tidyr Questions
2
Solved
I'd like to sample rows from a data frame by group. But here's the catch, I'd like to sample a different number of records based on data from another table. Here is my reproducible data:
df <- ...
6
Solved
My data looks like this:
# A tibble: 6 x 4
name val time x1
<chr> <dbl> <date> <dbl>
1 C Farolillo 7 2016-04-20 51.5
2 C Farolillo 3 2016-04-21 56.3
3 C Farolillo 7 2016-...
2
Solved
I searched and searched for this and found similar stuff but nothing quite right. Hopefully this hasn't been answered.
Lets say I have a column with Y,N, and sometimes extra information
df<-d...
3
Solved
I have a data.frame with ids composed of sequences of alphanumeric characters (e.g., id = c(A001, A002, B013)). I was looking for an easy function under stringr or stirngi that would easily do math...
4
Here is my input dataset which contains one row and 12 columns/variables:
df <- data.frame(q_q10=0,q_q20=0, q_q30=0,q_q40=400,
q_q10_low=0,q_q20_low=0,q_q30_low=0,q_q40_low=350,
q_q10_up...
2
Solved
Since the update to tidyr version 1.0.0 I have started to get an error when unnesting a list of dataframes.
The error comes because some of the data frames in the list contain a column with all NA...
3
Solved
I have example data like below, where for a unit, I have multiple treatments, and multiple measurements for each treatment in before and after periods. I want to do a before-after comparison, so I ...
3
Solved
I have a dataframe with several columns containing list columns that I want to unnest (or unchop). BUT, they are different lengths, so the resulting error is Error: No common size for...
Here is a...
11
Solved
I have a working solution but am looking for a cleaner, more readable solution that perhaps takes advantage of some of the newer dplyr window functions.
Using the mtcars dataset, if I want to look...
2
Solved
I have a data.frame with several columns:
set.seed(1)
df <- data.frame(cluster=LETTERS[1:4],group=c(rep("m",2),rep("f",2)),point=rnorm(4),err=runif(4,0.1,0.3))
and I'd add another columns whi...
1
Solved
Given a dataframe:
df <- data.frame(Col1 = LETTERS[1:4], Col2 = LETTERS[23:26], Col3 = c(1:4), col4 = c(100:103))
I want to combine column with their column names. I know I can use unite from t...
4
Solved
Suppose I have a 3-dimensional array g with dimensions [x,y,z]. reshape2::melt(g) would produce a data frame with columns giving indices of x,y,z and value where value contains the values in each e...
7
Solved
I have data with columns such as Area_bsl that contain strings of comma-separated values and a column diffr that states the number of elements by which Area_bsl must be shortened:
df <- data.fra...
3
I would like to make a cross tab in R using dplyr. I have good reasons for not just using the base table() command.
table(mtcars$cyl, mtcars$gear)
3 4 5
4 1 8 2
6 2 4 1
8 12 0 2
library(dplyr...
6
Solved
I'm trying to preserve the order of columns when I gather them from wide to long format. The problem I'm having is after I gather and summarize the order is lost. The number of columns is huge so I...
4
Solved
I have a large dataset that looks like this. I was wondering if there is a clever
way to apply a t-test, in each row, aka gene, and compare the counts between humans and mice.
I want to compete in ...
Selene asked 15/1, 2023 at 17:45
2
Solved
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...
2
Solved
I am a bit puzzled by separating columns using the separate function in tidyr:
My data frame looks like this
library(tidyverse)
df=tibble(col1 = c("2397_A_run379_CTTGTACT_S119_L004_R1_001&quo...
3
Solved
I have a large data set (35.8 GB, over 1 billion rows) that I need to tidy.
Here is some reproducible code to show its format.
id <- c(1, 1, 2, 2)
item <- c("a1", "a2", &q...
3
Solved
tidyr::fill() isn't filling values in my tibble. Here is a reprex:
library(tidyverse)
library(googlesheets4)
url <- "https://docs.google.com/spreadsheets/d/1q5gdePANXci8enuiS4oHUJxcxC13d6bjMRS...
3
Solved
Here's some silly data that we pivot wider, using two names:
library(tidyr)
df <- data.frame(
food = c('banana','banana','banana','banana','cheese','cheese','cheese','cheese'),
binary = c(rep...
3
Solved
I am trying to separate values for the estimates and CIs into three columns, so that the column with info of the type 99.99[-99.9,99.9] is converted into three separated columns.
Please consider th...
4
Solved
I would really like pivot_wider to create a column with NAs if the level of a factor exists but never appears in the data when it's used as a names_from argument. For example, the first line gives ...
1
Solved
I have a nested list from reading a JSON that stores logging info from a video game. The time element of the list is a simple vector, while inputManagerStates and syncedProperties are lists that ma...
6
Solved
Suppose I have some count data that looks like this:
library(tidyr)
library(dplyr)
X.raw <- data.frame(
x = as.factor(c("A", "A", "A", "B", "B"...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.