[R] add a data frame to my data frame
Tagmarie
Ramgad82 at gmx.net
Tue Sep 25 16:44:34 CEST 2012
Hello,
Once again I feel so dumb. Can anyone help me?
I have a data frame somewhat like that:
myframe <- data.frame (ID=c("Ernie", "Ernie", "Bert", "Bert"),
Timestamp=c("24.09.2012 09:00", "25.09.2012 09:00", "24.09.2012 10:00",
"25.09.2012 10:00"), Hunger=c("1","1","2","2") )
myframestime <- as.POSIXct (strptime(as.character(myframe$Timestamp),
"%d.%m.%Y %H:%M"), tz="GMT")
myframe2 <- cbind (myframe,myframestime)
myframe2$Timestamp <- NULL
Now I have a second dataframe with environmental variables. Something like
this:
environ <- data.frame (ID=c("Ernie", "Ernie", "Bert"),
Timestamp=c("24.09.2012 09:00", "25.09.2012 09:00", "25.09.2012 10:00"),
Temp=c("25","30","27"), Rain =c ("0.1", "5", "2"))
envirotime <- as.POSIXct (strptime(as.character(environ$Timestamp),
"%d.%m.%Y %H:%M"), tz="GMT")
environ2 <- cbind (environ,envirotime)
environ2$Timestamp <- NULL
How do I merge or handle the two data frames at the respective lines so that
I get the data (Temp, Rain) at the correct line with (Hunger)?
--
View this message in context: http://r.789695.n4.nabble.com/add-a-data-frame-to-my-data-frame-tp4644122.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list