Hello all,
I'm new to Rstudio and the community. I've been learning coding watching YouTube videos, and for the most part I can figure out most of my needs. Being said that, I'm having a hard time trying to find a way of subtracting the 10th value upstream of the max value for a series.
In summary I have a line ROI across a cell junction. I'm measuring intensity perpendicular to the junction so the values look like a bell shape (see attached picture). these values range from 0-3 um and my max intensity lies ~ 1.5 um but it is not always perfect, can try slightly between junctions.
I'm interested in coding to have a summarized dataframe (dataframe2) extracting max intensity value for each ROI and a new value "x" that represents: "max value - the 10th value up from the max value" (each data point spans almost 1/10th of a micron so it will be around the .5um mark in the x axis, or 1um from the max intensity point).
so far I've wrote this:
dataframe2 <- dataframe %>%
ddply((EXP ~ ROI ~ MUT), summarize,
max_intensity = max(Value),
x= ((max(Value) - first(Value)))
which was a nice work around given that the first value is position 15th up from the max intensity (roughly). But I want to be more precise with my math so I want to be exactly 1 um from the max intensity.
I know there should be an easy way to index for the 10th cell up from the max. I tried which.max(Value)-10 but didnt work.
x=((max(Value) - (which.max(Value)-10)). *and it didnt work
Thanks in advance, any suggestions are welcomed thanks