I think what you want is something like:
time<-seq(as.Date("2005/1/1"), as.Date("2005/1/10"), "days")
age<-round(runif(10,30,50))
measure<-rnorm(10)
mydat<-data.frame(time=time,age=age,measure=measure) #creates a data frame with your 3 #variables
time age measure 1 2005-01-01 48 -1.2873181 2 2005-01-02 50 0.5776001 3 2005-01-03 44 0.1892008 4 2005-01-04 38 0.4981651 5 2005-01-05 49 -1.7591745 6 2005-01-06 37 -0.8898464 7 2005-01-07 30 0.7528217 8 2005-01-08 46 -1.2421763 9 2005-01-09 39 -0.9333667 10 2005-01-10 32 1.2086509
#suppose you only want patients older than 40
Older40<-mydat[age>=40,c(1,3)]
time measure
1 2005-01-01 -1.2873181
2 2005-01-02 0.5776001
3 2005-01-03 0.1892008
5 2005-01-05 -1.7591745
8 2005-01-08 -1.2421763Is this what you wanted to do?
Francisco
From: "" <[EMAIL PROTECTED]> To: "" <[email protected]> Subject: [R] he^lp on "stack" function Date: Thu, 3 Feb 2005 18:10:24 +0100
Excuse me. I don't understant how to use the function "stack". I'm not sure to know the good syntax.
I've got a data witch column names are the time when the mesures was done and
an
other who indicates the age of the subjetcs.
I would like to do a new matrix with patients older than a value and the new
matrix will contain in the first column the time of the mesures and in the
second th evalue of the mesure.
Could you help me please ?
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
