I have data of the form

tC <- textConnection("
Subject Date    parameter1
bob     3/2/99  10
bob     4/2/99  10
bob     5/5/99  10
bob     6/27/99 NA
bob     8/35/01 10
bob     3/2/02  10
steve   1/2/99  4
steve   2/2/00  7
steve   3/2/01  10
steve   4/2/02  NA
steve   5/2/03  16
kevin   6/5/04  24
")
data <- read.table(header=TRUE, tC)
close.connection(tC)
rm(tC)

I am trying to calculate rate of change of parameter1 in units/day for each
person. I think I need something like:
"lapply(split(mydata, mydata$ppt), function(x) lm(parameter1 ~ day,
data=x))"

I am not sure how to handle the dates in order to have the first day for
each person be time = 0, and the remaining dates to be handled as days since
time 0. Also, is there a way to add the resulting slopes to the data set as
a new column? 

Thanks,
Marcel 

--
View this message in context: 
http://r.789695.n4.nabble.com/regression-on-data-subsets-in-datafile-tp3806743p3806743.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to