I have a dataframe in R that looks like this:
V1 T1 T2 T3 T4 T5
CXCL6 0.8536601 1.0903336 3.7633042 5.5800459 5.8477150
PPBP 0.7739450 0.3587961 0.5073359 0.2743522 0.6221722
CXCL10 0.1258370 -0.3535165 -0.7460387 3.5604672 0.1971432
CXCL11 -0.2563139 0.7117200 0.0000000 -0.2288303 0.9955557
CXCL12 0.6181279 1.7529310 1.7637760 1.2752787 1.2284810
I want to keep the rows that have values only between -1 and 1.
I have tried this command but unfortunately it does not work.
condition1 <- Genes[,c(2:6)] <=-1 & Genes[,c(2:6)] >=1
Genes <- Genes[condition1,]
Can someone tell me where I am wrong so that I can successfully filter my dataframe.
Assuming these are log2 fold changes or something like that, I don't know why you would want columns with values between -1 and 1, because most people want values exactly outside of that range. I may be reading this wrong, but you also seem to be asking for values
<=-1
which is to the "left" of -1, and>=1
which is to the "right" of 1.Did you try
&&
instead of&
?Since the
length(condition1)
is >1, and && check only for the first element in vector, && should be avoided here.