[R] Odp: computing and showing mean

Petr PIKAL petr.pikal at precheza.cz
Wed Jun 11 11:54:25 CEST 2008


Hi

r-help-bounces at r-project.org napsal dne 11.06.2008 08:41:27:

> Hello to everyone,
> I am trying to compute a mean and show it to the screen and then save to 
later be used
> as a boxplot.I have used the following code:
> dat<-read.table(file="C:\\Documents and Settings\\Owner\\My 
Documents\\Yeast\

here you get data frame

> \Yeast.txt",header=T,row.names=1)
> file.show(file="C:\\Documents and Settings\\Owner\\My 
Documents\\Yeast\\Yeast.txt")
> x<-dat[2,23:46]

x is data frame consisting from row 2 and columns 23:46 of data frame dat

> y=mean(x,trim=0,na.rm=T)

y is named vector numerically the same as x (you compute mean of one 
value)

if you want to see how your objects look like just print them on your 
console by simply typing

x or y.

If you want to see internal structure do

str(x) or str(y)

> save(y,file="ydata")
> Am I computing the mean correctly and how to I show the value of the 
mean to the screen?

Maybe its time to have a small glimpse into some basic documentation like 
R-intro.

I may guess you want mean of columns 25:46. If this is true, then

colMeans(dat[, 23:46])

prints means for defined columns.
And
boxplot(dat[, 23:46])

gives you boxplots for each column.

But enough of speculation what do you really want.

Regards
Petr



> 
> 
> 
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list