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 is an R package that installs a number of other packages for data processing and graphics.

Unless your question is about the entirety of the tidyverse package, its installation or its integration with your system, use tags for the packages you are actually using. Using library(tidyverse) is rarely a minimal reproducible example when only library(dplyr) is required.

See https://www.tidyverse.org/packages/ for a breakdown of the packages contained in tidyverse and their respective functions.

Repositories

Resources

Vignettes

Related tags

9739 questions
2
votes
4 answers

Programmatically rename dataframe columns using abbreviations derived from labels

I have a labelled dataframe with arbitrary column names, and I would like to rename the columns in a non-arbitrary way using the labels. Here is a simplified version of the dataframe: library(labelled) library(tidyverse) df <- tibble(id = "a", B101…
nicholas
  • 903
  • 2
  • 12
2
votes
4 answers

Fill cells dataframe based on multiple conditions

How to fill cells based on multiple conditions? There are a lot of players (columns) in this game, but I only included 2 for the sake of this example. I want to loop over a lot of players. Every row represents a game round. Conditions: IF…
2
votes
2 answers

Find differences in character column in R

I have a dataframe with ICPM codes before and after recoding of an operation. df1 <- tibble::tribble(~ops, ~opsalt, "8-915, 5-847.32", "5-847.32, 5-852.f3, 8-915", "8-915, 5-781.30, 8-919, 5-807.4, 5-800.c1, 5-79b.81", "5-79b.81, 5-800.c1,…
Peter Hahn
  • 148
  • 8
2
votes
2 answers

Conditional values using if else within shiny app using tidyverse and dplyr to group and filter a dataset

I have a simple shiny that presents descriptive statistics using reactive. However, I would like to use ifelse within tidyverse pipe (and not writing tons of codes). However, I´m not being able to do that. I checked previous post but it´s not…
Luis
  • 1,388
  • 10
  • 30
2
votes
2 answers

How to show Tukey groups using tidyverse and rstatix?

After a Tukey test using rstatix, I would like to add another column to the data frame with the Tukey groups. library(tidyverse) library(rstatix) ggplot(data = iris, aes(x = Species, y = Petal.Length)) + geom_boxplot() Tukey <-…
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38
2
votes
1 answer

More extensive summary with group_by

I have a dataset containing COVID-19 patients with vaccination status and whether they're dead or alive. ID <- c(1:20) Group <- c("1. vacc + unvacc", "2. vacc", "3. vacc", "1. vacc + unvacc", "2. vacc", "3. vacc", "1. vacc + unvacc", "2. vacc", "3.…
Nick Meier
  • 33
  • 4
2
votes
2 answers

How can I install tidyverse on Archlinux?

I'm running since a few days archlinux and installed R-Studio today. I'm not able to install the tidyverse packages. Error in library(tidyverse) : there is no package called ‘tidyverse’ Calls: .First -> library Execution halted Warning in…
alex
  • 89
  • 7
2
votes
3 answers

Build list of all values in group and apply to entire group

I have a dataframe like the below: x <- tibble(id = c(1,1,1,2,2,2), val = c(1,3,5,7,9,11) ) I would like to group_by each id, then apply a list/vector of all the vals in each group to every member of that group. The result…
Adam_G
  • 7,337
  • 20
  • 86
  • 148
2
votes
3 answers

convert partitioning folder columns to variables

I want to convert data frame like this: mre <- tibble::tribble( ~folder3, ~folder2, ~folder1, "V3=4", "V2=1", "V1=0", "V3=5", "V2=1", "V1=0", "V3=4", "V2=2", "V1=0", "V3=5", "V2=2", "V1=0", "V3=4", "V2=1", …
Dong
  • 481
  • 4
  • 15
2
votes
1 answer

Merging part of data frame into another data frame while preserving previous data

I have a data frame that looks like this: > data Lake_name Lake_name_percent surface_area percent2 Lake_name_percent2 prev.surface_area percent3 X 1 AlanHenry AlanHenry0.705 2109.350 0.705 AlanHenry0.708 2116.203 …
David Smith
  • 305
  • 1
  • 8
2
votes
4 answers

how to capture logic from case_when in dplyr

I am using case_when() from dplyr to create the following column, result. z <- tibble(a = c(40, 30, NA), b = c(NA, 20, 10)) z %>% mutate(result = case_when( !is.na(a) ~ a, is.na(a) &…
mdb_ftl
  • 423
  • 2
  • 14
2
votes
2 answers

How remove rows with same value in their relation but different ID in two columns in R

I have a huge data set with repeated information in a variable when this relation is understood in sense ID1, ID2 or ID2, ID1 (those in different columns), also values in the variable can be repeated from different IDs relations. I want to delete…
2
votes
1 answer

Create a variable to count the number of unique values in each row for a subset of columns

I'd like to create a variable to count the number of unique values in each row for a subset of columns (i.e.,baseline,wave1,wave2,wave3). So far I have the below. I have included an example data set with a variable "example" to show what I am after.…
Aepkr
  • 101
  • 8
2
votes
1 answer

Mutate a new columns based positive and negative consistency of two columns

I am trying to add a new column result in my dataframe df1, as specific columns (value1 and value2 columns) met the following conditions: Both of them row-wisely are positive, negative or 0, or one of them is 0 and another is either negative or…
ah bon
  • 9,293
  • 12
  • 65
  • 148
2
votes
1 answer

Filter rows by conditions including equal and get maximum values using R

Say I have a dataframe df as follows: df <- structure(list(date = c("2021-10-1", "2021-10-2", "2021-10-3", "2021-10-4", "2021-10-5", "2021-10-6", "2021-10-7", "2021-10-8", "2021-10-9"), value = c(190.3, 174.9, 163.2, 168.4, 168.6, 168.2, 163.5,…
ah bon
  • 9,293
  • 12
  • 65
  • 148