I find myself wanting to sometimes paste together columns from different dataframes (tables, matrices or whatever). For example I have a table of means and a table of stan devs. I want the two pasted together with the sd in a set of parentheses for latex printing. I suspect there's a friendly plyr solution but can't think of how to work on two data frames ( I attempted storing the dataframes as a list and using ldply but this was my first attempt with a list plyr function and it went down in flames.
Thank you in advance.
#=========
#fake data
#=========
x<-mtcars[1:3,1:3]
y<-mtcars[1:3,8:10]
#==========================
#A column pasting function
#==========================
meansd<-function(x, y){
x<-round(x, dig=2)
y<-round(y, dig=2)
paste(x, "(", y, ")", sep="")
}
That's as far as I got.
DESIRED OUTCOME No column names needed. I don't care if the return is a matrix or dataframe.
16.46(0) 0(1) 1(4)
17.02(0) 0(1) 1(4)
18.61(1) 1(1) 1(4)
mtablein the packagememisc. it is a very flexible function that allows you to output your regression output in multiple formats with minimal effort. - Ramnathxtablethe resulting data.frame? - Ari B. Friedmanmtableis super-flexible and it beats me that it can't do something standard :) - Ramnath