57 questions
3
votes
3
answers
179
views
How to reshape from long to wide format filling NAs with zeros
I have a long format table which already has NAs:
df <- data.frame(
ID = c(1, 1, 2, 2, 3),
region = c("A", "B", "A", "B", "A"),
status = c(1, ...
2
votes
1
answer
59
views
Trying to reshape/ rearrange table variables in MATLAB
ID
Channel
relativeAlpha
relativeBeta
relativeGamma
01-12
F7
9.25
1.23
2.98
01-12
F8
8.35
3.45
6.78
I'm using EEG lab to calculate relative spectral power for various bands. This went well, but now I'...
1
vote
2
answers
115
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
223
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
87
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
1
answer
72
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
137
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)
...
-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 ...
2
votes
1
answer
40
views
How can I collapse repeated missing observations into a single nonmissing observation for the same ID in SAS?
I have a large dataset with hundreds of variables collected over several timepoints. The variables are already defined by timepoint, but each observation is a different timepoint. It's like the ...
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
...
-1
votes
2
answers
54
views
Pivot a longer dataframe to wide with multiple columns in R
I have a dataframe with 1000+ rows in a long format. I need to pivot into wider format using the ID as the pivoter. Pivoting it using pivot_wider only returns values in the first column, but not all ...
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
155
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 ...
0
votes
1
answer
509
views
convert SQL output in databricks from long to wide
I have a very simple outcome in databricks that has 80M lines of data because there is a separate line for each PIN. The data is a listing by PIN with columns "pin", "device category&...
0
votes
1
answer
66
views
R: Formatting a weird, long-ish table into wide format
I have some data in the format found in the code chunk.
dat <- data.frame(fruit=c('apple',NA,NA,NA,NA,NA,NA,NA,NA,
'pear',NA,NA,NA,NA,NA,NA,NA,NA,
...