Skip to content

2 factor split and lapply

1 message · arun

#
Hi,
No problem.
If you have two columns and need the ratio, you could use ?transform
?testframe$data1 <- c(2.24,6.5,4.34)


dcast(transform(testframe,ratio=data/data1),factor2~factor1,value.var="ratio",mean)
#? factor2??????? a???????? b
#1?????? 1 1.491071?????? NaN
#2?????? 2 0.483871 0.6461538
A.K.
On Monday, December 23, 2013 10:49 AM, Onur Uncu <onuruncu at gmail.com> wrote:
Thank you Arun. May I ask a follow up question? What if the function needed to take multiple arguments? So, instead of "mean", suppose the function was ?function(x,y){x/y} and suppose x and y inputs were 2 columns of a data frame. In other words, is there an mapply type function under reshape package?

thnks
On Mon, Dec 23, 2013 at 2:45 PM, arun <smartpink111 at yahoo.com> wrote:
HI,