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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -