library(datasets)
library(dplyr)

# select columns by name:
print("=> mpg,cyl,dps,qsec:")
selecn = select(mtcars,mpg,cyl,disp,qsec)
head(selecn)

# data filter
#filter(mtcars, mpg > 20)
print("Filter by mpg > 20 and cyl > 5:")
f = filter(mtcars, mpg > 20 & cyl > 5)
head(f)

# add a new column
#dm=mutate(mtcars, TempInC = (Temp - 32) * 5 / 9)
#head(dm)

# summarize and group by data
#print("=> summarize by mpg:")
#summarise(mtcars, mpg)

# group: average wind value per month
# Month is the basis of grouping
#print("=> group by cl and mean by mpg:")
#summarise(group_by(mtcars, cyl), mean(mpg, na.rm = TRUE))

