That's how my data looks like:
> dput(data)
structure(list(Name = c("Mark", "Tere", "Marcus", "Heidi", "Georg",
"Tieme", "Joan", "Tytus", "Mark", "Tere", "Marcus", "Heidi",
"Georg", "Tieme", "Joan", "Tytus", "Mark", "Tere", "Marcus",
"Heidi", "Georg", "Tieme", "Joan", "Tytus", "Mark", "Tere", "Marcus",
"Heidi", "Georg", "Tieme", "Joan", "Tytus", "Mark", "Tere", "Marcus",
"Heidi", "Georg", "Tieme", "Joan", "Tytus", "Mark", "Tere", "Marcus",
"Heidi", "Georg", "Tieme", "Joan", "Tytus"), position = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("n",
"w"), class = "factor"), time = c(0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2), type = c(5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3), value = structure(c(0.314543267094949, 3.19693140536703,
0.930679293700748, 0.344465436879545, 1.12925174828143, 0.295226529240608,
0.534869402647018, 0.699742971466516, 0.899450918860775, 1.69467910557034,
0.105376912280917, 2.49469271475885, 0.0343013256788254, 0.469440043556817,
0.917351596015406, 1.46852763733807, 0.967872510622156, 0.354032471310347,
1.52519534333589, 1.04999953913746, 1.90298544048312, 0.265492846723646,
1.19947244036467, 2.54636084834549, 0.401142360642552, 0.190538682818794,
1.55882554492893, 1.27338900133492, 0.298795571085066, 1.73941845252159,
0.133721855003387, 0.115250693634152, 1.12742130434271, 1.50438847943189,
0.0286978152580559, 0.740798383999788, 0.838944700504553, 0.726393882538543,
1.79097043714466, 0.214124974329025, 1.46675111903789, 0.0172332774632657,
2.89433199895506, 3.07798819227104, 0.826817313167167, 0.72394085004025,
0.083957624156028, 1.07571752737732), .Dim = c(48L, 1L))), .Names = c("Name",
"position", "time", "type", "value"), row.names = c(NA, 48L), class = "data.frame")
I would like to perform t-test of value
in specific rows. How to find the rows for which t-test will be performed:
1. Name
has to be the same.
2. Type
has to be the same.
3. Time
= 0
is always a reference so t-test should be calculated between time
= 1
and time
= 0
, time
= 2
and time
= 0
, and so on. That's an example data so I can't tell you how many time
is in real data but 0 is always a reference.
4. Output (results of t-test) can be stored in additional column and in the row with specified time
.
5. Number of Names
and Times
I do not know. The data contains thousands of rows.
6. I believe that the loop is the only solution and anyway it is my desired code. Of course additional solution without the loop is more than welcome.
It's a bit of programming so I am going to start a bounty to reward someone who will put some effort on that.