Re: [R] Excel to R

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Mon 17 Jul 2006 - 17:04:59 EST

Hi

based on your output qw is not a factor. What does say

str(data)

If your file is coded 1,2,9 it was imported as numeric and changing 9 to NA inside R does not change its nature to factor. You has to explicitly convert qw to factor e.g.

data$qw<as.factor(data$qw)

HTH
Petr

On 15 Jul 2006 at 11:50, Bernardo Rangel tura wrote:

Date sent:      	Sat, 15 Jul 2006 11:50:14 -0300
To:             	R-help@stat.math.ethz.ch
From:           	Bernardo Rangel tura <tura@centroin.com.br>
Subject:        	[R] Excel to R

>
> >Hi peolple!
>
>
> I have a many excel tables with mode than 100 variables. And I want
> use R to analize that.
>
> But I have a problem, a group of this variables (more than 50) in any
> table is a factor and other part is a number.
>
> Tha factors variables have tha values enconde this form (1=Yes,2=No
> and 9 = NA)
>
> Well I use this scripts to import the database
>
> require(RODBC)
> channel <- odbcConnectExcel("f:/teste.xls")
> data <- sqlFetch(channel, "Sheet1")
> summary(data)
> qw ee
> Min. :1.000 Min. :1.000
> 1st Qu.:1.000 1st Qu.:1.500
> Median :1.000 Median :2.000
> Mean :1.333 Mean :2.429
> 3rd Qu.:1.750 3rd Qu.:3.500
> Max. :2.000 Max. :4.000
> NA's :1.000
>
>
> But qw is a factor (and is colnum type isvtext)
>
> Is possible modify my script for this utcome
>
> > summary(data)
> qw ee
> 1 :4 Min. :1.000
> 2 :2 1st Qu.:1.500
> NA's:1 Median :2.000
> Mean :2.429
> 3rd Qu.:3.500
> Max. :4.000
>
>
> Thanks in advance
>
> Bernardo Rangel Tura, MD, MSc
> National Institute of Cardiology Laranjeiras
> Rio de Janeiro Brazil
>
> ______________________________________________
> R-help@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

Petr Pikal
petr.pikal@precheza.cz



R-help@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 Received on Mon Jul 17 17:21:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 17 Jul 2006 - 18:15:56 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.