# [R] defining number of samples

Peter Ehlers ehlers at ucalgary.ca
Mon Oct 26 08:29:23 CET 2009

```ms.com wrote:
> dear all
> i am trying to perform t-test (t.test) in R
> here i am putting the commands and answer i got
>> t.test(Ht_cm[from_treeline=='above'][type=='SD'],Ht_cm[from_treeline=='below'][type=='SD'])
>         Welch Two Sample t-test
> data:  Ht_cm[from_treeline == "above"][type == "SD"] and Ht_cm[from_treeline == "below"][type == "SD"] t = 1.4181, df = 159.203, p-value = 0.1581alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -1.547018  9.426110 sample estimates:mean of x mean of y  21.34627  17.40672
>> t.test(Ht_cm[from_treeline=='above'][type=='SPB'],Ht_cm[from_treeline=='below'][type=='SPB'])Error in t.test.default(Ht_cm[from_treeline == "above"][type == "SPB"],  :   not enough 'x' observations>
> its ok with the first command, but it says 'not enough 'x' observations', in the later case i have 31 samples.
> how can i do t.test with my day for latter case, will it work by defining the number of samples, if yes, how can i define it.
>
Does this give you a clue:

x <- 4
y <- 1:5
t.test(x,y)
#Error in t.test.default(x, y) : not enough 'x' observations

length(x)
# 1

If you don't 'get' it, try calculating the test statistic
by hand.

-Peter Ehlers

> thanking you in anticipation
>
>
> regard
> MS
> Nepal
>
> _________________________________________________________________
>
>
> 24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_pcscout:102009
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help