You could use lapply indeed of sapply:
irisf[,index] <- lapply(irisf[,index], as.factor)
str(irisf)
On Wed, Sep 9, 2009 at 8:06 AM, Petr PIKAL wrote:
> Dear all
>
> I have a simple problem which I thought is easy to solve but what I tried
> did not work. I want to change character variables to
Dear all
I have a simple problem which I thought is easy to solve but what I tried
did not work. I want to change character variables to factor in data
frame. It goes easily from factor to character, but I am stuck in how to
do backwards conversion.
Here is an example
irisf<-iris
irisf[,2]<-f
2 matches
Mail list logo