How to copy a table in R -


the problem have following. load table file

table <- read.table(opt$input, header = true, sep = "\t") 

then remove things not need

tt<-table[(table[,2] != "xz" & table[,1] != "n" & table[,1] != ""),] 

then compute frequencies

freq<-table(tt[,1], tt[,2]) 

but

        xz b       0  0   0       0   s   0  1   0       3   c   0 28   0      83   n   0  0   0       0 

so values have been removed placeholders : xz(col), ""(col), n(row) have stayed. how eliminate those. there way copy table not reference value placeholders skipped

try (remove factor levels dropped):

tt<-table[(table[,2] != "xz" & table[,1] != "n" & table[,1] != ""),]  tt[,1] <- factor(tt[,1]) tt[,2] <- factor(tt[,2]) 

and then

freq<-table(tt[,1], tt[,2]) 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -