Not the prettiest code but it returns what you want. Might be slow for
large dataframes.
df <- data.frame( ID=c(1,1,1,1,2,2),
TEST=c("A","A","B","C","B","B"),
RESULT=c(17,12,15,12,8,9) )
big.out <- list(NULL)
for( uID in unique(df$ID) ){
m <- df[ df$ID ==
Thank you for your suggestion, I will play around with it. I guess my concern
is that I need each test result to occupy its own "cell" rather than have
one or more in the same row.
Adaikalavan Ramasamy-2 wrote:
>
> There might be a more elegant way of doing this but here is a way of
> doing it
There might be a more elegant way of doing this but here is a way of
doing it without reshape().
df <- data.frame( ID=c(1,1,1,1,2,2),
TEST=c("A","A","B","C","B","B"),
RESULT=c(17,12,15,12,8,9) )
df.s <- split( df, df$ID )
out <- sapply( df.s,
I have a dataset in "long" format that looks something like this:
ID TESTRESULT
1 A 17
1 A 12
1 B 15
1 C 12
2 B 8
2 B 9
Now what I would like to do is transpose it like so:
IDTEST ATEST B
4 matches
Mail list logo