Skip to main content
William Boon
Age: 15-26 The age where you meet a lot of temporary people.
Asked a question last year

how to exclude data in r?

Where am I?

In answerQA you can ask and answer questions and share your experience with others!

Adam Leo
The smart thing to do once wealthy: Keeping a low profile.

To exclude variables from dataset, use same function but with the sign - before the colon number like dt[,c(-x,-y)] . Sometimes you need to exclude observation based on certain condition. For this task the function subset() is used. subset() function is broadly used in R programing and datasets. The most easiest way to drop columns is by using subset() function. In the code below, we are telling R to drop variables x and z. The '-' sign indicates dropping variables. Make sure the variable names would NOT be specified in quotes when using subset() function.