I am working with R.
Here I share a sample of my data...
structure(list(column_a = c("1_1", "1_1", "1_2", "1_2", "1_2",
"2_1", "2_2", "2_2", "3_1", "3_2"), column_b = c("kitchen", "tree",
"hate", "kind", "table", "dog", "human", "car", "moon", "rage"
)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame"
))
column_a column_b
1 1_1 kitchen
2 1_1 tree
3 1_2 hate
4 1_2 kind
5 1_2 table
6 2_1 dog
7 2_2 human
8 2_2 car
9 3_1 moon
10 3_2 rage
I need to calculate the mean value of the total words produced by condition (1_1, 1_2, etc.). The only problem that I have is that the conditions that finish with "_1" have a total number of 50 and the conditions that end with "_2" have a total number of 100.
So, since the condition "1_1" has two words produced (in the sample) I should calculate the mean by diving by 50. This is 2/50 = 0.04. However, when calculating the mean for the "1_2" condition I need to divide by 100. This is 3/100 = 0.03.
I need to create a column that has the mean value of the total words produced by condition, considering that some condition needs to be calculated by 50 and the other ones by a 100. How can I do this and still have the results in the same column?