# -----------------------------------------------
# ss for data frames and multiple variables
# -----------------------------------------------
# create data frame, mydata, to mimic reading data with rad function
# mydata contains both numeric and non-numeric data
# X has two character values, Y is numeric
n <- 12
X <- sample(c("Group1","Group2"), size=n, replace=TRUE)
Y <- round(rnorm(n=n, mean=50, sd=10),3)
mydata <- data.frame(X,Y)
rm(X); rm(Y)
# Analyze all the values of numerical Y, then categorical X
ss(Y)
ss(X)
# Analyze all the values of Y and X with more output
ss(Y, brief=FALSE)
ss(X, brief=FALSE)
# Get the summary statistics for Y at each level of X
# Specify 2 decimal digits for each statistic displayed
ss(Y, by=X, digits.d=2)
# Analyze all variables in data frame mydata at once
# Any variables with a numeric data type and 4 or less
# unique values will be analyzed as a categorical variable
ss()
# Analyze all variables in data frame mydata at once
# Any variables with a numeric data type and 7 or less
# unique values will be analyzed as a categorical variable
ss(ncut=7)
# variables in a data frame which is not the default mydata
# access the breaks variable in the R provided warpbreaks data set
# although data not attached, access the variable directly by its name
data(warpbreaks)
ss(breaks, by=wool, dframe=warpbreaks)
# Analyze all variables in data frame warpbreaks at once
ss(warpbreaks)
Run the code above in your browser using DataLab