New dataset from old dataset

Hello,

I have dataset which has Age, lipid levels and disease A as 0,1. Disease B as 0,1

I want to make a new dataset where only disease A (0,1) is present with all other variables.

help me please. I am very new in R.

You might want to use the tidyverse package, and then the select() function. That let's you choose which variables to keep.

1 Like

You can use this :

your_dataset
library(tidyverse)

your_newdataset <- your_dataset %>% select(-DiseaseB)

If you want to drop more columns then use the same code select(-column_to_drop1,-column_to_drop2). The "-" does the trick by dropping off the column.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.