I have a dataframe with some price values. No I want to have one or in best case two data frames with the max and min values for each article without 0 values.
I tried it this way with DT (For maxValue everything works perfect):
minValue <- setDT(df)[, .SD[which.min(price > 0)], by=number]
maxValue <- setDT(df)[, .SD[which.max(price)], by=number]
But the minValue Df shows 0 Values. I have also tried it with:
do.call(rbind, tapply(df$price, df$number, FUN = function(x) c(max = max(x), min = min(x))))
But here I dont know how to use the > 0 condition.
In the best case I would like to have to dfs maxvalue and minvalue for each product.