Question:I have an
dataframewith a column titled ‘Normalized Month‘ for different entities. I am trying to evaluate average of the column ‘Oil_Prod‘ grouped by ‘Normalized Month’. Hence, the final dataframe should have just two columns; ‘Normalized Month’ and associated mean of oil prod for that ‘Normalized Month’ value.
Here is the code:
What I need is a dataframe with a below structure:
‘Normalized Month’ | ‘Mean’ |
3 value 3
Answer:When you use
mydf2$Oil_Prodyou are referencing the external data frame, not the one from the pipe. I think if you stop subsetting within your dplyr functions, things will work as expected:
If you have better answer, please add a comment about this, thank you!