Hello,
I recently started to explore dyplr and its many functions.
I used the "summarize()" command to come up with the following data frame:
In a next step I would like to do the following:
1: Identify for each "Genotype" the maximun and the minimun "Mean_PG" value (e.g. this would be 6.47 and 5.22 for Genotype A)
2: Substract the minimum from the maximum value, do this for each genotype (e.g. for A 6.47-5.22, for B 5.96-4.11 ....)
3: create a new data frame including the Genotype columns as well as the results obtained under step 2.
Can someone help me to figure out how I could do that with dyplr? Thanks a lot!
Mike
pass your existing summary data frame to dplyr::group_by and set Genotype as the only group
simply use mutate to create a min column and a max column , min and max are base functions that work comfortably with dplyr.
you can add another entry to your mutate to hold the difference, simply use the minus symbol to subtract one column from the other.
As its all been done on one frame you never lost your other columns so no need to add them back.
good luck.
If you require more specific help then it would be good of you to provide a reprex (for example by dput() some portion of your summary data that you wish to begin transforming further).