Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

extracting specific column with certain condition on one column only

I have a data(in R) in below form,

enter image description here

A B C D
x alpha sine 0
y gama cos 1
z beta tan 2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

and I want to extract only column A & B where column D > 0.
i tried using data %>% filter(D > 0), which gives me last two rows where D>0 but it also gives me column c which i don’t want.
how can i get only column A&B with condition applied on column D only.?

Data in text:

A B C D
x alpha sine 0
y gama cos 1
z beta tan 2

>Solution :

data %>% filter(D > 0) %>%select(A,B, D)
  A    B D
1 y gama 1
2 z beta 2

or even:

data %>% filter(D > 0) %>%select(-C)
  A    B D
1 y gama 1
2 z beta 2
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading