Questions tagged [tidyverse]
ONLY use this tag if your question relates to the installation, integration with your system, or inclusion of the entire tidyverse library. DO NOT USE if your question relates to one or two components of the tidyverse, such as dplyr or ggplot2. Use *those* tags, and tag with `r` as well for a better response.
tidyverse
10,149
questions
1
vote
1
answer
24
views
pivot_longer from multiple columns into a singular names_to and two values_to
I've spent most of the day on this and finally calling in some help. There are multiple entries here on related questions, but none that quite get at what I'm trying to do.
Below is an example df.
x &...
1
vote
1
answer
49
views
Is there an elegant way to handle changing number of rows within tidyverse?
In Tidyverse there are limitations concerning the row number resulting from some data processing. Most prominent, mutate expects that the row number equals to the original data set. For example, if we ...
-2
votes
2
answers
117
views
Is there a %$% operator?
In the book R for Data Science, there is an operator %$%, as in the example code below. But when I run that code, I get the error message "there is no such operator". Can anyone help with ...
0
votes
1
answer
77
views
Order columns based of suffix condition in R
The name of my variables looks like this:
df <- data.frame(var_NA = 1:10, var = 11:20, var_Level = 21:30, var_Total = 31:40)
Except I have lots of variables. The key feature is that for every &...
0
votes
2
answers
94
views
Renaming files with r library("tidyverse”)
I'm trying to rename a bunch of files in r with library("tidyverse”).
As is: Snap-551-Image Export-01_c1_ORG.tif
The bold section is a running number, starting at 01 going to 150, each number ...
0
votes
0
answers
48
views
Convert from long to wide format in tidyverse [duplicate]
library(tidyverse)
df <- data.frame(continent = c("europe", "africa"),
region = c("north", "west", "south"),
...
0
votes
1
answer
22
views
iterate over groups with `group_walk` in original order
Using dplyr::group_walk, I would like to iterate on the original order of the dataframe.
For example:
library(dplyr)
tibble(
group = c("C", "B", "A"),
values = c(1, 2,...
0
votes
0
answers
20
views
How to change order of one variable in ggplot2 [duplicate]
I need to make a grouped bar chart:
pivot_longer(cols = c(2:5), names_to = "name", values_to = "value") %>%
ggplot(aes(x = sample_2, y = value, fill = name))+
geom_bar(...
2
votes
7
answers
110
views
How to count observations after each filter in tidyverse R?
I often apply filters in R, e.g. when selecting a particular sample or feature or excluding implausible values. Is there a fast and easy way to keep track on how many units were deleted after every ...
0
votes
0
answers
38
views
Unwrap dataframe while keeping columns from the original dataframe in R
I have R dataframe which has one column delivery_by_region which is a JSON string which when parsed returns a multiple row dataframe. I want to create a new dataframe which has all the rows from ...
0
votes
1
answer
43
views
comparing two groups in a bar plots while incorporparating lower and upper limits in R langauge
I have data frame as below:
YOM <- c(2017, 2018, 2019)
CO <- c(1159,910,931)
PM <- c(159,90,91)
upperlim <- c(1998,1302,1745)
lowerlim <- c(320,117,320)
data1 <- data.frame(YOM, ...
0
votes
1
answer
44
views
iteratively apply a function to a dataset via purrr where the function arguments are stored in a tibble
I want to iteratively apply a function (myFun) to a dataset (df) via {purrr} where the function arguments are stored in a tibble (var_question). This is a simple toy example of the use case.
library(...
2
votes
1
answer
64
views
Extract *all* possible patterns in a variable
I have a large variable containing strings (words). I need to extract all substrings that contain any of the patters listed in a separate vector.
library(tidyverse)
df <- data.frame(Word = c("...
0
votes
1
answer
55
views
Color code values conditionally in xlsx produced by openxlsx package in R in a loop
My reproducible code below writes a super small .xlsx file that has two sheets.
I was wondering if there might be a way to color-code values of 3 in red, 4 in orange, and 5 in green anywhere in the ...
0
votes
5
answers
74
views
How can I filter data frame with multiple dependent filtering criteria? [closed]
I have searched for an answer over the past two days and can't figure this out. I have tidyverse loaded but can use any solution.
I have a data frame structured like this. These are arbitrary values ...