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.
Where am I?
In answerQA you can ask and answer questions and share your experience with others!