Hi: If I understood you correctly, the following may work:
# Utility function to compute all pairwise differences of a vector: # The upper triangle subtracts x_i - x_j for j > i; if you want it the # other way around, use lower.tri() instead of upper.tri(). # Coercion to vector means that the differences from x_1 appear # first, followed by those from x_2, then x_3, etc. subtfun <- function(x) { u <- outer(x, x, '-') as.vector(u[upper.tri(u)]) } # To apply it to each of A, B, C in each Thesis:Day subgroup, # here's one way with function ddply() in the plyr package: library(plyr) v <- ddply(df, .(Thesis, Day), numcolwise(subtfun)) head(v) HTH, Dennis On Fri, Jan 14, 2011 at 1:17 AM, romzero <romz...@yahoo.it> wrote: > > Hi, i have that table > > > > Thesis Day A B C > 1 0 83.43 90.15 22.97 > 1 0 85.50 94.97 16.62 > 1 0 83.36 95.38 20.70 > 1 0 84.47 92.16 23.58 > 1 0 83.98 95.33 19.39 > 1 0 82.86 93.78 24.55 > 1 0 83.39 92.67 19.56 > 1 0 85.17 95.24 17.95 > 1 0 81.62 93.32 28.49 > 1 0 82.99 92.85 19.73 > 1 0 81.11 95.67 27.20 > 1 0 83.39 94.69 16.51 > 1 0 79.56 89.87 30.39 > 1 0 80.54 93.32 21.76 > 1 0 82.11 92.58 22.17 > 1 14 85.65 94.00 19.19 > 1 14 85.06 92.44 20.44 > 1 14 83.97 91.39 24.38 > 1 14 84.61 91.97 19.44 > 1 14 85.13 90.59 25.30 > 1 14 84.81 91.01 19.80 > 1 14 84.52 94.06 18.77 > 1 14 84.30 94.49 24.90 > 1 14 84.74 91.32 20.35 > 1 14 84.08 94.12 22.96 > 1 14 84.50 94.25 19.95 > 1 14 84.02 94.74 20.35 > 1 14 85.30 92.82 21.12 > 1 14 85.08 91.14 24.16 > 1 14 85.21 95.69 18.17 > etc etc etc etc etc > 2 0 83.43 90.15 22.97 > 2 0 85.50 94.97 16.62 > 2 0 83.36 95.38 20.70 > 2 0 84.47 92.16 23.58 > 2 0 83.98 95.33 19.39 > 2 0 82.86 93.78 24.55 > 2 0 83.39 92.67 19.56 > 2 0 85.17 95.24 17.95 > 2 0 81.62 93.32 28.49 > 2 0 82.99 92.85 19.73 > 2 0 81.11 95.67 27.20 > 2 0 83.39 94.69 16.51 > 2 0 79.56 89.87 30.39 > 2 0 80.54 93.32 21.76 > 2 0 82.11 92.58 22.17 > 2 14 84.48 91.23 20.44 > 2 14 85.22 93.08 22.54 > 2 14 83.89 92.74 25.11 > etc etc etc etc etc > > I need to subtract from every number the other numbers of the same thesis > and same day. > > Example: > A(row1) - A (row2) (same for B and C) > A(row1) - A (row3) > etc until the last Thesis 1 and Day 0 > A(row2) - A (row3) > etc etc until the last Thesis 1 and Day 0 > > Same for the others theses and days. > > How can i do that? > > Sorry for my english. > -- > View this message in context: > http://r.789695.n4.nabble.com/test-tp3217329p3217329.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.