i'm trying to use this R script, but the problem is that it's not working the way i want.
Here is the script:
#!/usr/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
df = read.table(args[1], header=FALSE, sep="\t", row.names=1)
#print(df)
df.0 <- apply(df, c(1,2), function(x) {if(x>0) return (x) }) #this function doesn't work it must select only data >0
df.0
the input data is like this:
mir1306 0
mir151 0
mir302b 0
mir5124 0
mir744 0
mmu-let-7a-5p 60
mmu-let-7b-5p 15
mmu-let-7c-5p 77
mmu-let-7f-5p 60
mmu-let-7i-5p 22
and i get this error :
V2
mir1306 NULL
mir151 NULL
mir302b NULL
mir5124 NULL
mir744 NULL
mmu-let-7a-5p 60
mmu-let-7b-5p 15
mmu-let-7c-5p 77
mmu-let-7f-5p 60
mmu-let-7i-5p 22
i don't want of the lines containing value == 0, i only want to keep data with value > 0
I tried other solution but nothing worked...
Thanks you !
edit:
i tried this way :
df.0 <- df[, df$V2>0]
but i get this error message :
Error in `[.data.frame`(df, , df$V2 > 0) : undefined columns selected
Calls: [ -> [.data.frame