Replacement of table values in R? -
the following codes:
female=(1) male=(2) r <- sapply(list(female, male), length) distribution = sample(c(female, male), size = 100, prob = rep(c(0.2, 0.8) / r, r), replace = true) summary(distribution) distribution[distribution == "1"] <- "f"
i replace 1s "f" , 2s "m". how can it? please help.
i think have change vector's type character first:
distribution <- as.character(distribution) distribution[distribution == "1"] <- "f" distribution[distribution == "2"] <- "m"
Comments
Post a Comment