Dear all,
I have a list of dataframes from (1 to no.of.subs) -
some of the column classes have been read incorrectly
as factors instead of characters. I have
class(dataframes) is a list
class(dataframes[[k]]) is a data.frame
class(dataframes[[k]][j]) is a factor or numeric
(where j runs from 1 to no.of.cols[[k]])
I would like to use the sapply function to change the
columns that have class factor to character for all
data frames.
I thought something along the lines of:
dataframes <- sapply(1: no.of.subs, function(k)
sapply(1:no.of.cols[[k]], function(j) {
if(is.factor(dataframes[[k]][,j])) dataframes[[k][,j]
<- as.character(dataframes[[k]][,j])
}
))
would work, but doesn't.
Can someone please tell me where I'm going wrong.
Thanks in advance for any help.
Dave
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
|