across Questions

4

Solved

This is somehow related to this question: In principle I try to understand how rowwise operations with mutate across multiple columns applying more then 1 functions like (mean(), sum(), min() etc.....
Sebrinasebum asked 1/5, 2021 at 14:34

1

Solved

I attempt to use read_csv from {readr} to read a CSV file into R. To demonstrate my real issue, I reset the argument guess_max to 5 at first (default is 1000) library(readr) formals(read_csv)$guess...
Histo asked 8/3, 2023 at 15:28

2

Solved

See code below. the mutate(across(everything(), scale, .names = "{.col}_z")) part of the syntax is generating columns with [,1]appended at the end. Two questions: Why is this happening? ...
Lerma asked 30/12, 2022 at 19:0

1

Solved

I'm wondering if there's an obvious shorthand for applying a bunch of functions across the whole dataset, that is shorthand for across(everything(), ...). Solution does not have to use dplyr. Note ...
Ferrell asked 23/11, 2022 at 20:21

4

I'm trying to automatically calculate the mean score per row for multiple groups of columns. E.g. a set of columns could represent items of different scales. The columns are also systematically nam...
Hydric asked 1/7, 2022 at 17:15

2

Solved

I want to add several columns (filled with NA) to a data.frame using dplyr. I've defined the names of the columns in a character vector. Usually, with only one new column, you can use the following...
Hair asked 5/10, 2021 at 19:39

1

Solved

When I mutate across data, the columns selected by .cols are replaced by the results of the mutation. How can I perform this operation whilst: Keeping the columns selected by .cols in the output A...
Emerson asked 16/9, 2021 at 13:57

4

Solved

I would like to: Use across and case_when to check if columns A1-A3 == 1 Concatenate the column names of the columns where A1-A3 == 1 and mutate a new column with the concatenated column names My...
Barbarous asked 30/5, 2021 at 11:5

1

I want to use the across() function in dplyr but get an error. For instance, running iris %>% group_by(Species) %>% summarise(across(starts_with("Sepal"), mean)) gives me E...
Superfuse asked 25/6, 2020 at 14:31

2

Solved

In dplyr Column-wise operations has this example: df <- tibble(x = c("a", "b"), y = c(1, 1), z = c(-1, 1)) # Find all rows where EVERY numeric variable is greater than zero d...
Portia asked 18/2, 2021 at 19:4

3

I have demographic data set, which includes the age of people in a household. This is collected via a survey and participants are allowed to refuse providing their age. The result is a data set wit...
Selfconscious asked 3/11, 2020 at 18:2

4

Solved

I have a tibble with a number of variables collected over time. A very simplified version of the tibble looks like this. df = tribble( ~id, ~varA.t1, ~varA.t2, ~varB.t1, ~varB.t2, 'row_1', 5, 10, 2...
Bauxite asked 10/4, 2021 at 3:34

1

Solved

In previous versions of dplyr, if I wanted to get row counts in addition to other summary values using summarise(), I could do something like library(tidyverse) df <- tibble( group = c("A...
Jillianjillie asked 11/2, 2021 at 19:38

3

Solved

I am having some trouble getting mutate, across, and case_when to function properly, I've recreated a simple version of my problem here: a <- c(1:10) b <- c(2:11) c <- c(3:12) test <- ...
Lerner asked 17/1, 2021 at 0:32

4

Solved

I have 18 pairs of variable and I would like to do pair-wise math on them to calculate 18 new variables. The across() function in dplyr is quite handy when applying a formula to one column. Is ther...
Predominant asked 2/1, 2021 at 20:8

0

I'm trying to use dplyr::mutate(across()) to recode specified columns in a tbl. Using these on their own works fine, but I can't get them to work in a function: library(dplyr) library(tidyr) df1 &...
Vaudeville asked 8/12, 2020 at 16:59

2

Solved

I have election results for different candidates by district. The source has the number of votes for each candidate and the total number of votes per district. I'd like to add variables for the per...
Jarvey asked 12/8, 2020 at 18:45

2

Solved

Hey i'm trying to rename some columsn by adding "Last_" with the new version of dplyr but I keep getting this error Error: `across()` must only be used inside dplyr verbs. this is my cod...
Navarre asked 3/10, 2020 at 20:26

3

Solved

I want to have a flexible function using summarize in which: the aggregation function is given by user the aggregation function might use further arguments which refer to variables within the data...
Stretto asked 11/11, 2020 at 0:28

2

Solved

I am sure the solution is a one liner, but I am banging my head against the wall. See the very short reprex at the end of the post; how do I tell dplyr that I want to double only the columns withou...
Gurgitation asked 27/10, 2020 at 13:20

2

Solved

Is there a way to mutate all numeric variables except one (in this case age) or two? data data = data.frame( Year = c(1,2,5,7,2,6,2,6), days = c(5,3,6,3,7,2,5,7), age = c(1,3,5,23,2,4,5,2), nam...
Seaway asked 8/9, 2020 at 21:24
1

© 2022 - 2025 — McMap. All rights reserved.