Hello, Elahe,
you were, of course, supposed to insert my suggested
code-snippet into you code and test it therein ...
Regards -- Gerrit
-
Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eich...@m
Hello Gerit
mutate(MinValue = min(Value[Value != 0]) ) or mutate(MinValue =
sort(unique(Value))[2]) only mutates one value which is 100, it doesnt mutate
minimum Value != 0 per group by element
On Tuesday, May 11, 2021, 01:26:49 PM GMT+2, Gerrit Eichner
wrote:
Homework?
Try ma
Hello,
This can be done by getting the min of Value[Value != 0].
In the code that follows I have named the expected output df2 and
assigned the result to df3 and df4.
library(dplyr)
df3 <- df %>%
group_by(Department,Class) %>%
mutate(flag = Value != 0,
MinValue = min(Value[flag]) ) %
Homework?
Try maybe
mutate(MinValue = min(Value[Value != 0]) )
or
mutate(MinValue = sort(unique(Value))[2])
Hth -- Gerrit
-
Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eich...@math.uni-gie
Hi all,
I have the following data frame
dput(df)
structure(list(Department = c("A", "A", "A", "A", "A", "A", "A",
"A", "B", "B", "B", "B", "B", "B", "B", "B"), Class = c(1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), Value = c(0L,
100L, 800L, 800L, 0L, 300L, 1200L, 1200
5 matches
Mail list logo