[R] Calculating the mean in one column with empty cells

William Dunlap wdunlap at tibco.com
Fri Oct 5 16:49:25 CEST 2012


You need to show us the verbatim output of the following R command
  dput(dataSet2$ac_bhar_60d_4d_after_ann[2:10])
to make any further progress.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of fxen3k
> Sent: Friday, October 05, 2012 6:15 AM
> To: r-help at r-project.org
> Subject: Re: [R] Calculating the mean in one column with empty cells
> 
> I'm sorry!
> 
> Now I tried it again with just 10 numbers (just random numbers) and Excel
> gives a different output than R.
> 
> Here are the numbers I used:
> 
> 0,2006160108532920
> 0,1321167173880490
> 0,0563941428921262
> 0,0264198664609803
> 0,0200581303857603
> -0,2971754213679500
> -0,2353086361784190
> 0,0667195538296534
> 0,1755852636926560
> 
> And this is the command in R:
> 
> > nums <- as.numeric(as.character(dataSet2$ac_bhar_60d_4d_after_ann[2:10]))
> > m <- mean(nums, na.rm = T)
> > m
> 
> The output of R is:
> > print(m, digits= 12)
> [1] 0.0166666666667
> 
> The output in Excel is:
> 0,0161584031062386
> 
> The numbers are imported correctly. Or does R reduce the imported numbers to
> any decimal place? (i don't think so ;-) )
> 
> Best Regards,
> Felix
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Calculating-the-mean-in-
> one-column-with-empty-cells-tp4645135p4645165.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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