Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [tidyr]

tidyr is an R package by Hadley Wickham for cleaning and reshaping data, designed to use the magrittr pipe (%>%) so as to interact well with dplyr and similar pipeable packages which emphasize tidy data. tidyr is the successor to reshape2.

0 votes
0 answers
18 views

ggplot line plots are not showing up on proportional secondary axis

I am trying to plot a barplot, and overlay some plots onto it using a secondary axis. I am able to adjust the secondary axis to be proportional to the values but the line plots still seem be squished ...
no_frills_30's user avatar
0 votes
1 answer
94 views

Complex lon/lat format manipulation

I originally developed a model to work with a df as df1_ref. Now, I found more data I need in a different format as df2. df1_ref: id country point_id lon lat value_A ...
dmoyaec's user avatar
  • 65
0 votes
1 answer
40 views

R How to reframe data to connect start and stop times

I have a data set that describes narwhal behaviours. There are eight whales (whaleID), multiple behaviours (behaviour), each whale can interact with none, some or all of the other whales (modID), and ...
Ghazam's user avatar
  • 27
2 votes
3 answers
73 views

Complete and fill missing rows with groups of uneven length

I have a dataframe of county executives and the year they were inaugurated. I am running a panel study with county-year as the unit of analysis. The date range is 2000 to 2004. I will like to expand ...
YouLocalRUser's user avatar
0 votes
2 answers
29 views

Pad column numbers while using separate_wider_delim in R

I have a dataset in R that contains a column that contains a string that I want to separate into multiple columns using separate_wider_delim from the tidyr package. What I want to do is to pad the ...
BPL's user avatar
  • 127
2 votes
4 answers
87 views

Convert a dataframe of nearest neighbors to onehot coding

Let's say we took the mtcars data and ran a PCA. Then, we want to know which brands of cars are most similar in PC space, i.e. the nearest neighbors. So someone ran a nearest neighbors analysis and ...
jnat's user avatar
  • 65
1 vote
2 answers
69 views

parallel/automatic way of unnesting list columns that contains data frames (list columns might be empty)

Please consider the following data frame: df <- structure(list(oID = c(37751L, 30978L, 33498L), peId = c(12L, 13L, 14L), last_Name = c("ABC", &...
deschen's user avatar
  • 10.4k
1 vote
4 answers
76 views

Apply function rowwise() using column names to identify function arguments using mutate()

I've created a tibble where each column is named to correspond to the arguments of a custom function. There are many columns and so I'm trying to avoid having to explicitly call and assign each ...
mikemtnbikes's user avatar
0 votes
1 answer
45 views

Change raster extent with tidy

I have files from ERA5 that have extent from 0 to 360 (lon) and -90 to 90 (lat) Example: > era5_sr class : SpatRaster dimensions : 721, 1440, 744 (nrow, ncol, nlyr) resolution : 0.25, 0....
herakles_1950's user avatar
1 vote
0 answers
62 views

Selecting columns based on multiple conditionals (including string matching) using dplyr

Having fun testing out the capabilities of the select_if() function, especially learning how to bundle multiple conditionals together for column selection. For example I can select factors that have ...
llewmills's user avatar
  • 3,386
1 vote
1 answer
42 views

Pivot distinct value pairs wider using timestamp

I have distinct pairwise data points in column Utterance; the data pairs have identical Timestamps. I'd like to pivot the distinct Utterance pairs wider and align them on the same row with the same ...
Chris Ruehlemann's user avatar
1 vote
1 answer
24 views

pivot_longer from multiple columns into a singular names_to and two values_to

I've spent most of the day on this and finally calling in some help. There are multiple entries here on related questions, but none that quite get at what I'm trying to do. Below is an example df. x &...
Scott Davidson's user avatar
3 votes
3 answers
53 views

How can I convert two summarized columns to two columns with a binary response in R?

I have a dataframe in R with results of sports matches. Each row represents one match between two players with columns for the date of the match, the player names, and the scores of each player. ...
Trevor Greissinger's user avatar
0 votes
2 answers
24 views

How to avoid input variable names in tidyr::complete()

In tidyr::complete, I have to input variable names, how to avoid it? In actual, the variable are some many, it's boring to input one by one ... Anyone can help? library(tidyverse) raw_df <- ...
anderwyang's user avatar
  • 2,283
0 votes
1 answer
40 views

Force column to appear when no data returned for group after summarising dataframe

I have a (non-shareable) data frame of cases of disease (each row is a person with a disease) and columns corresponding to their age group (Age_Grp_15) and their quintile of marginalization (...
user25561433's user avatar

15 30 50 per page
1
2 3 4 5
290