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
1 answer

ggplot2 Set geom_point Size according to a Factor

I am trying to set the size of geom_point according to a factor. I know it is not advised, but my data is extremely unbalanced (the minimum value is 6 while the maximum is larger than 10,000). I am trying to make the size of the points reflect the…
Judy Zhang
  • 23
  • 3
2
votes
1 answer

R: use mice mipo/data.frame object with sjPlot tab_model

I'm trying to get a table output for a pooled logistic model with imputed datasets from mice so I can see and report the standardized and exponentiated estimates and model fit statistics, but it seems like tab_model will not take a mipo/data.frame…
L. Tucker
  • 523
  • 2
  • 12
2
votes
1 answer

How to merge two rows in R?

I wanted to know if there is a function in R that will help me merge two rows. Right now my data is in the following shape Car_Type Prod Sale Month Civic 120 67 June City 192 112 June If possible, I would like the data to take this…
2
votes
2 answers

I want summarise a data frame

I want summarize the following data frame to a summary table. plot <- c(rep(1,2), rep(2,4), rep(3,3)) bird <- c('a','b', 'a','b', 'c', 'd', 'a', 'b', 'c') area <- c(rep(10,2), rep(5,4), rep(15,3)) birdlist <- data.frame(plot,bird,area) birdlist …
2
votes
2 answers

gtsummary::tbl_regression use pool_and_tidy_mice() with tidy_standardize()

I'm currently trying to run tbl_regression with an imputed dataset from mice run through a logistic glm. I'm having trouble trying to combine the custom tidiers pool_and_tidy_mice and tidy_standardize in order to get the regression output from the…
L. Tucker
  • 523
  • 2
  • 12
2
votes
1 answer

What is the tidyverse way to apply a function designed to take data.frames as input across a grouped tibble in R?

I've written a function that takes multiple columns as its input that I'd like to apply to a grouped tibble, and I think that something with purrr::map might be the right approach, but I don't understand what the appropriate input is for the various…
shirewoman2
  • 1,842
  • 4
  • 19
  • 31
2
votes
2 answers

In `dplyr`, when use `pivot_wide` ,I want to replace 'NA' at the same time

In dplyr, when use pivot_wide ,I want to replace 'NA' at the same time . Here is the code as below ,they are not work. Anyone can help? Thanks! library(tidyverse) test_data <- data.frame(category=c('A','B','A','B','A','B','A','B'), …
anderwyang
  • 1,801
  • 4
  • 18
2
votes
3 answers

Create sequence of dates in R with pipe %>%

I am trying to create a sequence of dates from a raw string. library(tidyverse) tmp <- "1900-01-01 3000-01-01" This yields a vector of length 2: tmp %>% str_split(., " ", simplify = T) %>% as.vector() %>% as.Date I need to create a sequence of…
FreyGeospatial
  • 325
  • 4
  • 17
2
votes
2 answers

How to remove duplicate records based off a date/time timestamp column using tidyverse? R

I have a dataset that looks like this. library(tidyverse) data <- structure(list(Timestamp = c("12/7/2021 11:29:15", "12/7/2021 11:29:35", "12/7/2021 11:59:18", "12/7/2021 12:28:53", …
RL_Pug
  • 697
  • 7
  • 30
2
votes
2 answers

R: Add new column based on character vector and existing column in dataframe with unique items

I want to assign elements in the character vector to the dataframe based on matching information in the existing column. Data frame with one column head(df, 5) items 1 1 2 1 3 1 4 1 5 1 tail(df, 5) 120001 …
botloggy
  • 383
  • 2
  • 15
2
votes
1 answer

extrapolate position of vehicle by adding new rows to tibbles

I have time t, speed v and position x of a vehicle along with other informations: info1, info2, status How can I extend the tibble by linearly extrapolating the position based on last speed (v = 14) for given timestamps. So the added rows are copy…
SiH
  • 1,378
  • 4
  • 18
2
votes
3 answers

Create Nested List from Tibble

I'd like to create a nested listed from a tibble, so the data is stored more efficiently and it is easier to extract information with subsetting. I have a 3 column tibble like the following: library(dplyr) df <- tribble( ~a,~b,~c, "a1", "b1",…
2
votes
1 answer

How can I crop the data points which lie inside polygon and plot

How can I crop the data points which lie inside the given polygon? library(tidyverse) tbl <- tibble(x = runif(100), y = runif(100)) ggplot(data = tbl, aes(x = x, y = y)) + geom_point() + theme_bw() + …
SiH
  • 1,378
  • 4
  • 18
2
votes
1 answer

Mutate a data frame in the tidyverse passed as a parameter in a function

I'm trying to create a function where you can pass a data frame and the name of one of the columns. Within the function it should mutate the data frame to create a scaled version of the column you sent. Here's my attempt: test_scale <-…
Parseltongue
  • 11,157
  • 30
  • 95
  • 160
2
votes
1 answer

tidyr::pivot_longer tidying multiple columns

I need to tidy the following data set in a compact manner using pivot_longer. My aim is to have a trial column that shows the numbers in the column names from will_f1:will_f16, dface1:dface16, dfood1:dfood16, dout1:dout16. I would like to also…
gundedun
  • 25
  • 2
1 2 3
99
100