Questions tagged [reshape2]

The reshape2 package in R contains functions that allow data to be transformed into more convenient forms.

reshape2 is an package for flexibly restructuring and aggregating data. Its primary use is ing data between wide format with repeated measurements in separate columns of the same record and long format with the repeated measurements in separate records.

reshape2 succeeds the reshape package, and is succeeded by the package.

Repositories

Other resources

Related tags

1177 questions
-1
votes
1 answer

Converting to wide format from long with multiple id and value columns

I am stuck trying to convert from wide to long format with multiple ID and value columns. I'd prefer a tidyr solution as dcast as been defaulting to length. Here's what I've tried so far: df_wide <- df %>% melt(id.vars = c(Route, Address, Week))…
philiporlando
  • 941
  • 4
  • 19
  • 31
-1
votes
2 answers

Splitting a string into six new variables in r

I'm trying to split a string of numbers into six different variables. I tried doing it in the original df, but it caused me a lot of problems, so I decided to extract the column I needed to split into a temporary dataframe (with the intent of just…
Nordsted
  • 97
  • 2
  • 12
-1
votes
1 answer

Keep tibbles as tibbles after reshape2::dcast

Is there a way to get dcast to output a tibble? (without using as_tibble) df <- tibble(a = letters[c(rep(1:3, 3), 1)], b = 1:10 + .1, c = 11:20 + .1) df %>% class # [1] "tbl_df" "tbl" "data.frame" df %>% dcast(a ~ b) %>% class # [1]…
IceCreamToucan
  • 28,083
  • 2
  • 22
  • 38
-1
votes
2 answers

reshaping in pandas (python)

I am trying to reshape this file with pivot and pivoed fonction but without any succes. Every user have two tiestamps, one at 19h and the second at 22h, every user have 3 variable and each variable has 8 index file sample…
mbooma
  • 65
  • 5
-1
votes
1 answer

R reformat data frame

In R, I am trying to take interview scores currently in a data frame like this: Interviewer Applicant Score Int_9 App_5 3 Int_3 App_3 2 Int_1 App_2 9 Int_3 App_5 2 ... and reformat to this: …
-1
votes
1 answer

RStudio one numeric variable against n numeric variables in n plots

I'm eviews user and eviews very basically draws scatter plots matrix. In the following graph, I have 13 different group datas and Eviews draws one group data against 12 groups' data in 12 plots in one graph with regression line. How can I realize…
Engin YILMAZ
  • 103
  • 1
  • 5
-1
votes
2 answers

Convert multiple columns to a existing column

My data looks like: data.frame(name=c("city","village"),code=c(10322,10321),plz=c(7041,7043),plz1=c(7044,7044),plz2=c(7043,NA)) What's the smartest way to convert column plz1 and column plz2 to plz: name code plz city 10322 7041 city 10322 …
rupi42
  • 69
  • 7
-1
votes
1 answer

r long to wide reshape

This might possible be a duplicate question. I am working with a dataset which is as shown below Hunters <- rnorm(20, 10,3) Hoarders <- rnorm(20, 4, 5) Truckers <- rnorm(20, 6, 2) Ninja_Warriors <- rnorm(20, 8, 5) Inventors <- rnorm(20, 5, 5) y …
Jill Sellum
  • 319
  • 2
  • 4
  • 14
-1
votes
1 answer

Plot selected rows with multiple columns with ggplot

I have a dataset set with 34 columns and 600+ rows. I successfully managed to reshape it for my data to be predicted for 5 columns (5 years) using reshape2 Dataset_name <- melt(data=XYZ, id.vars=c("A", "B", "C",.... {so on minus 5 columns})) Now I…
Zulu
  • 13
  • 4
-1
votes
2 answers

Wide to long format in R list: 3D to 2D array with 3rd dimension as ID

I have imported a *.mat data set of ECG data and it turns out to be an array nested in a list with (1:19, 1:2000, 1:45) dimensions. I'd like to convert this array into a data.table in long format where each of the 1:45 are 'ids'. I like the look of…
HCAI
  • 2,213
  • 8
  • 33
  • 65
-1
votes
1 answer

R: How to find means of columns greater than 1 after grouping by gender?

How do I group the below sample of data by Gender and compute means for each of the genre columns within these groups considering only those values greater than 1? Ultimately I want to plot a bar chart with genres on the horizontal independent to…
bb5kb
  • 51
  • 1
  • 8
-1
votes
1 answer

reshape / restructure the data frame in R

I'm cleaning a dataset, but the frame is not ideal, I have to reshape it, but I don't know how. The following are the original data frame: Rater Rater ID Ratee1 Ratee2 Ratee3 Ratee1.item1 Ratee1.item2 Ratee2.item1 Ratee2.item2 …
wh41e
  • 183
  • 1
  • 3
  • 10
-1
votes
1 answer

Unsure why merge() is not merging all rows horizontally (in R)

I have 2 dataframes in R: ag<-structure(list(Crop = c("beans", "chayote", "chives", "chiwa squash", "cilantro", "corn", "epazote", "flower chiwa squash", "jicama", "macal", "onion", "papaya", "pineapple", "plantain", "red onion", "scallions",…
elduderino260
  • 223
  • 3
  • 12
-1
votes
1 answer

More compact use of ggplot : grid spaghetti plot

The following code plot the predicted probability of several models against time. Having, all the plots on one graph was not readable so I divided the result in a grid. I was wondering if it was possible to have only one ggplot with all the models…
jadWe
  • 9
  • 2
-1
votes
1 answer

How to aggregate data.table by applying two functions

I have a data.table that lists the user id, the week number, the fact that a user did something (Processed, either 0 or 1) and a column I just use to count how many values I have, called HowMany: data <-…
user299791
  • 2,021
  • 3
  • 31
  • 57