Suppose I have a data.frame
names <- c("John", "Mark", "Larry", "Will", "Kate", "Daria", "Tom")
gender <- c("M", "M", "M", "M", "F", "F", "M")
mark <- c(1, 2, 3, 1, 2, 3, 1)
df <- data.frame(names, gender, mark)
df
names gender mark
1 John M 1
2 Mark M 2
3 Larry M 3
4 Will M 1
5 Kate F 2
6 Daria F 3
7 Tom M 1
I can't figure out how to replace certain values as NAs
. For example, if I want mark
for Kate
, Daria
and Tom
to be NAs
:
names gender mark
1 John M 1
2 Mark M 2
3 Larry M 3
4 Will M 1
5 Kate F NA
6 Daria F NA
7 Tom M NA
Try
Or
Or