hypothesis testing two samples I have two samples with different amount of element and I wonder how to do t.test in R to see if it is the same distribution between them. My teacher had on example but there the samples had the same amount of element and he took sample1 - sample2 and then check for mu=0.
How do I do it with two different lengths of the samples?
 A: If sample sizes differ, it doesn't make a difference in the R code. R counts the number of elements in each of the two data vectors and uses those for $n_1$ and $n_2$. 
Here is an
example in which I have generated two vectors of different lengths from different normal distributions. The means are different, so we expect a small P-value. I'm doing a 2-sided test.
By default R does a Welch (separate variances) test. If this were a pooled two-sample t test we would have df = 10 + 12 - 2 = 20. The output from the test below has a smaller df. If you used parameter 'var.eq=T', you would get a pooled test with df=20. 
It is a quirk of R that the sample sizes are not given in the output. this may be the source of your confusion. But you could get them in the case below with 'length(x1)' and 'length(x2)' (not shown below).
If you use the seed shown, you will get the same fake data I did. If you change (or omit) the 'set.seed' statement, you will get different data and somewhat different test results.


> set.seed(1234)
> x1 = rnorm(15, 100, 10);  x2 = rnorm(10, 115, 12)
> t.test(x1, x2)

        Welch Two Sample t-test

data:  x1 and x2 
t = -3.9081, df = 15.868, p-value = 0.001270
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval:
 -26.52207  -7.85962 
sample estimates:
mean of x mean of y 
 96.62703 113.81788 


