Skip to content
Prev 280916 / 398503 Next

Help with code

Hi

Can you explain rules for propagating values? I do not see any pattern. 
Only when there is no Y in a line you want to fill all columns with either 
T1D_noc or Ctrl_noc based on t1d_ptype.

I would start with narrowing the levels in last column as it seems to me 
there is no difference between Ctrl and Ctrl_FDR in desired result

levels(c1$t1d_ptype)[1:2] <- "Ctrl"
If you want to retain old values just make a new column with t1d_ptype and 
change levels only in this new column.

select all rows without Y
selection<-which(rowSums(c1[,1:6]=="")==6)

change columns 1:6 to character instead of factors
c1[,1:6]<-sapply(c2[,1:6], as.character)

put values from last column to other columns and add "noc"
c1[selection,1:6]<-paste(c1[selection,7], "noc", sep="_")

and after that I am lost.

Petr
row.names
http://www.R-project.org/posting-guide.html