[R] how to find and use specific column after spliting dataframe

leeznar leeznar at yahoo.com.tw
Wed Nov 28 08:55:44 CET 2007



Dear all: 


I am a new R-user and I have 2 questions
about it.  


1) I need to find specific sub-dataframe,
and then use specific column to calculate. 
For example, after splitting dataframe, I find specific the
sub-dataframe, such as “A.split [1]”. 
But, I don’t know how to find “time” and “concentration” columns of “A.split
[1]”.  


2) The equation used to sub-dataframe is
(time[i]-time[i-1])*(concentration[i]- concentration[i-1])*1/2.  I don’t know how to calculate it.  How can I find the specific column and use it to calculate ? 



 


x<-rep(c(1.2,6.8),4)


y<-rep(c(1, 2),4)


z<-rep(c(1,2),4)


t<-rep(c(0,1,2,3),length.out=8)


c<-rep(c(0,0.5,1,2),length.out=8)


df<-data.frame(pH=x, formulation=y,
subject=z, time=t, concentration=c)


A.split<-split(df, list(df$pH
,df$formulation, df$subject) )


A.split [1] 




 


Best regards,


Hsin-Ya Lee






      ______________________________________________________________________________________
怎樣減少垃圾信?只要看到垃圾信,立即按下「這是垃圾信」按鈕。http://tw.promo.yahoo.com/antispam/index.html



More information about the R-help mailing list