I want to do a two-sample t.test comparing values from two regions for several groups. I know it must be a simple trick, but I couldn't find an answer so far.
This is a short version of my table. Several species each from 2 regions (There are generally 6 specimens per species available for each region).
species region N15
ARGAFF EQ 9.85
ARGAFF EQ 10.42
ARGAFF EQ 10.43
ARGAFF OMZ 10.28
ARGAFF OMZ 10.30
ARGAFF OMZ 10.41
BATABY EQ 10.57
BATABY EQ 10.60
BATABY EQ 10.68
BATABY OMZ 9.21
BATABY OMZ 9.29
BATABY OMZ 9.67
I tried
spp<-split(SIA,species,drop=FALSE)
followed by
lapply(spp,function (x) t.test(N15~region))
I further tried
by(SIA[,3], SIA[, "species"], function (x) t.test(N15~region))
but both versions compute the test for all values (N.138, not just for individual species (N:12).
On the other hand
by(SIA[,3], SIA[, "species"], t.test)
results in a one-sample test but for individual species.
I'd appreciate advice.