If the numbers were imported correctly you wouldn't need to do as.numeric(as.character(yourdata)).
Please use dput() to provide your data, as in: dput(dataSet2$ac_bhar_60d_4d_after_ann[2:10]) Otherwise it's impossible for us to diagnose your problem or reproduce your error. testdata <- c(0.2006160108532920, 0.1321167173880490, 0.0563941428921262, 0.0264198664609803, 0.0200581303857603, -0.2971754213679500, -0.2353086361784190, 0.0667195538296534, 0.1755852636926560) > mean(testdata) [1] 0.0161584 Sarah On Fri, Oct 5, 2012 at 9:14 AM, fxen3k <f.seha...@gmail.com> wrote: > 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 > > > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ R-help@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.