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

ggplot2: Reshaping data to plot multiple Y values for each X Value

I have a data frame which contains 2 weeks of data that indicate how many passengers have been on a train each day. Each observation contains 3 values, the date, the number of passengers, and the day of the week. I want to compare the passengers on…
Brad
  • 29
  • 1
  • 10
0
votes
0 answers

Using melt function and getting error: names do not match previous names

I created a dataframe with names [1] "promotion" "code" "01.09.2016" "01.16.2016" "01.23.2016" "01.30.2016" "02.06.2016" "02.13.2016" "02.20.2016" "02.27.2016" "03.05.2016" [12] "03.12.2016" "03.19.2016" "03.26.2016" "04.02.2016" "04.09.2016"…
shailesh
  • 43
  • 1
  • 7
0
votes
0 answers

dplyr melting for pivot tables

If I wanted to apply multiple functions in a dplyr call, I could run the following: mtcars %>% group_by(gear) %>% select(hp, disp) %>% summarise_all(funs(n=sum(!is.na(.)), mean=mean(.,na.rm=T))) Output: # A tibble: 3 x 5 gear hp_n disp_n …
vashts85
  • 1,069
  • 3
  • 14
  • 28
0
votes
2 answers

Need some advise to use reshape2:melt function for ggplot-ing

I need help writing a command to do the following: I have two data frames (which I plan to combine into one to do some ggplotting) of the following form: df1 |..D..|..A...|..B...| | d1 | a11 | b11 | | d2 | a12 | b12 | | d3 | a13 | b13 | …
Mario Reyes
  • 385
  • 1
  • 2
  • 13
0
votes
1 answer

How can I reshape this data to plot multiple lines with ggplot2?

I have a dataframe that looks like this: lethal.y lethal.x resist.y resist.x mock.y mock.x Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000 …
Adam Price
  • 810
  • 2
  • 11
  • 21
0
votes
1 answer

Transform a data frame from long to wide with all values in rows

I read a lot on the internet and haven't found a solution. I have this data.frame: d <- data.frame(cat = letters[11:15], count = c(1:10)) e <- data.frame(cat = letters[11:15], count = c(11:20)) G <- rbind(d, e) cat count 1 k 1 2 l …
Erik Steiner
  • 581
  • 1
  • 5
  • 18
0
votes
2 answers

Using row value in dataframe to choose column in second dataframe

So I have two dataframes... one is a wide format where the column names are dates, and listed under the dates are all the issues that happened on those days. The second dataframe is one that has a variety of columns that depicts other information of…
Naji
  • 674
  • 2
  • 14
  • 35
0
votes
1 answer

How do I melt/gather multiple variables (error bars) into one for mapping to geom_bar?

I'll start with my goal which is to generate graphs for each of my variables (magnitude [mag], duration [dura] and distance [dist] but with distinct error bars for train and test. : Almost finished graph I have a data-frame that looks like this:…
TunaFishLies
  • 107
  • 7
0
votes
3 answers

Reshaping from wide to long data while collapsing variable values for same IDs in R

I am relatively new to R. I have a dataframe df that looks like this, where PMID is an ID: PMID Variable Value 1 MH Humans 1 MH Male 1 MH Middle Aged 1 …
sweetmusicality
  • 937
  • 1
  • 10
  • 27
0
votes
1 answer

How to blend tracks in melt framework?

Is there any filters/transtions which could be used to blend tracks?
MagicKyle
  • 366
  • 3
  • 9
0
votes
1 answer

How to Melt single column in R

How to melt single column from T1 to T2. T1 Mar-17 T2 328 Mar-17 328 29.57 Mar-17 29.57 38.483 Mar-17 38.483 31.26 Mar-17 31.26 37.3 Mar-17 37.3 60.026 Mar-17 60.026 47.059 Mar-17 47.059 40.215 Mar-17 40.215 51.79 Mar-17…
0
votes
1 answer

ggplot plots a mess from filtered long-form data

With the code below, I generate three plots of a CO2 data series. Two of the plots look good, the last one looks weird. I don't understand how ggplot can come up with this plot. Any ideas? data = read.csv('data4.csv', header = TRUE, comment.char…
schoettl
  • 350
  • 4
  • 14
0
votes
1 answer

Getting the name of the variable with maximum value in a molten data frame

Example data: year <- c(1990, 1991) January <- c(1, 1) February <- c(0, 3) df <- data.frame(year, January, February) year January February 1 1990 1 0 2 1991 1 3 I want to get a new data frame with the maximum…
MZimbric
  • 45
  • 7
0
votes
1 answer

Create new dataframe from list of values of variable2 for each value of variable1?

I've got some lists of postcodes from different states, in the form such as stateA_postcode = [12345, 23456, 34567, ...] stateB_postcode = [11111, 22222, 33333, ...] And I would like to create a pandas dataframe like this (order doesn't matter): …
Kevin Fang
  • 1,966
  • 2
  • 16
  • 31
0
votes
1 answer

Python Pandas Dataframe check column of lists and return ID from another Dataframe

I have a pandas dataframe df1 which has an index, and a column of lists and looks like: index IDList 0 [1,3,5,7] 1 [2,4,5,8] 2 [6,8,9] 3 [1,2] I have another pandas dataframe df2 which has NewID as the index, and a column of lists which…
clg4
  • 2,863
  • 6
  • 27
  • 32