drop = TRUE ) # Collapse the dataįormula <- as.formula ( paste ( measurevar, paste ( groupvars, collapse = " + " ), sep = " ~ " )) datac <- summaryBy ( formula, data = data, FUN = c ( length2, mean, sd ), na.rm = na. SummarySE <- function ( data = NULL, measurevar, groupvars = NULL, na.rm = FALSE, conf.interval =. # conf.interval: the percent range of the confidence interval (default is 95%) # na.rm: a boolean that indicates whether to ignore NA's # groupvars: a vector containing names of columns that contain grouping variables To find the means, standard deviations, and n's for the two study groups in the 'kidswalk' data set: > tapply (agewalk, group, mean) > tapply (agewalk, group, sd) > tapply (agewalk, group, length) 1 2 33 17 The subset () function creates a new data frame, restricting observations to those that meet some criteria. # measurevar: the name of a column that contains the variable to be summariezed # Gives count, mean, standard deviation, standard error of the mean, and confidence interval (default 95%). To use, put this function in your code and call it as demonstrated below.
0 Comments
Leave a Reply. |