I have a data frame which looks like this:
highopen_percent_change <- c(0.285, -2.156, 0.030, -0.184, -0.005, 0,092, -0.092, 0, -0.0563, -0.020, -0.174, -0.492, 0.201, -0.005)
IDcombinatie_nr <- c(47, 41, 42, 45, 41, 42, 48, 32, 44, 48, 32, 48, 32, 48, 28, 12, 32)
df <- data.frame(highopen_percent_change, IDcombinatie_nr)
In this data frame I want to know the smallest positive and negative value of highopen_percent_change
per IDcombinatie_nr
. So per IDcombinatie_nr
I want to know what the smallest positive and negative highopen_percent_change
values are. This value should not be zero, since some values of highopen_percent_change
are zero in my data frame.
So, this is what I want:
For 47 the lowest positive value is 0.05 and the lowest negative value is -0.1.
For 41 the lowest positive value is 0.02 and the lowest negative value is -0.4.
For 42 the lowest positive value is 0.3 and the lowest negative value is -0.2.
I hope you can help me.