Re: [R] Datatable manipulation

2013-11-20 Thread Nitisha jha
Thanks a lot. It worked :) On Wed, Nov 20, 2013 at 9:44 AM, arun wrote: > Hi, > Try: > dat1 <- read.table(text="a b c > x 1 4 7 > y 2 5 8 > z 3 6 9",header=TRUE) > dat2 <- dat1 > #either > library(reshape2) > res1 <- > within(melt(dat1,id.var="ID"),cell<-as.character(interaction(variable,ID,sep

Re: [R] Datatable manipulation

2013-11-19 Thread arun
Hi, Try: dat1 <- read.table(text="a b c x 1 4 7 y 2 5 8 z 3 6 9",header=TRUE) dat2 <- dat1 #either library(reshape2) res1 <- within(melt(dat1,id.var="ID"),cell<-as.character(interaction(variable,ID,sep="_")))[,c(4,3)] #or indx <- which(dat2>0,arr.ind=TRUE) res2 <- data.frame(cell=paste(colnames