Replace Particular Value in Data Frame in R (2 Examples) | Change Certain Values in Variable/Column

Published: 27 March 2020
on channel: Statistics Globe
22,656
182

How to modify specific values in a data frame in the R programming language. More details: https://statisticsglobe.com/replace-p...
R code of this video:

data <- data.frame(x1 = 1:5,
x2 = LETTERS[1:5],
x3 = c("A", "C", "A", "A", "B"),
x4 = factor(c("f1", "f2", "f3", "f2", "f1")),
stringsAsFactors = FALSE)

data1 <- data # Replicate data
data1[data1 == "A"] <- "XXX"

data2 <- data # Replicate data
data2[data2 == "f2"] <- "YYY"

data2 <- data # Replicate data
data2$x4 <- as.character(data2$x4)
data2[data2 == "f2"] <- "YYY"
data2$x4 <- as.factor(data2$x4)


On this page of the site you can watch the video online Replace Particular Value in Data Frame in R (2 Examples) | Change Certain Values in Variable/Column with a duration of hours minute second in good quality, which was uploaded by the user Statistics Globe 27 March 2020, share the link with friends and acquaintances, this video has already been watched 22,656 times on youtube and it was liked by 182 viewers. Enjoy your viewing!