[R] Excel files
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Oct 25 22:06:28 CEST 2006
ramelan thiagarajah <ramelan3 at 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 at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list