data frame function in r code example
Example 1: simple data frame in R
// in RStudio
dat <- data.frame(
SSN = c(204,401,101,666,777),
Name=c("Blossum","Buttercup","Bubbles","MojoJojo","Professor"),
Age = c(7,8,6,43,56),
Gender = c(0,0,0,1,1)
)
Example 2: how to apply a function to a dataframe in r
x = apply(df, MARGIN = 2, FUN = mean)