Displaying 3 results from an estimated 3 matches for "df3b".
Did you mean:
d3b
2024 Oct 18
1
DPLYR Multiple Mutate Statements On Same DataFrame
...ve
to pipe a third time, the final variable is changed in the same
instruction.
Also use mutate(across(...)), mutate_at is deprecated.
And use ?case_when instead of nested ifelse's. It's much cleaner.
As you can see, the result is identical to your code's result.
library(dplyr)
df3b <- df0 %>%
mutate(
across(starts_with('P'), ~case_when(
.x == 0 ~ 0,
.x == 1 ~ 25,
.x == 2 ~ 75,
.x == 3 ~ 150,
.x == 4 ~ 350,
.x == 5 ~ 750,
.x == 6 ~ 3000,
.x == 7 ~ 7500,
.x == 8 ~ 15000,
.x == 9 ~ 30000,...
2024 Oct 17
2
DPLYR Multiple Mutate Statements On Same DataFrame
Hi R Helpers,
I have been looking for an example of how to execute different dplyr mutate statements on the same dataframe in a single step. I show how to do what I want to do by going from df0 to df1 to df2 to df3 by applying a mutate statement to each dataframe in sequence, but I would like to know if there is a way to execute this in a single step; so simply go from df0 to df1 while executing
2012 Dec 13
3
Repeat elements of matrix based on vector counts
I have two dataframes (df) that share a column header ("plot.id"). In the
1st df, "plot.id" records are repeated a variable number of times based on
the number of trees monitored within each plot. The 2nd df only has a
single record for each "plot.id", and contains a variable named "load" that
is collected at the plot-level and is only listed once per plot