[R] Excel to R

Petr Pikal petr.pikal at precheza.cz
Mon Jul 17 09:04:59 CEST 2006


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 at stat.math.ethz.ch
From:           	Bernardo Rangel tura <tura at 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 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

Petr Pikal
petr.pikal at precheza.cz



More information about the R-help mailing list