Linked Questions

50 votes
3 answers
246k views

I've been playing around with the airquality dataset in R and figuring out how to remove lines with missing values. I used the following command: complete.cases(airquality) AQ1<-airquality[...
killahtron's user avatar
2 votes
2 answers
15k views

How can I replace, for example, all "-sh2", in a column (V2) with -100, as in the following dataframe: V1 V2 V3 p1 -sh2 13 p2 23 29 p3 17 25 p4 -sh2 34 Thanks
user27976's user avatar
  • 903
1 vote
1 answer
10k views

I have a dataset with lots of numerical variables, and a character variables that says whether or not low values are suppressed for that observation. In observations where values aren't suppressed, I ...
user5457414's user avatar
1 vote
1 answer
9k views

I want all NAs to be replaced with "Not Found" in a df . i have this df A B 1 NA 2 NA 3 NA How can i get that . A B 1 Not Found 2 Not Found 3 Not Found
Pankaj Kaundal's user avatar
0 votes
3 answers
3k views

I want to replace some empty cells in Variable B and Variable C with 0 if Variable A == 0. If Variable A equals anything but 0 I would like Variable B and Variable C to stay the same. I've created a ...
Tyler's user avatar
  • 29
1 vote
3 answers
2k views

merged$number_articles %>% replace_na(0) Im trying to replace all na values in a column (number_articles) in the df (merged), with 0. I have tried the above code but the values are not getting ...
Galadriel's user avatar
0 votes
1 answer
5k views

In a dataset of 589 rows there are around 50 entries who miss a variable and are assigned the NA value, but I know which value that should have ("Brussel Hoofstedelijk Gewest" is the exact ...
AronBrownie's user avatar
0 votes
1 answer
3k views

Quite new to R, I am trying to subselect certain columns in order to set their NA's to 0. so far I have: col_names1 <- c('a','b','c') col_names2 <- c('e','f','g') col_names <- c(col_names1,...
tosh1611's user avatar
-2 votes
2 answers
3k views

Recently, I started learning R. I would like to replace certain word in table by other word in the same table. For example, my table looks like No. Fruits Weight Size 1 AB 200 L 2 AM 150 M 3 ...
H. Suzuki's user avatar
1 vote
1 answer
3k views

Is there a quick way to run multiple arithmetic operations across data frame variables while ignoring cases with NAs? I've put a simple example below. It seems I could add intermediary variables or '...
val's user avatar
  • 1,709
-1 votes
3 answers
1k views

i have a dataframe that looks like this : Date = seq(as.Date("2022/1/1"), by = "day", length.out = 10) x = c(rnorm(9),NA) y = c(NA,0,rnorm(4),6,0,0,10) z = c(rnorm(4),0,0,NA,NA,3,2)...
Homer Jay Simpson's user avatar
3 votes
1 answer
2k views

I need to replace some data in my dataframe, which looks like this: V1 V2 V3 V4 1 * * 4 5 2 * * 4 * 3 4 * 2 2 4 * * 1 * If a "*" is in that cell, replace it with the value of the ...
user2567875's user avatar
0 votes
0 answers
3k views

Basically, I am iterating through some values, some which may be NA. If it is NA, I'd like to set it to 0. For example if (myValue.is.na){ myValue=0 }
Luke Zhang's user avatar
1 vote
2 answers
1k views

I want to merge the following 3 data frames and fill the missing values with -1. I think I should use the fct merge() but not exactly know how to do it. > df1 Letter Values1 1 A 1 2 ...
Math Avengers's user avatar
-2 votes
1 answer
2k views

I have a data set: x y z 1 apple a 4 2 orange d 3 3 banana b 2 4 strawberry c 1 How can I change the name "banana" to "grape"? I want to get: x y z 1 apple a ...
Asteroid098's user avatar
  • 2,865

15 30 50 per page
1
2 3 4 5 6