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

Boxplot with a for loop

I have a list of data frames called: mylist. Headers of the list are names of people and the data frames contain columns with data associated with those names (date, height, weight, etc) names(mylist[1]) [1] "John" names(mylist[2]) [1]…
user2794659
  • 145
  • 2
  • 14
0
votes
1 answer

Extract data value from the output of melt in reshape2

I have a data set in the following format and want to extract data-value for each combination like A_ALL, B_ALL, A_Part, B_part for stastical analysis. Currently, what I can do is A_ALL <- data[data$variable=="All" & data$Set=="A",1] A_Part <-…
ct586
  • 353
  • 1
  • 4
  • 8
0
votes
1 answer

Reshape wide data frame to long format in R using column name information

I am having troubles converting a complicated data base output from its wide form to the long format. It has a couple of hundred rows and ~1,000 columns. It looks something like this: The problem is that the variable of df1_long or the columns of…
JollyRoger
  • 473
  • 4
  • 9
0
votes
3 answers

How to transform dataframe from wide- to long-form

I have this dataframe : data=structure(list(X3CO = c(24.88993835, 25.02366257, 24.90308762), X3CS = c(25.70629883,25.26747704, 25.1953907), X3CD = c(26.95723343, 26.84725571, 26.2314415)), .Names = c("X3CO", "X3CS", "X3CD"), class = "data.frame",…
Wicelo
  • 2,358
  • 2
  • 28
  • 44
0
votes
1 answer

How can I extract vector from melted data

raw Data looks like this: type value 1 a 10 2 a 20 3 a 30 4 b 50 5 b 10 6 b 20 melted data looks like this: 1 a value 10 2 b value 10 I want to apply wilcox.test to a,b To check whether a is greater than b. How to do…
tmjdone
  • 15
  • 5
0
votes
2 answers

R - Reshape - Melt Error

I am trying to melt a data frame and I get this weird error. Any ideas why? str(zx7) 'data.frame': 519 obs. of 5 variables: $ calday.new: Date, format: "2011-01-03" "2011-01-04" "2011-01-05" "2011-01-06" ... $ A20 : Time-Series from 1 to…
user1446967
  • 1
  • 1
  • 1
0
votes
1 answer

Identifiers in Molten data for ggplot

I am struggling a bit with id.vars in melt() and how to make it work with ggplot(). Let's say I got this data on California Population by race, age, and gender since 1970: ca1970_1989<-read.table( …
ako
  • 3,569
  • 4
  • 27
  • 38
0
votes
1 answer

ggplot2-line plotting with TIME series and multi-spline

This question's theme is simple but drives me crazy: 1. how to use melt() 2. how to deal with multi-lines in single one image? Here is my raw data: a 4.17125 41.33875 29.674375 8.551875 5.5 b 4.101875 29.49875 50.191875 …
Puriney
  • 2,417
  • 3
  • 20
  • 25
-1
votes
1 answer

Melt Many columns into 4 R

I have a dataset of patient info, 25 DX codes, and 20 Procedure codes. Each code is in its own column so my table is 45 columns wide just between diagnosis and procedure codes. I need to get the dx codes into two columns DX1-25, and the the code,…
regents
  • 600
  • 6
  • 15
-1
votes
1 answer

How to aggregate DataFrame based on binnary and numeric columns in Python Pandas?

I have DataFrame in Python Pandas like below: ID | VAR1 | VAR2 | C1 | C2 -----|------|------|------|------- 111 | 1 | 0 | 12 | 0 222 | 1 | 1 | 11 | 18 333 | 0 | 1 | 6 | 5 444 | 1 | 0 | 7 | 2 And as an…
unbik
  • 178
  • 9
-1
votes
2 answers

How to merge 3 columns into 1 whilst keeping values column separate

I have the following Pivot table: Subclass Subclass2 Layer Amount A B C 5 E F G 100 I want to merge the 3 columns together and have Amount stay separate to form…
user18233539
  • 129
  • 1
  • 2
  • 8
-1
votes
1 answer

Reshape data into long format by expanding two times, first, by "year" and then by "month"

I have data of a lot of villages with unique identifiers (village), I am trying to shape the data into a long format by first expanding by year and then by month. df_input <- data.frame( village=c("A","B","C"), population = c(1000,1500,2000)) …
Fuser
  • 47
  • 1
  • 9
-1
votes
2 answers

Reshape wide data to long format

I am facing trouble reshaping my wide data into a long format using reshape melt.But I couldn't find a solution best suited to my need. Sorry if I am duplicating this question. My monthly data (CSV file)of a single variable is in the following…
-1
votes
1 answer

How to get a string from column names and melt multiple columns in python?

I have this table and I need to melt away this table to be like the expected table where I need to get the point name (a and b) from the column name and let the bq and progress columns melt. type bq a bq b progress a progress b P …
yangyang
  • 491
  • 4
  • 16
-1
votes
1 answer

Melt pandas dataframe multiple times

I have a dataframe df: Item Name Location Jan-Units Feb-Units Mar-Units Jan-Rev Feb-Rev Mar-Rev Jan-Trl Feb-Trl Mar-Trl 123 ABC CA 20 30 40 100 150 200 1.00 1.50 2.00 456 DEF …
sebwallat
  • 65
  • 3