Re: [R] Excel files

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Wed 25 Oct 2006 - 20:06:28 GMT

ramelan thiagarajah <ramelan3@yahoo.co.uk> writes:

> Hi every one,
>
> I am very very new to R and solicit your kind help
>
> I am trying to use my excel files in R. I used the
> Xlread/write package and able to load the a sample
> file into console. Then I tried to find the mean of a
> column vector for example. But I could not proceed
>
> Here is the problem
> rfile <- "Trial1.xls"
> > read.xls( rfile, colNames = TRUE, sheet = 1, type =
> "data.frame", from = 1 )
> x y z
> 1 4 7 9
> 2 5 7 10
> 3 6 9 11
>
> I request your help to find mean of column x

First, assign your data frame to a variable:

Tr1 <- read.xls( rfile, colNames = TRUE, sheet = 1,

                     type = "data.frame", from = 1 )

then

mean(Tr1$x)

or

with(Tr1, mean(x))

or

attach(Tr1)
mean(x)

Did you study the "An Introduction to R" manual that ships with the software?

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Oct 26 06:11:48 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 Wed 25 Oct 2006 - 20:30:44 GMT.

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