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
16
votes
2 answers

What is the difference between as.tibble(), as_data_frame(), and tbl_df()?

I remember reading somewhere that as.tibble() is an alias for as_data_frame(), but I don't know what exactly an alias is in programming terminology. Is it similar to a wrapper? So I guess my question probably comes down to the difference in possible…
Chill2Macht
  • 1,182
  • 3
  • 12
  • 22
16
votes
7 answers

Is is possible to convert a dataframe object to a tribble constructor?

I have data that looks like this: library(tidyverse) df <- tibble( x = c(0, 179, 342, 467, 705, 878, 1080, 1209, 1458, 1639, 1805, 2000, 2121, 2339, 2462, 2676, 2857, 3049, 3227, 3403, 3583, 3651, 4009, 4034, 4151, 4194, 4512, 4523, 4679,…
emehex
  • 9,874
  • 10
  • 54
  • 100
15
votes
3 answers

Combining Rolling Origin Forecast Resampling and Group V-Fold Cross-Validation in rsample

I would like to use the R package rsample to generate resamples of my data. The package offers the function rolling_origin to produce resamples that keep the time series structure of the data. This means that training data (in the package called…
Richi W
  • 3,534
  • 4
  • 20
  • 39
15
votes
1 answer

Use filter() (and other dplyr functions) inside nested data frames with map()

I'm trying to use map() of purrr package to apply filter() function to the data stored in a nested data frame. "Why wouldn't you filter first, and then nest? - you might ask. That will work (and I'll show my desired outcome using such process), but…
Taraas
  • 1,268
  • 1
  • 11
  • 20
15
votes
2 answers

How to Transpose (t) in the Tidyverse Using Tidyr

Using the sample data (bottom), I want to use the code below to group and summarise the data. After this, I want to transpose, but I'm stuck on how to use tidyr to achieve this? For context, I'm attempting to recreate an existing table that was…
Mike
  • 2,017
  • 6
  • 26
  • 53
15
votes
2 answers

Filter by multiple patterns with filter() and str_detect()

I would like to filter a dataframe using filter() and str_detect() matching for multiple patterns without multiple str_detect() function calls. In the example below I would like to filter the dataframe df to show only rows containing the letters a f…
user6571411
  • 2,749
  • 4
  • 16
  • 29
15
votes
0 answers

When should we use curly brackets { } when piping with dplyr

I found out that some expressions can only be piped if inside curly brackets (braces, { }), for instance: library(dplyr) 3 %>% {3 + .} 3 %>% {ifelse(. < 2, TRUE, FALSE)} What are the rules behind the use of curly brackets when piping? When should…
mat
  • 2,412
  • 5
  • 31
  • 69
15
votes
3 answers

Using standard evaluation and do_ to run simulations on a grid of parameters without do.call

Goals I want to use dplyr to run simulations on grids of parameters. Specifically, I'd like a function that I can use in another program that gets passed a data.frame for every row calculates some simulation using each column as an argument also is…
jaimedash
  • 2,683
  • 17
  • 30
14
votes
2 answers

Why does !! (bang-bang) combined with as.name() give a different output compared to !! or as.name() alone?

I use a dynamic variable (eg. ID) as a way to reference a column name that will change depending on which gene I am processing at the time. I then use case_when within mutate to create a new column that will have values that depend on the dynamic…
Yuka Takemon
  • 320
  • 1
  • 11
14
votes
4 answers

Error installing tidyr on Ubuntu 18.04 & R 4.0.2

In trying to install the package tidyverse, I get errors in the installation of dependency tidyr. Here is the tail of the message I get: cpp11.cpp:31:100: error: ‘unmove’ is not a member of ‘cpp11’ return…
msoftrain
  • 1,017
  • 8
  • 23
14
votes
1 answer

R ggrides package drawing mean line (NOT MEDIAN)

I'd like to draw a line through my rideplots for the mean. The built-in quantile arguments draw a line in the style I want, but at the median. How can I draw one at the mean, preferably without using geom_vline() or pluck at the ggplot build object…
Laserhedvig
  • 381
  • 2
  • 13
14
votes
5 answers

tidyverse not loaded, it says "namespace ‘vctrs’ 0.2.0 is already loaded, but >= 0.2.1 is required"

strong textI keep encountering problems with installing tidyverse package, which preventing me from implementing many text processing tasks. The problem is the same as those mentioned in many previous threads since 2017 in that when I enter…
Chris T.
  • 1,699
  • 7
  • 23
  • 45
14
votes
2 answers

R Googlsheets: Unable to use `gs_auth()` in googlesheets package - Sign In With Google Temporarily Disabled App Not Verified Issue

I am unable to authenticate my googlesheets package. Everytime I run the gs_auth() command I am taken to the chrome where I would usually login to enable the package to access my googlesheets: However, lately every time I do this I have the…
14
votes
1 answer

Evaluation Error when tidyverse is loaded after Hmisc

I am using r 3.3.3, dplyr 0.7.4, and Hmisc 4.1-1. I noticed that the order I load packages effects whether or not a dplyr::summaries function wold work or not. I understand that loading packages in a different order would mask certain functions but…
Mike
  • 3,797
  • 1
  • 11
  • 30
14
votes
1 answer

ggplot using grouped date variables (such as year_month)

I feel like this should be an easy task for ggplot, tidyverse, lubridate, but I cannot seem to find an elegant solution. GOAL: Create a bar graph of my data aggregated/summarized/grouped_by year and month.…
Jeff Parker
  • 1,809
  • 1
  • 18
  • 28