Conditionally Remove Row from Data Frame in R (3 Examples) | How to Delete Rows of Matrix or Table

preview_player
Показать описание
R code of this video:

x2 = letters[1:5],
x3 = "x")

##### Example 1
data[data$x1 != 2, ] # Remove row based on condition

##### Example 2
data[data$x1 != 2 & data$x2 != "e", ] # Multiple conditions

##### Example 3
subset(data, data$x1 != 2 & data$x2 != "e") # Apply subset function
Рекомендации по теме
Комментарии
Автор

Hey! I just wanted to add to one of your video a comment saying that your work is very appreciated. It is of top-quality, and I thank you greatly for making it freely available. Please continue your great work- it is very much appreciated by many! Have a lovely rest of your day : )

philippagadsby
Автор

The best channel for learning R! Thank you!

michaelrussi
Автор

Hi, sir I'm just wondering how to remove rows that have inconsistent string length in a huge data set.

raffyraffy
Автор

hey thanks for the vid. do u know by chance how to remove rows in two time series that have intercept values?

kseniyapak
Автор

Hey sir, i was wondering if you know how to remove only a specific percentage of row where we have a specific value. For exemple we have 10 rows with a value of 1 and we want to remove half of those row

henrytadja
Автор

Hello. Thanks for the video. what if I want to remove columns with all zeros? I want to keep the first column with ID, but want to remove columns 2-7 with all zeros.

heekyunghong
Автор

Hi, I really tried to do this question but I could not, can u please help me with how to write the code for it?

4.7 Use the subset function to return a data frame made from the Cars93 (MASS) data frame consisting only of non-USA cars in origin, with 4 cylinders and a maximum price of $15, 000 or less.

> subset(Cars93, Origin=="non-USA", Cylinders=1:4, Max.Price <= 15)
this is how I wrote it but Its did not gave me "4 cylinders" and "maximum price of $15, 000 or less."


thank you

byoo
Автор

what if I want to remove column, or few items from a particular column? I hope you will answer this.

zakjay
Автор

Hi I just wanted to tell you that this method doesnt work in the new update

danielricardo
Автор

Hi, but what is about the case when we want to remove several rows in one column?

narekmirzoyan
Автор

i got an error.... "Error: unexpected numeric constant"

jullsjocson