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

Tabulizer package in R: how to scrape tables after specific Title

How to scrape tables preceded with some title text from PDF? I am experimenting with tabulizer package. Here an example of getting a table from a specific page (Polish "Map of Public Health…
Jacek Kotowski
  • 620
  • 16
  • 49
6
votes
3 answers

Select all rows which are duplicates except for one column

I want to find rows in a dataset where the values in all columns, except for one, match. After much messing around trying unsuccessfully to get duplicated() to return all instances of the duplicate rows (not just the first instance), I figured out a…
Paul Raftery
  • 223
  • 2
  • 6
6
votes
3 answers

How can I use accumulate like reduce2 function in purrr?

I would like to use the accumulate function with two input vectors and the reduce2 function. The documentation for accumulate implies that two input vectors can be given and that accumulate can work with reduce2. However, I am having trouble. Here…
Steve
  • 135
  • 1
  • 6
6
votes
2 answers

tidyr: using mutate inside a function

I'd like to use mutate function from the tidyverse to create a new column based on the old column using only a data frame and strings, which represent column headers, as inputs. I can get this to work without using the tidyverse (see function f…
Tyler Law
  • 73
  • 4
6
votes
2 answers

How to pass by argument to dplyr join function within a function?

I would like to pass an unquoted variable name x to a left_join function. The output I expect is the same as if I ran: left_join(mtcars, mtcars, by = c('mpg' = 'mpg')) I'm trying this: ff <- function(x) { x <- enquo(x) left_join(mtcars,…
Dambo
  • 3,318
  • 5
  • 30
  • 79
6
votes
2 answers

dplyr::filter "No tidyselect variables were registered"

I am trying to filter specific rows of my tibble using the dplyr::filter() function. Here is part of my tibble head(raw.tb): A tibble: 738 x 4 geno ind X Y 1 san1w16 A1 467 383 2 san1w16 A1 …
Al3xEP
  • 328
  • 2
  • 9
6
votes
1 answer

Purrr::map_df() drops NULL rows

When using purrr::map_df(), I will occasionally pass in a list of data frames where some items are NULL. When I do, map_df() returns a data frame with fewer rows than the the original list. I assume what's going on is that map_df() calls…
crazybilly
  • 2,992
  • 1
  • 16
  • 42
6
votes
2 answers

Vectorised time zone conversion with lubridate

I have a data frame with a column of date-time strings: library(tidyverse) library(lubridate) testdf = data_frame( mytz = c('Australia/Sydney', 'Australia/Adelaide', 'Australia/Perth'), mydt = c('2018-01-17T09:15:00', '2018-01-17T09:16:00',…
jimjamslam
  • 1,988
  • 1
  • 18
  • 32
6
votes
1 answer

dplyr number of rows across groups after filtering

I want the count and proportion (of all of elements) of each group in a data frame (after filtering). This code produces the desired output: library(dplyr) df <- data_frame(id = sample(letters[1:3], 100, replace = TRUE), value =…
Fridolin Linder
  • 401
  • 6
  • 12
6
votes
2 answers

transform a dataframe of frequencies to a wider format

I have a dataframe that looks like this. input dataframe position,mean_freq,reference,alternative,sample_id 1,0.002,A,C,name1 2,0.04,G,T,name1 3,0.03,A,C,name2 These data are nucleotide differences at a given position in a hypothetical genome,…
eastafri
  • 2,186
  • 2
  • 23
  • 34
6
votes
2 answers

Creating and using new variables in function in R: NSE programing error in the tidyverse

After reading and re-reading the many "programing with dplyr" guides, I still cannot find a way to solve my particular case. I understand that the use of group_by_, mutate_ and such "string-friendly" versions of tidyverse functions is heading…
Dominique Makowski
  • 1,511
  • 1
  • 13
  • 30
6
votes
2 answers

Rename multiple dataframe columns using purrr

I have the following list of data frames containing a column named cyl # Create 3 dataframes with identical column names mt_list <- list(head(mtcars[, 1:2]), tail(mtcars[, 1:2]), mtcars[13:18, 1:2]) mt_list #> [[1]] #> mpg cyl #>…
user4687531
  • 1,021
  • 15
  • 30
6
votes
1 answer

Can forcats::as_factor return an ordered factor?

Can as_factor from forcats return an ordered factor? It seems like a missing feature if not although I haven't seen it reported as an issue on the GitHub page. I have tried: y <- forcats::as_factor(c("a", "z", "g"), ordered = TRUE) is.ordered(y) #…
Danny
  • 448
  • 3
  • 15
6
votes
1 answer

n() acting inconsistently when used in summarise_at()

Using this example data: library(tidyverse) set.seed(123) df <- data_frame(X1 = rep(LETTERS[1:4], 6), X2 = sort(rep(1:6, 4)), ref = sample(1:50, 24), sampl1 = sample(1:50, 24), …
G_T
  • 1,555
  • 1
  • 18
  • 34
6
votes
1 answer

Using mutate_at() with negated select helpers e.g(not one_of())

I have data which looks like this: library(dplyr) set.seed(123) df <- data_frame(X1 = rep(LETTERS[1:4], 6), X2 = rep(1:2, 12), ref = sample(1:50, 24), sampl1 = sample(1:50, 24), …
G_T
  • 1,555
  • 1
  • 18
  • 34