Questions tagged [melt]

In R, the "melt" function from the "reshape2" and "data.table" (and earlier, "reshape") packages converts data into a long form. Melt is also a web application framework written in PHP.

In data processing, reshaping data to a long form where each row represents only one observation of one variable is often called "melting" the data, similar to UNPIVOT in some relational databases such as .

In , the function is part of the and packages (earlier, the "reshape" package).

This functionality is also found in similar data processing tools such as .

Related tags:

840 questions
0
votes
1 answer

R: Re-Formatting Sports Team Line-up Data

I have a lot of data in R for sports teams and their starting line-ups for matches. An example of my dataset is below: matchdata <- data.frame(match_id = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), player_name = c("andrew",…
user3198404
  • 127
  • 11
0
votes
2 answers

R: Cast data back to original form

I am trying to figure out how to create columns from a series of rowvalues for a variable. Here is a toy representation, I have a set melted: name variable value 1 Dog id 1 2 Cat id 2 3 Fish …
mlegge
  • 6,763
  • 3
  • 40
  • 67
0
votes
1 answer

stacking subsets of data.frame in R

I have a dataset with one (or more) id variables and many subsets of variables which have the same structure. I would like to stack these subsets, in a long format : I have three subsets in my example, so the final table must have three times more…
Giuliano
  • 323
  • 3
  • 10
0
votes
1 answer

Reshape multivariate time series in R

I have time series T(1), T(2), T(3), T(4)...Tn in addition I have 2 other time-dependent parameters P(1), P2(2), P(3)... and R(1),R(2),R(3)... Therefore the data looks like T(1) P(1) R(1) T(2) P(2) R(2) T(3) P(3) R(3) T(4) P(4) R(4) T(5) P(5)…
blast00
  • 559
  • 2
  • 8
  • 18
0
votes
2 answers

Transform data frame with column values as column names

I have a dataframe that looks like this: variable Name Description value SMTS GTEX-N7MS-0007-SM-2D7W1 ENSG00000223972.4 DDX11L1 0 Blood GTEX-N7MS-0007-SM-2D7W1 ENSG00000227232.4 WASH7P 158…
Komal Rathi
  • 4,164
  • 13
  • 60
  • 98
0
votes
1 answer

R: Creating long dataset when rows are variables and columns are years

I have data that looks like this: Country.Code Indicator.Code X1960 X1961 X1962 X1963 X1964 X1965 AFG allsi.bi_q1 NA NA NA NA NA NA AFG allsp.bi_q1 NA NA NA NA NA NA AFG …
Kenji
  • 571
  • 4
  • 20
0
votes
2 answers

Is this reshape of data possible?

I have a data structure that looks like the following: groupA1 groupA2 groupB1 groupB2 date text 0 1 1 1 2013-01-01 the dog For each groupB variable, I want to list one row for each column…
tcash21
  • 4,880
  • 4
  • 32
  • 39
0
votes
1 answer

melt and cast dataframe adding new variables

Im running into a bit of trouble trying to reshape my dataframe: sites_w_richness DATASET LINK HERE. I have been trying to get the data to organize into four columns site longitude latitude year scenario richness value. Unfortunatley the…
I Del Toro
  • 913
  • 4
  • 15
  • 36
0
votes
1 answer

R: reverse reshape2's melt() on n-dimensional arrays

I've got a 3-dimensional array in R that I can use melt() on to produce a long data.frame: library(abind) library(reshape2) a = matrix(1:4, nrow=2, ncol=2) x = abind(a, a, along=3) y = melt(x) y which yields: Var1 Var2 Var3 value 1 1 1 1…
Michael Schubert
  • 2,726
  • 4
  • 27
  • 49
0
votes
2 answers

Convert from long wide data fromat to long data format in R with multiple depth headers

Maybe this can't even be done because I have my data in a bad format, but I'm trying to get it from a "kind of" wide format to a long format. If I modify the data in excel first, I know how to do this with melt, but I have a LOT of data, and I'm…
Krone
  • 43
  • 10
0
votes
1 answer

How to melt data in R?

I have got a matrix describing relationship between diffetent people. If there is any connection between people I have "1" in a particular cell, otherwise - "0". How to turn this into a data.frame with two columns looks like: person1 --…
group413
  • 159
  • 1
  • 1
  • 5
0
votes
2 answers

Creating a time variable to melt a data frame

I have a small nagging question that I hope I might be able to get some help on... My data frame has a personID and houseID (as well a distance between the two), though one person may be matched to more than one house. I want to reshape my data so…
bubsy
  • 23
  • 4
0
votes
2 answers

melt giving several value columns

I am reading in parameter estimates from some results files that I would like to compare side by side in a table. But I cant get the dataframe to the structure that I want to have (Parameter name, Values(file1), Values(file2)) When I read in the…
0
votes
0 answers

Using melt function: Variable and Value

I used the melt function to combine some variable under a single column: melt(p,id= c("year","month","carrier","carrier_name","airport","airport_name","arr_cancelled","arr_diverted","arr_delay")) The melted data looks fine with all identifiers in…
0
votes
1 answer

Summarizing a presence absence, abundance matrix

I have a site by species matrix that looks like this: colA= c("A","A","A","B","B","B","C","C","C") colB= c(1,2,3,3,0,1,2,1,0) colC= c(0,0,0,1,0,0,0,0,1) df= data.frame (site=colA, sp1=colB, sp2=colC) This matrix has three sites A,B,C, and two…
I Del Toro
  • 913
  • 4
  • 15
  • 36