Dear MS,

please follow the posting guide and provide reproducible lines of code !
Like this I have no idea what's inside your Ht_cm object .

Maybe the problem is that your data might contain NAs, since the basic formula doesn't allow missing values. In this case you have to specify how the function sd() should react. Would you consider removing all elements that are missing as correct ? In order to justify this you should know what your data represent and how much potential bias you're introducing ... Of course the sd() command can't replace your understand of the subjects you're studying ..

To illustrate this point :

> dat1 <- matrix(c(5,1:5,2,NA),nc=2)

> dat1
    [,1] [,2]
[1,]    5    4
[2,]    1    5
[3,]    2    2
[4,]    3   NA

> sd(dat1[,1])
[1] 1.707825

> sd(dat1[,2])
[1] NA

## here I understand the nature of a missing element and judge
##   that omitting missing element is acceptable in my study :
> sd(dat1[,2],na.rm=T) [1] 1.527525

> sessionInfo()
R version 2.9.1 (2009-06-26)
i386-pc-mingw32


Hope this helps,
Wolfgang

ms.com a écrit :
Dear all
I am trying to learn R
I was trying to calculate standard deviation here are the commands and outputs in R
sd(Ht_cm[type=='SD'])[1] 3.283605> sd(Ht_cm[from_treeline=='above'])[1] 16.83289> sd(Ht_cm[type=='SD'][from_treeline=='above'])[1] NA>

the problem is that, i could not understand why the third command could not give any result. please help me out thanking you
Regard
MS
Nepal _________________________________________________________________
[[elided Hotmail spam]]

D24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_myidea:102009
        [[alternative HTML version deleted]]

______________________________________________
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.




. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
CNRS UMR7104, IGBMC, 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France
Tel (+33) 388 65 3300         Fax (+33) 388 65 3276
wolfgang.raffelsber...@igbmc.fr

______________________________________________
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.

Reply via email to