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

How do you find the lifecycle status of a tidyverse function or argument?

What's the correct way to work out the lifecycle stage of tidyverse functions? (that is, whether the function/argument is considered stable, experimental, deprecated, or superseded) What I know so far I guess that the documentation will tell us,…
stevec
  • 41,291
  • 27
  • 223
  • 311
8
votes
1 answer

Why does my code using read_fwf() not work like in the book?

I study R with R Cookbook 2nd edition. in 4.6 Reading Fixed-Width Records, I typed code as written in book. but my code doesn't work like book Fisher R.A. 1890 1962 Pearson Karl 1857 1936 Cox Gertrude 1900 1978 Yates Frank …
8
votes
1 answer

Printing gt table inside a loop with rmarkdown::render not working

I am programming a report generator that export html. I use two files, the first is a loop that will determine the number of reports and within my .Rmd template I have another loop to print several tables. The .Rmd below, works fine --- title:…
jcarlos
  • 425
  • 7
  • 17
8
votes
4 answers

Can you use dplyr across() to iterate across pairs of columns?

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 there a way to apply across() to pairs of columns? Tiny…
nefosl
  • 366
  • 1
  • 8
8
votes
1 answer

Round corners in ggplots geom_tile possible?

is it possible to make rounded corners for the tiles in the geom_tile layer on ggplot2? Example w/ standard edges: df <- data.frame( x = rep(seq(2, 15, 6.5), 2), y = c(rep(6.5, 3), rep(2,3)), h = rep(4.25, 6), w = rep(6.25, 6), …
8
votes
2 answers

R: Group Similar Addresses Together

I have a 400,000 row file with manually entered addresses which need to be geocoded. There's a lot of different variations of the same addresses in the file, so it seems wasteful to be using API calls for the same address multiple times. To cut down…
rsylatian
  • 429
  • 2
  • 14
8
votes
4 answers

Standardize variables using dplyr [r]

I would like to standardize variables in R. I know about multiple approahces how this can be done. However, I realy like using this approach bellow: library(tidyverse) df <- mtcars df %>% gather() %>% group_by(key) %>% mutate(value =…
Petr
  • 1,606
  • 2
  • 14
  • 39
8
votes
1 answer

Using pivot_longer with multiple paired columns in the wide dataset

I have a dataset that looks like this: input <- data.frame( event = 1:2, url_1 = c("g1", "g3"), name_1 = c("dc", "nyc"), url_2 = c("g2", "g4"), name_2 = c("sf", "la")) Essentially there are pairs of indexed columns that are…
lethalSinger
  • 606
  • 3
  • 9
8
votes
2 answers

R install.packages returns 'ERROR: failed to lock directory'

[Similar question to 14382209 but suggestions there haven't solved this issue] New installation of R 4.0.0 and tidyverse on a Windows 7 work computer returns this classic failed to create lock directory error install.packages('tidyverse') WARNING:…
Brent
  • 425
  • 1
  • 3
  • 10
8
votes
1 answer

tidyselect changes how to refer an external vector of variable names in selecting functions in R

I have started to recieve a warning when using selecting functions within tidyverse packages. Example: library(dplyr) set.seed(123) df = data.frame( "id" = c(rep("G1", 3), rep("G2", 4), rep("G3", 3)), "total" = sample.int(n = 10), "C1" =…
alvaropr
  • 699
  • 9
  • 20
8
votes
2 answers

how to filter, then pipe and use sum function?

For Example the following will not work: data(mpg) filter(mpg, manufacturer =="audi") %>% sum(.$cty) However the following will work: data(mpg) x <- filter(mpg, manufacturer =="audi") sum(x$cty) I would like to get it all to work in a…
Angel Cloudwalker
  • 2,015
  • 5
  • 32
  • 54
8
votes
1 answer

why does rbind() work and bind_rows() not work in combining these sf objects?

I've got some sf objects I want to combine. I've stripped them down to a single polygon each (rtmp and rtmp2) for the purposes of this question. rbind() and do.call(rbind,...) seem to work fine, but bind_rows() doesn't. Obviously I can work around…
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
8
votes
1 answer

Bootstrapping by multiple groups in the tidyverse: rsample vs. broom

In this SO Question bootstrapping by several groups and subgroups seemed to be easy using the broom::bootstrap function specifying the by_group argument with TRUE. My desired output is a nested tibble with n rows where the data column contains the…
TimTeaFan
  • 17,549
  • 4
  • 18
  • 39
8
votes
4 answers

Replace part of string with mutate (in a pipe)

I would like to replace a part of a string (between the first 2 underscores, the first group always being "i") like in the base R example below: library(dplyr) library(stringr) d <- tibble(txt = c("i_0000_GES", "i_0000_OISO", "i_0000_ASE1333"), …
r.user.05apr
  • 5,356
  • 3
  • 22
  • 39
8
votes
5 answers

How to duplicate last row by group (ID)?

I have a data.frame of surfaces touched over time. I would like to simply append a duplicate of the last row for each AcvitivityID: head(movsdf.rbind) ActivityID CareType HCWType Orientation Surface Date Time Dev.Date.Time…
HCAI
  • 2,213
  • 8
  • 33
  • 65