All Questions
303
questions
-3
votes
0
answers
39
views
cannot reshape array of size 1000 into shape (100,100) [closed]
>>> cent_rand = np.random.randint(1919, 3946, 1000)
>>> len(cent_rand)
1000
>>> two_d_cent = cent_rand.reshape((100,100))
Traceback (most recent call last):
File "<...
1
vote
2
answers
53
views
In R, how to transpose row data to coulmn per variable? [duplicate]
I have some data like below
dataA=data.frame(structure(list(Season = c(2021, 2021, 2021, 2021, 2021, 2022,
2022, 2022, 2022, 2022, 2023, 2023, 2023, 2023, 2023),
...
0
votes
0
answers
38
views
Reshape multiple columns R. Columns inverted
Following this question I got a very strange behaviour with base reshape:
Reshaping wide to long with multiple values columns
Here, it works:
df <- data.frame(id=c("a", "b", &...
2
votes
3
answers
85
views
Convert the event-level dataset to the patient-level data in r
I need to convert the event-level dataset to the patient-level data i.e. convert a long dataset to a wider one based on deidnum as a key variable. Additionally, I want to create columns for each ...
0
votes
1
answer
17
views
I would like to reshape my data such that the individual items under the column ''variable'' become separate columns with their values under them [duplicate]
The current data looks like this: Please run the code below
df1<- data.frame(Names= c(c(rep("Lincon",12), rep("Joe",12),rep("Megi",12))),
Year= c(rep(...
1
vote
0
answers
102
views
"Aggregation requires fun.aggregate: length used as default" error when using cast() function from Reshape package
I am trying to use the cast() function from the Reshape package to convert a long format dataframe into wide format. Below is the dataframe (named textMessagesLong) I am working with.
I am using the ...
0
votes
1
answer
48
views
I want to modify my dataset in R so that I can conduct a market basket analysis
I need to modify in R my dataset that looks like a classic table with observations in the row and variables in the column. Specifically, the first column reports a set of transactions identified by an ...
1
vote
2
answers
73
views
dcasting long table along multiple columns
I am having a difficult time understanding dcast, and cannot get the right commands to get what I want. I will give a minimal repro.
#generate the data
ID <- c('a','a','a','b','b','b')
Parameter &...
4
votes
1
answer
65
views
transform data frame from wide to long (several variables) using separator [duplicate]
I have a df like this one:
FID <- c(1,2,3,4)
d <- c(1,1,2,2)
IID_1 <- c("1A","2A","NA","4A")
IID_2 <- c("1B","2B","3B",...
0
votes
2
answers
57
views
reshape function not mapping values correctly
I am working with a within-subjects design looking at how participants rated 20 videos across a variety of variables (valence, arousal, etc.) and am trying to turn my wide-format df into a long format ...
0
votes
1
answer
49
views
transforming complex wide data to long in R, multiple year columns, corresponding values, UTF-8 issues (Duplicate?)
What I have is a wide format, that need to get reshaped and sorted differently. I have 10 columns in total for year, one same year for all rows, different year per column. These I would like to merge ...
2
votes
2
answers
55
views
Reshape the data from three columns to two column
I have a data like this :
Response Prompt Prompt.Label Comments
1 Friend who si3 3_a
2 1 was si4_en 3_a
3 1 was si4_nag 3_a
4 ...
0
votes
0
answers
29
views
reshape2 melt a list of pixel image objects like in reshape
I have a list of pixel image objects from spatstat.geom (see example data below) and want to melt them into one data.frame. I do it with reshape::melt and it works fine. Now, I wanted to do it with ...
0
votes
0
answers
268
views
converting a df from wide to long but warning message: number of items to replace is not a multiple of replacement length
I would like to turn this dataframe from wide to long. I know that there are some similar posts about the topic, for instance I have tried all the options from this one:
Reshaping wide to long with ...
0
votes
3
answers
142
views
How to do a nested 2 level reshape in R?
I am currently working on a survey project that asks about respondents' economic activities. So we will ask the jobs/businesses they have, and since some jobs/businesses are seasonal, we ask about ...