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

Melt a big data frame without pandas

I have a 3GB dataset with 40k rows and 60k columns which Pandas is unable to read and I would like to melt the file based on the current index. The current file looks like this: The first column is an index and I would like to melt all the file…
Alicia Pliego
  • 181
  • 10
0
votes
2 answers

How to change a R table from long to wide with dates as well?

I have a dataframe of purchasing events and ages of the individual. Name Item Date PersonA Apple 1/1/14 PersonA Banana 1/1/13 PersonA Pear 1/1/12 PersonB Orange 1/1/15 PersonC Kiwi 1/1/17 PersonC Grapes …
0
votes
1 answer

python pandas melt column by substring

I have dataframe: subject A_target_word_gd A_target_word_fd B_target_word_gd B_target_word_fd subject_type 1 1 2 3 4 mild 2 …
Cranjis
  • 1,590
  • 8
  • 31
  • 64
0
votes
1 answer

R- melting groups of columns from survey data -understanding how R(gather) works

New to code in general and have been through hundreds of google searches and stackoverflow threads but nothing yet really explains how my solution works. There are many ways to melt data, most appear overly complex...curious why my solution works…
alphamelt
  • 13
  • 2
0
votes
2 answers

pandas - move multiple columns with the same name and different missing data into single column then delete duplicate columns

I have a dataframe that looks like this: Col1 | Col2 | Col1 | Col3 | Col1 | Col4 a | d | | h | a | p b | e | b | i | b | l | l | a | l | | a l | r | l | a |…
adin
  • 783
  • 3
  • 13
  • 27
0
votes
1 answer

Looking for a way to make my data horizontal in R

I'm currently working in a psychology lab and beginning data analysis on response time data from a task. The task itself goes on multiple trials and this makes the data disorganized to look at - especially more so now since my initial job was to…
user12470302
0
votes
0 answers

Using ggplot and melt function

I am following the examples lied out below (https://rpubs.com/thinh_ha/londonhouseprice). I am attempting to use the group by part. by_pt <- select(df, realprice1, class) %>% group_by(class) %>% summarise(Count=n(), Mean.Price=mean(realprice1),…
Sean_C
  • 11
  • 2
0
votes
0 answers

Melt() & Cast()

I want to apply the cast() function to this df. In the df there are 2081 different unique 'Variables'. I do not know how to get each of them to be a column with its 'Value' as the content of that column. Also, the seasons are from 2010 - 2018, so…
0
votes
1 answer

Change the format of your data

For some of you these is an easy question; I would like to reshape my data My data structure: structure(list(Time = c("00:01", "00:02", "00:03", "00:04", "00:05", "00:06", "00:07", "00:08", "00:09", "00:10"), Week_Day = c("Wednesday", "Wednesday",…
Rstudent
  • 887
  • 4
  • 12
0
votes
1 answer

How to melt dataframe when a column has two values for a variable in pandas?

I have a dataset that describes a question paper. I would like to map it with the marks obtained by the students and do some analysis. For that purpose, I wanted to melt the question paper details. Question Marks BL PI CO PSO PO 0 Q1 2 …
David
  • 524
  • 1
  • 7
  • 24
0
votes
1 answer

R using melt() and dcast() with categorical and numerical variables at the same time

I am a newbie in programming with R, and this is my first question ever here on Stackoverflow. Let's say that I have a data frame with 4 columns: (1) Individual ID (numeric); (2) Morality of the individual (factor); (3) The city (factor); (4)…
0
votes
1 answer

Applying melt function to multiple .txt files

I am having multiple .txt files each representing some parameters in the following format Parameter1 = structure(list(Year = 1969:1974, Jan = c(16.6, 15.6, 15.8, 16.9, 16.2, 15.4), Feb = c(17, 15.2, 16.6, 14.8, 12.9, 17.9), Mar = c(14.2, …
UseR10085
  • 7,120
  • 3
  • 24
  • 54
0
votes
1 answer

X axis not ordering discrete value after melt of DF

I am fairly new to R and I have a problem with the usage of ggplot2 together with the melt function. In the specific case I am trying to create a multiline plot which represents certain time gaps and their evolution during a race. Say the data…
JacquesLeen
  • 109
  • 7
0
votes
1 answer

Python: combine two data frames with all combinations of index

I have a data frame with x variables and an id_number 1:n (n is large). I want to create a new data frame that horizontally merges each pair based on id_number from the data frame. Original data looks like this: id_number var_x1 var_x2 1 …
pandini
  • 69
  • 7
0
votes
2 answers

How to melt into columns row results?

From a frame like this: df <- data.frame(year = c(2010,2010,2011,2011), stock = c("Amazon","Google","Yahoo","Google") How can we melt the rows and convert into columns count results? The expected output: stock 2010 2011 Amazon 1 0 Google…
Nathalie
  • 1,228
  • 7
  • 20