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
2 answers

convert to wide format and set 0 if value does not exists

I have following dataset: dataset1 <- data.frame( bnames = c("T1", "T1", "T2", "T3", "T3"), events = c("I", "O", "I", "I", "O"), freq = c(1,2,3,4,5)) I want to convert this dataset to wide format, my approach (using reshape…
Wakan Tanka
  • 7,542
  • 16
  • 69
  • 122
0
votes
1 answer

Stacking data file in R

I am looking to stack a datafile that I have in R and am struggling to find a solution to my problem. I have 49 variables, named i1.1, i1.2, 1.3, i1.4, i1.5, i1.6, i1.7 ... i7.6, i7.7. And I would like to stack all of the i1s together with a new…
Daniel Rawlings
  • 183
  • 1
  • 1
  • 8
0
votes
1 answer

Plotting two columns, one stacked using melt and ggplot

I've searched all over the place and can't seem to find the answer to this question. I have a dataframe with a number of variables that I'd like to make into a barplot. That code is here: Raw_Portfolio_Data <- read_excel("RData2.xlsx", range =…
bigjdawg43
  • 93
  • 1
  • 1
  • 7
0
votes
1 answer

plotting thousands of lines with ggplot2 and melt

I want to create a plot overlaying 1000 simulations of a MA(2) process (1 plot, 1000 lines). I cant seem to get ggplot to plot more than one of these 1000 series. There are many posts about this problem on here, and it seems that the problem for…
0
votes
2 answers

unmelt data of data values for groups

I am trying to unmelt a big table with variables. this thread did only give me hints but did not solve my problem (How to "unmelt" data with reshape r). I am trying to get from here: name1 name2 values group xyz1 abc1 1 group1 xyz2 …
Dennis
  • 45
  • 8
0
votes
0 answers

Melting R dataframe in a paired fashion

I have the following data frame: > sample chrom start end score genehancer_id connected_gene score.1 connected_gene.1 score.2 connected_gene.2 score.3 connected_gene.3 score.4 1 chr10 121780088 121780259 0.27 GH10G121780 …
Newbie
  • 411
  • 5
  • 18
0
votes
0 answers

adding a melt function in a loop generating subsets with R

do you think I can add a melt function in this loop? for (i in unique(df$year)) {dfnames<- paste("df",i, sep = "_") assign(dfnames, df[df$year==i,])} I just want to reshape all the subsets that I am generating with that loop. I would like…
user9395105
0
votes
1 answer

in R, melted data works with ggplot. Why does an identical manually constructed data set fail?

I have a dataframe that looks like this, lets call it t1 for now: D1 D3 D5 Min. :-0.2692 Min. :-0.4129 Min. : 2.509 1st Qu.: 2.4232 1st Qu.: 2.9288 1st Qu.: 4.731 Median : 3.3372 …
Adam Price
  • 810
  • 2
  • 11
  • 21
0
votes
2 answers

R - adding columns together, depending on column name

I have a dataframe (df1) that includes abundances of different species in each sample: > SampleID Sp1 Sp2 Sp3 Sp4 ... Spn > asb-001 3 0 0 23 9 > asb-002 4 15 10 56 98 > asb-003 8 45 …
ayesha
  • 135
  • 15
0
votes
0 answers

stacking dataset

I am working to melt some data using reshape2. I have a series of tables (about 16), form The Office for National Statistics, merged into one spreadsheet. Each table covers a different type of measurement. The first table is 16 industries over 6…
El_Commi
  • 1
  • 2
0
votes
1 answer

Equivalent of R's reshape2::melt() in Scala?

I have a data frame and I would like to use Scala to explode rows into multiple rows using the values in multiple columns. Ideally I am looking to replicate the behavior of the R function melt(). All the columns contain Strings. Example: I want to…
Raphvanns
  • 1,766
  • 19
  • 21
0
votes
1 answer

Need assistance in reshaping the data

I'm new here and also to R world. I have been trying to reshape the data but i couldn't do it after going through dcast, melt ,reshape options. my data looks like, original data TESTCODE BATCHNUMBER BATCHVALUE DATALINEID test 1 …
Santhosh N
  • 25
  • 6
0
votes
2 answers

R- Reshaping Data two columns to 1

Hello I have the following dataframe: Date S1 Mavg1 STdev1 S2 Mavg2 STdev2 1 02/12/1999 -0.000217052 0.002862195 -0.002390842 2.2025825 -1.17258213 -0.3057015 2 03/12/1999 -0.004882038 -0.015920939…
J.Doe
  • 166
  • 1
  • 9
0
votes
1 answer

How to plot multiple variables vs single x-axis using ggplot2 boxplot

I have a data frame like so: df= data.frame(cond = c(rep('N', 5), rep('Y', 5)), var1 = rnorm(10), var2 = rnorm(10), var3= rnorm(10)) which looks like this: > df cond var1 var2 …
rimorob
  • 624
  • 1
  • 5
  • 16
0
votes
2 answers

melt function gives match.names() error

I have a data frame (dat) whose structure reads as follows: Classes ‘grouped_df’, ‘tbl_df’, ‘tbl’ and 'data.frame': 16 obs. of 28 variables: $ tank : Factor w/ 16 levels "1","2","3","4",..: 1 4 5 16 6 8 10 11 7 12 ... #This is a factor $…
user8435999