[R] Sandard deviation calculation

marcos carvajalino maancafe240 at gmail.com
Tue Oct 27 20:05:24 CET 2009


Hi ms.

also try this:

sd(Ht_cm[type=='SD' && from_treeline=='above'])

cause i think you can't use [][] two apply 2 conditions to a data
frame, in that cases you should use an AND (&&) conector like above

2009/10/27 marcos carvajalino <maancafe240 at gmail.com>:
> Dear ms.
>
> The most possible reason for this:
>
>>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
>
> is that you're trying to calculate sd over a vector where a NA (Not
> available) value is contained, that is, you have an empty cell, a
> different type of data or no data satisfies your condition, try:
>
>>sd(Ht_cm[type=='SD'][from_treeline=='above'],na.rm=T)
>
> That should do it...
>
> --
> Marcos Antonio Carvajalino Fernández
> Estudiante de Ingeniería Ambiental y Sanitaria
> Universidad del Magdalena, Colombia
>



-- 
Marcos Antonio Carvajalino Fernández
Estudiante de Ingeniería Ambiental y Sanitaria
Universidad del Magdalena, Colombia




More information about the R-help mailing list