> subset(df, X1 >= 1.5 | X1 <= -2) also works. If you are trying dplyr, for the above data frame, use following code:
library(dplyr)
df %>% filter (X1 >= 1.5 | X1 <= -2)
However, with dplyr, one of the issues is that you would loose row index (row names), to retain row index/row names, use following code:
library(dplyr)
library(tibble)
df %>%
rownames_to_column() %>%
filter (X1 >= 1.5 | X1 <= -2) %>%
column_to_rownames()
Please show us what you tried
Hello challagandla.anil!
We believe that this post does not fit the main topic of this site.
Pure R question, please search StackOverflow
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!