I am currently working with a large dataframe which consists of rougly 20 columns and a lot of rows.
Simplified it can look like this:
letter = c("A", "A", "A", "B", "B", "B", "C", "C", "C", "C", "A", "A", "A", "B", "B", "B", "C")
number = c(1,2,3,1,2,1,2,3,2,1,2,3,2,2,3,2,1)\
value1 = c(1:17)
value2 = seq(18, 50, 2)
df = data.frame(letter, number, value1, value2)
I would like to do some calculations on specific sets of values. These are the unique combinations of letter and number. So all values who have the letter A and number 1 can be summed, counted (or count_not_zero), taken minimum, or other (more elaborate) calculations. My goal is to make a new data frame with these unique combinations and their calculations.
letter number value1.sum value1.count .. value2.max value2.elaborate
A 1 1 1 .. 18 0.56
A 2 26 3 .. 42 0.40
A 3 15 2 .. 40 0.44
B 1 .. .. .. .. ..
.. .. .. .. .. .. ..
C 2 16 2 .. 34 0.44
C 3 8 1 .. 32 0.50
I tried doing this in several ways. For example making a list of matrices with the letter A (in this case), and then using aggregate while selecting on the individual letters. However this gets awfully big.
I tried several combinations of DPLYR package but it was difficult to do different kind of calculations, especially selfmade ones.