<<>>= options(width = 60) Loading the functions Making sure we can source code from github source("http://www.r-statistics.com/wp-content/uploads/2012/01/sourcehttps.r.txt") Reading in the function for using tabular on a castdf object: sourcehttps("https://raw.github.com/talgalili/R-code-snippets/master/tabular.castdf.r") require(reshape) names(airquality) <- tolower(names(airquality)) airquality2 <- airquality airquality2temp2 <- ifelse(airquality2temp > median(airquality2temp), "hot", "cold") aqm <- melt(airquality2, id=c("month", "day","temp2"), na.rm=TRUE) colnames(aqm)[4] <- "variable2" because otherwise the function is having problem when relying on the melt function of the cast object head(aqm,4) tabular.castdf(cast(aqm, month variable2, c(mean,sd))) tabular(cast(aqm, month variable2, c(mean,sd))) @ <>= Hmisc::latex(tabular(cast(aqm, month variable2, c(mean,sd)))) @ LaTeX Original \documentclass[12pt,a4paper]{article} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} <<>>= options(width = 60) ###################### # Loading the functions ###################### # Making sure we can source code from github source("http://www.r-statistics.com/wp-content/uploads/2012/01/source_https.r.txt") # Reading in the function for using tabular on a cast_df object: source_https("https://raw.github.com/talgalili/R-code-snippets/master/tabular.cast_df.r") require(reshape) names(airquality) <- tolower(names(airquality)) airquality2 <- airquality airquality2$temp2 <- ifelse(airquality2$temp > median(airquality2$temp), "hot", "cold") aqm <- melt(airquality2, id=c("month", "day","temp2"), na.rm=TRUE) colnames(aqm)[4] <- "variable2" # because otherwise the function is having problem when relying on the melt function of the cast object # head(aqm,4) # tabular.cast_df(cast(aqm, month ~ variable2, c(mean,sd))) # tabular(cast(aqm, month ~ variable2, c(mean,sd))) @ <>= Hmisc::latex(tabular(cast(aqm, month ~ variable2, c(mean,sd)))) @ \end{document}