s-news
[Top] [All Lists]

list question

To: s-news@lists.biostat.wustl.edu
Subject: list question
From: Dave Evens <devens8765@yahoo.com>
Date: Tue, 31 May 2005 06:49:42 -0700 (PDT)
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=R6FVaTs1dbTcoJI+CETCwUUgj8MccYPKSqwR+/8kpz7UJ22D5K7YBhmceEaadbMwpsUkyjhL/VLUqH8b2zTlUB9cLxWTGW/CAyosmcxT4WPSFZY0zo/EGS5/A6QjHefwnm3iMXSq5M/mNz7ryQnhlJFU1AQdzJYGPVmjPYmaB9E= ;
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 

<Prev in Thread] Current Thread [Next in Thread>