71 questions
1 vote
3 answers
127 views
transform from wide to long format for groups of columns in dataframe
This is a followup question based on one of my previous questions Transform dataframe to long format based on text . There is also another question that is similar Transforming multible columns from ...
0 votes
1 answer
134 views
names_pattern in tidyr pivot_longer for multiple variables nested in the column names
I have a data frame which I need to put into long format. Here is a simplified version of my data frame: df <- data.frame("UserID" = c(1:3), "ProdID" = c(1, 1, 2), "...
1 vote
2 answers
112 views
Converting Pandas dataframe from long to wide format
I have a Pandas dataframe that records the performance of students in exams in different classes and it looks like: Class_ID Class_size Student_Number IQ Hours Score Place 1 3 ...
0 votes
2 answers
219 views
R reshaping the data
data <- data.frame( T2_husband = rnorm(5), T2_wife = rnorm(5), T1_husband = rnorm(5), T1_wife = rnorm(5), Dyad_ID = 1:5 ) I have 5 columns in the dataset. However, I want to make dataset ...
0 votes
1 answer
82 views
long to wide transformation without creating lists and nulls
this is a followup question from my previous post. My dataframe arranges visit for a specific PK based on dates, with a columns for: visit number visit date exam done in that visit I am trying to ...
0 votes
2 answers
86 views
Select only columns that have no duplicates considering groups
I have a rather large dataset with both long and short data inside: some columns have unique value given a subject and a visit, while other have multiple values. The short data is duplicated to match ...
0 votes
1 answer
70 views
Dataframe from wide to long output
original wide data frame mean_SRBD: I have a data frame (mean_SRBD). The measurement moments (day 1, day 2, day 3) are included in the suffix of the variables (-D1 = day 1, -D2 = day 2). I want to go ...
2 votes
3 answers
136 views
Converting dataframe from "wide" to "long" format with pairs of ID variables
Here's an example of what I am trying to do. I am starting with a dataframe in "wide" format, like below. #sample dataframe id_1 <- c(260, 500, 640, 720) id_2 <- c(261, 501, 641, 721) ...
0 votes
1 answer
64 views
Long format dataframe column hierarchy
I am working with long format dataframes and intend to write a package myself. While it is not crucial, I would like to adhere to common practice of column hierarchy, e.g. when I have 3 participants ...
-1 votes
1 answer
54 views
How to convert wide-data to long-data format for big dataset? [closed]
I am conducting a cross-sectional online study about 54 illnesses, and have 10 variables/columns for participants' background information, then participants were randomly assigned to a set of 9 ...
0 votes
0 answers
20 views
wide data with part of column name as value [duplicate]
I have the following data structure in R DE_GDP DE_INFL US_GDP US_INFL 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 ...
2 votes
2 answers
69 views
How to pivot multiple columns from wide to long by matching all possible combinations in R?
I found this case and this other but they don't quite answer my problem. Input data are in wide format: dat0 # A tibble: 5 × 6 id gp a1 a2 a3 a4 <dbl> <chr&...
0 votes
0 answers
34 views
Excel Long format subtract previous row in certain condition
I have an Excel Long format with the same ID over several days. Participants answered different types of questionnaires and times were recorded. I want to calculate the difference between two types of ...
1 vote
2 answers
51 views
R : Reshape Long => wide with different value length
I want to reshape from long to wide the following data base df_long <- data.frame( indiv_id = c(rep(1,2), rep(2,6), rep(3,4)), value = c(sample(x = 2), sample(x = 6), sample(x = 4)), field_id ...
0 votes
1 answer
153 views
Best way to format this data for exploratory factor analysis, using R? [closed]
I have extremely little experience with factor analysis so my question may beyond rudimentary/remedial. My question is about data formatting. I have this dataset (well, this is just the first two of ...