See
?read.csv
and read the part about colClasses.
> X <- read.csv(textConnection("x1 ,x2,x3
+ 10,20,30
+ 11 ,22,35"), colClasses = c("character", "character",
"numeric")
+ )> str(X)
'data.frame': 2 obs. of 3 variables:
$ x1: chr "10" "11 "
$ x2: chr "20" "22"
$ x3: num 30 35>
-Ista
On Thu, Nov 5, 2009 at 5:58 PM, Vadlamani, Satish {FLNA}
<SATISH.VADLAMANI at fritolay.com> wrote:> Hi:
> If I want to read a file with read.table. I want x1 and x2 to be read as
character and x3 as numeric. How to do this? Thanks.
> Satish
>
>
> x1 ,x2,x3
> 10,20,30
> 11 ,22,35
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org