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.....
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?
...
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 ...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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 <- ...
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...
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 &...
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...
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...
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...
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...
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...
1
© 2022 - 2025 — McMap. All rights reserved.