## ----------------------------------------------------------------------------- head(mtcars) ## ----------------------------------------------------------------------------- our.data <- mtcars our.data$mpg[5] <- our.data$mpg[5] * -1 our.data[4:6,] ## ----message=FALSE------------------------------------------------------------ library(dplyr) our.data %>% group_by(cyl) %>% summarise(avg.mpg=mean(mpg)) ## ----------------------------------------------------------------------------- not.empty.p <- function(x) if(x=="") return(FALSE) ## ----------------------------------------------------------------------------- seven.digit.p <- function(x) nchar(x)==7 ## ----perl=FALSE--------------------------------------------------------------- example.data <- data.frame(x=c(8, 9, 6, 5, 9, 5, 6, 7, 8, 9, 6, 5, 5, 6, 7), y=c(82, 91, 61, 49, 40, 49, 57, 74, 78, 90, 61, 49, 51, 62, 68)) (example.data)