Dear all,
I have a data frame (expression_data) having many rows and 16 columns.
dark_11 dark_9 dark_7 dark_5
Gene1 0.41 0.58 1 0.91
Gene2 0.62 0.56 0.89 0.36
Gene3 0.89 0.41 0.67 0.76
Gene4 0.31 0.56 0.12 0.32
I want to subset rows having values >= 0.5 in different columns using dpylr filter function.
dark_11 <- filter (expression_data, dark_11 >= 0.5 )
Which returns:
dark_11
Gene2 0.62
Gene3 0.89
I want to use it in a for loop and want to make 16 files as there are 16 columns. I have tried but not getting the desired results.
for (i in names(expression_data)) {
test <- filter(expression_data, i >= 0.5
write.csv(test, paste0(i,".csv"))
}
Any help will be highly appreciated.
Thanks in advance
Please use the formatting bar (especially the
code
option) to present your post better. You can use backticks for inline code (`text` becomestext
), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.