Hi I have a dataset with multiple columns that are populated with either NA or "Y". I wish to make these values 0 and 1 respectively.
I am fairly new to R, and trying to determine the best way to loop through these variables and recode them.
STATE<-c(NA, "WA", "NY", NA, NA)
x<-c(NA,"Y",NA,NA,"Y")
y<-c(NA,NA,"Y",NA,"Y")
z<-c("Y","Y",NA, NA, NA)
mydata<-data.frame(x,y,z)
I have a large dataset, and many of these variables. However, some of them (such as STATE), I wish to leave alone. Any help would be greatly appreciated. Thanks.