I am fairly new to R and can't get my head around "apply" family functions. Please help in resolving this query. I have run the following code:
attach(airquality)
mydata<-airquality
col_names1<-names(mydata)
mydata[,col_names1]<-lapply(mydata[,col_names1],factor)
str(mydata)
col_names2<-names(mydata)
mydata[,col_names2]<-sapply(mydata[,col_names2],factor)
str(mydata)
I see that lapply converts all numeric variables into factors but sapply does not do that. Why is it so? Please do throw light on it.