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

Convert columns into rows, R data.frame

I want to repeat heach column into a new row as the next example: Date<- c(seq(as.Date("2000/1/1"), by = "month", length.out = 3)) A<- c(seq(2,4,length.out=3)) B<- c(seq(20,40,length.out=3)) df <- (data.frame(Date,A,B)) df Date A B 1…
francisco corvalan
  • 300
  • 1
  • 4
  • 10
0
votes
0 answers

df.melt() a certain number of variables at a time

I have a spreadsheet with hundreds of variables, that I need to visualize. To do so I'm using df.melt() to convert the dataset to long format. Which is working well to visualize all the variables in subplots. The only problem is that it creates a…
John Conor
  • 722
  • 6
  • 20
0
votes
2 answers

Uniting several rows of data frame

Is there a way to unite several rows of a data frame with multiple columns? I have data from different animal organs - I want to contrast individuals' organs. One row should contain only measurements of an individual but from all sampled organs…
Nadiine El Nino
  • 339
  • 1
  • 6
0
votes
1 answer

Melt issues resulting in incorrect plot

Trying to plot multiple curves on one graph using ggplot2. The x-axis will be wavelength, the y-axis will show intensity. Data Table (called ‘Set’) is shown below (col2 refers to column 2 etc.), wavelength goes from 3600 to 8000 wavenumbers. Each…
Screamh
  • 39
  • 5
0
votes
3 answers

R reshape but interweaved?

I need to reshape a wide-format dataframe into a long-format. I am familiar with the melt() function and have used it multiple times. df <- data.frame( Weekday = c( "Mon", "Tues", "Wed", "Thurs", "Fri" ), Q1 = c( 9.9 , 4.9 …
user15141497
  • 73
  • 1
  • 6
0
votes
1 answer

Restructuring data set by stacking similar variables in R

I have the following variables as part of a bigger data set. And each 3 successive variables measured the same (e.g. the first 3 variables c_0064, c_0065, c_0066 measured 3 brands the participant knows, the second 3 variables v_159_1, v_159_2,…
Nadine M.
  • 95
  • 2
  • 10
0
votes
1 answer

how to melt only selected columns (integer and string) in python?

I have this dataframe: no id type xa xa 01 02 1 bar any 2 3 1 3 2 foo all 3 4 0 1 the columns I need to transform is coming after the type column, and I actually have plenty of them coming after…
nomnom3214
  • 227
  • 1
  • 11
0
votes
0 answers

Jupyter Melting a Covariance Table

In R, you can use a melt function to take the below example table and convert it to a melted covariance table. Is there a function to perform this? I looked at pd.melt() but is there a way to perform this based on column name and row name? I am…
0
votes
1 answer

How to Plot Two or More Specific Columns Side by Side using ggplot

I've been struggling with how to make a bar plot for the following table. I want to show two bars for input and nonchimeric numbers side by side and fill them in based on the treatment. And I need each bar labelled according to the samplename. I…
tslb14
  • 11
  • 3
0
votes
1 answer

Transpose few columns and reshaping them

I am looking to transpose only certain columns in my dataframe and their values by keeping certain columns fixed. WO.No LineSubType ProductName Desc Problem WO-00201182 P-A-T WO-00201182 Parts …
sanju
  • 3
  • 4
0
votes
1 answer

Long melt output, select for boxplot

I have a large melt output - 4608940, 2, comprising 1000 columns with ca. 4000+ rows. The variable column entries do not have the same number of points. Is there a way to select certain data within the melt to use with ggplot2/boxplot()? Say…
Screamh
  • 39
  • 5
0
votes
0 answers

Why does R think all of my rows end in "e"?

I am trying to create a new column with information from another column. For example, I want "Neutrophil_A0Late" to have "Late" in a new column, and "Neutrophil_A0Peak" to have "Peak" in the new column. My current code is: gene_CNS <-…
0
votes
1 answer

complex restructuring of (already wide) data with items of different length

I want to restructure my data set. Therefore, I need kind of a restructuring from long to wide. The difficulty for me is that I do already have something like a wide format which I would like to make even wider. But therefore I could not find any…
Nadine M.
  • 95
  • 2
  • 10
0
votes
1 answer

Why does melt return NA column in R?

I have the following list df in R: structure(list(disease = structure(c(1L, 1L), .Label = "Barcelona", class = "factor"), `<18` = structure(list(0.193103448275862, 0.0445344129554656), .Names = c(NA_character_, NA_character_ )),…
Daniel
  • 471
  • 3
  • 8
  • 18
0
votes
3 answers

Reshape/Melt data with two rows of variable names

I have a large data set that I need to reshape/melt. The problem that I have is that the first and second row are variable names (i.e., the first row is the id of a person and the second row lists four attributes for this person). In addition to…
TCS
  • 127
  • 1
  • 11