I currently have a data frame labeled a:j that have numeric values. Then an 11th column that is labeled "new" where the first 50 values in column "new" are 'x' and the last 50 values are 'y'.
Here is a mini made up example of the data frame format:
a b c d e f g h i j new
1 1 1 1 1 1 1 1 1 x
2 2 2 2 2 2 2 2 2 x
3 3 3 3 3 3 3 3 3 y
4 4 4 4 4 4 4 4 4 y
I am needing to get the average from column "d's" numeric values but only in which column "new" has the value of 'x'.
Assuming that the correct code for this task must specify the column "new" and the value of 'x' (or the negation of y) somewhere in the line of code, my coding format has to be wrong. My line of code so far leaves this out and simply highlights where the 'x' in the column "new" would be found. But, in a messier data frame, I would need to be able to specify.
My line of code:
mean(x_dfs$d[1:50])