Re: [R] Rows to Column

2013-12-16 Thread David Carlson
ect.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Sunday, December 15, 2013 7:49 PM To: r-help@r-project.org Cc: marcos.takahashi Subject: Re: [R] Rows to Column Hi, Try: dat1 <- read.table(text="id cat val 1  A  2 1  C  4 3  B  1 5  A  2 6  A  3 6  B  5 6  C  2 8 

Re: [R] Rows to Column

2013-12-16 Thread arun
Hi, Try: dat1 <- read.table(text="id cat val 1  A  2 1  C  4 3  B  1 5  A  2 6  A  3 6  B  5 6  C  2 8  B  5 8  D  2 9  D  3",sep="",header=TRUE,stringsAsFactors=FALSE) library(reshape2)  res1 <- dcast(dat1,id~cat,value.var="val",fill=0) colnames(res1)[-1] <- paste0("cat",colnames(res1)[-1]) #o

[R] Rows to Column

2013-12-15 Thread marcos.takahashi
Hi all, I'm kinda new in R programming and I need some help preparing a database to run logistic regression. I have data in a tuple form: *id cat val* 1 A 2 1 C 4 3 B 1 5 A 2 6 A 3 6 B 5 6 C 2 8 B 5 8 D 2 9 D 3 and would like to have it like: *id catA