I need to change the value of a variable.
One of them is called Village
and one of them is called site
. One of the Villages
that is called esperanza_paleta
has value 5 in variable site
and I want that 5 change to 4. Bone when the Village: esperanza_paleta
has value 5 in the site variable, change it to 4.
Try, but I get it as follows:
> data <- data[ which(data$country=="peru"), ]#
> summary(data$site)
2 3 4 5 6
0 0 833 2 171
> data$site<- ifelse(data$village=="esperanza_paleta" & data$site==5,4,data$site)
> data$site<- as.factor(data$site)
> summary(data$site)
3 4 5
833 2 171