Skip to content

Very basic statistics in R

10 messages · S Ellison, Jeff Newmiller, Xavier Prudent +6 more

#
1. Use R's help system to look up 'standard deviation' and 'mean'
e.g.:
??'standard deviation' 
??'mean'

For the other two questions, consult your basic stats textbook; the answers can be calculated from the two above together with the number of observations.

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
#
I recommend you read the Introduction to R document that comes with R. Look for making vectors with the c() function, and using the mean() and sd() functions. 

Note that this is not a homework help forum (read the Posting Guide mentioned at the bottom of every message). If this is not homework, you are going to need to do quite a bit of self study before you can ask questions clearly enough to get useful responses on this list. See

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Xavier Prudent <prudentxavier at gmail.com> wrote:

            
2 days later
#
Dear Xavier,

Jeffs answer was to point out two things to you:
1: How to find these functions on your own.
2: These functions are definitely available in R

Good luck,
Marius
On Mon, 6 May 2013, Xavier Prudent wrote:

            
#
Hi,
?set.seed(15)
?vec1<- sample(1:15,10,replace=TRUE)
?mean(vec1)
#[1] 10
?sd(vec1)
#[1] 4.346135
?stErr<- sd(vec1)/sqrt(length(vec1))
?stErr
#[1] 1.374369
library(plotrix)
?std.error(vec1)
#[1] 1.374369
A.K.




----- Original Message -----
From: Xavier Prudent <prudentxavier at gmail.com>
To: S Ellison <S.Ellison at lgcgroup.com>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Monday, May 6, 2013 3:05 AM
Subject: Re: [R] Very basic statistics in R

Dear Jeff,
Thanks for your fast answer,
I could for sure implement the 2-lines code to calculate the uncertainties,
but I am astonished that a widespread statistics package like R does not
include these very basic quantities.
Regards,
Xavier


2013/5/3 S Ellison <S.Ellison at lgcgroup.com>

  
    
2 days later
#
On 5/6/2013 7:02 AM, arun wrote:
stErr<- sd(vec1)/sqrt(length(vec1))

Or possibly,

  stErr<- sd(vec1)/sqrt(!is.na(vec1))
#
On May 8, 2013, at 20:38 , Robert Baer wrote:

            
You probably intended sqrt(sum(!is.na(...))).
#
Hello,

Or, to make it complete, use the na.rm argument.

sd(vec1, na.rm = TRUE)/sqrt(sum(!is.na(vec1)))

Rui Barradas

Em 08-05-2013 20:55, peter dalgaard escreveu:
#
On May 8, 2013, at 12:55 PM, peter dalgaard wrote:

            
And if 'vec1' has NA's in it, he would also need:  sd(vec1, na.rm=TRUE)