Hi,
Try:
dat <- read.table(text="
ID Name
1 Andy
2 John
3 Amy",sep="",header=TRUE,stringsAsFactors=FALSE)
dat2 <- read.table(text="
ID Date Value
1 2013-10-01 10
1 2013-10-02 15
2 2013-10-01 7
2 2013-10-03 10
2 2013-10-04 15
3 2013-10-01
Hi,
I think based on your title, the output you provided is not clear. If it
depends on Date, there should be four columns.
library(reshape2)
res1 <- dcast(merge(dat,dat2,by="ID"),ID+Name~Date,value.var="Value")
colnames(res1)[3:6] <- c("First", "Second", "Third", "Fourth")
rownames(res1) <- 1
hello togehter,
i have a little problem, maybe you can help me.
I have a data.frame like this one:
IDName
1 Andy
2 John
3 Amy
and a data.frame like this:
ID DateValue
12013-10-0110
12013-10-0215
22013-10-017
22013-10-0310
22013-
3 matches
Mail list logo