[R] String in data frame

Bill.Venables@csiro.au Bill.Venables at csiro.au
Sat Apr 16 07:31:54 CEST 2005


str <- as.character(d$name)

should do the trick.  (damn... my shift key just broke as well...)

bill venables.

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Cuichang Zhao
Sent: Saturday, 16 April 2005 2:00 PM
To: r-help at stat.math.ethz.ch
Subject: [R] String in data frame


hello, 
how can take the string in the data frame.
right now i have a table that create as a data frame and stored in the
file called "data.xls" and now i want to read data frame as a table in
my another r program, i used the following command:
the first column of the data frame is just one number called "num", but
the second one a list of string, called "name". 
 
d <- read.table("data.xls", header = T);
 
what i get for d is a table of 2 columns: num and name: 
 
the one for d$num is just a normal list without any levels with it, and
this is what i want. but the second d$name is a list with a levels with
it. 
the list i have for d$name is: d$name = (bal bal bal bal bal bal),
levlels:bal, however, when i want to have for following code, something
different happens:
namelist <- NA;
a <- d$name[1]; #this will outputs a = bal, lelvels:bal
 namelist <- c(namelist, a); #this does not outptu (NA, bal), instead it
outputs (NA, 1), if i keep #adding a to the namelist, it keeps adding 1
to the namelist instead of bal. However, i want to add bal to the
namelist, not 1, so how i can do this?
 
Thank you very much.
 
Cuichang Zhao
 
April 15, 2005 

		
---------------------------------


	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list