How to group by single column and create Python-style list strings from multiple rows and columns
I want to group the data by mcode
and create two different types of rows for each group.
How to group by single column and create Python-style list strings from multiple rows and columns
I want to group the data by mcode
and create two different types of rows for each group.
Can dplyr::mutate function modify a column’s value by the index of this column?
For example:
Projections in R dataframe
I have a R dataframe with year, growth_rate and total for one year. I want to fill missing values by discounting using the growth_rate with increase with years after and decrease for years before. For instance, if the year with value is 2018, the value for 2019 is value for 2018 multiplied by 2018 growth rate, the value for 2020 is value for 2018 multiplied by 2018 growth rate and growth_rate value for 2019. Conversely, the value for 2017, would be the value of 2018 discounted by the grotwh_rate of 2017, the value for 2016 would be the value of 2018 discounted by the grotwh_rate of 2017 and growth_rate for 2016. Below is the example dataframe with the desired column being total_projection
Non-mutually exclusive race categories into mutually exclusive categories in R using Dplyr
I was interested in recoding non-mutually exclusive race categories into mutually exclusive race categories.
Non-mutually exclusive race categories into mutually exclusive categories in R using Dplyr
I was interested in recoding non-mutually exclusive race categories into mutually exclusive race categories.
pmax (pmin) na.rm not working – Problem with NA/NaN Argument
I am dealing with a problem related to the pmax
(and the pmin
) function. I know it is used to get rowwise max (min) values. And what I wanted to get are the max and min values so to set some columns to a new range that is balanced for my analysis. The a:g is the old range and e:g is the new range that I want to use and balance out. My dataframe is not exactly the same (quite big actually), but for the sake of getting to the point, lets say the df is like this:
How can I use the across() function in dplyr to apply custom functions that return multiple columns?
I’m exploring the across() function introduced in recent versions of dplyr, and I’m trying to understand how to use it to apply a custom function that returns multiple columns. Specifically, I want to apply a function that calculates both the mean and standard deviation for selected numeric columns in my data frame and returns these as separate columns.
How to split one row of dataframe into two rows based on several conditions (R)
I have a source dataset that looks like the following:
Is there a multiple-columns-as-input version of dplyr’s “across” function?
I had to write a function today like this