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

Reshape dataframe and add column index

I have a dataframe that looks like this: df = b e t w e e n [1,] 219 125 125 94 172 109 172 [2,] 78 78 250 156 172 141 140 [3,] 250 204 296 829 265 125 203 [4,] 406 110 172 187 63 156 109 When I melt it,…
Adam_G
  • 7,337
  • 20
  • 86
  • 148
1
vote
1 answer

Pandas: reshape data frame

I have the following data frame: url='https://raw.githubusercontent.com/108michael/ms_thesis/master/crsp.dime.mpl.df' zz=pd.read_csv(url) zz.head(5) date feccandid feccandcfscore.dyn pacid paccfscore cid catcode type_x di …
Collective Action
  • 7,607
  • 15
  • 45
  • 60
1
vote
0 answers

vidstab installed on Ubuntu, Melt can't find it

I am trying to stabilize a shaky video with melt. i have installed the vidstab plugin shown below. :~$ apt-cache search vidstab libvidstab-dev - Video stabilization library. libvidstab1.0 - Video stabilization library. But i don't see melt is…
Danushka Gunawardena
  • 1,109
  • 1
  • 9
  • 17
1
vote
1 answer

Generating horizontal notch plot in ggplot2

I have a data with 3 different disease conditions and several outcomes of them. Diseases are in the first column and outcomes are named from second column on. Please see the data in the attachment. Disease A B C D E F G H X …
Lothlorian
  • 55
  • 2
  • 9
1
vote
1 answer

days in rows and months in columns melt into time series R

I have time series data in the following structure: dat=data.frame("Year"=rep(2005,31), "Day"=seq(1:31), "JANUARY"=sample(seq(1:100),31,T), "FEBRUARY"=c(sample(seq(1:100),28),NA,NA,NA), …
slap-a-da-bias
  • 376
  • 1
  • 6
  • 25
1
vote
1 answer

Dimension Mismatch using melt() in reshape2

I am trying to melt a data frame from 'wide' format to 'long' format in R, using the function 'melt' in the package 'reshape2'. However, I am encountering an issue with dimensions when trying to view the output data frame which I am having trouble…
Sam Zipper
  • 642
  • 1
  • 7
  • 19
1
vote
0 answers

node-mlt - setting argument for watermark

I have get project where server get json file and media file and convert to xml. Server use mlt with node-mlt lib. My task is add watermark. I did it, but I can't find any description for node-mlt method arguments except URL to file. node-mlt have…
1
vote
0 answers

tidyr::gather observations from multiple sets of columns of different types

How can I transform a dataset in "wide" format that has sets of columns of different types, into "long" format, as in the example bellow? Preferably using tidyr (and dplyr, etc) or some equally simple syntax. d_wide <- data.frame( …
LucasMation
  • 2,408
  • 2
  • 22
  • 45
1
vote
2 answers

Select top row melted data after sorting by value

I have the following melted data: dat.melt <- structure(list(CellTypes = structure(c(62L, 35L, 73L, 45L, 14L, 22L, 46L, 13L, 68L, 21L, 1L, 10L, 64L, 24L, 72L, 58L, 51L, 9L, 60L, 37L, 34L, 49L, 33L, 2L, 50L, 32L, 11L, 52L, 44L, 66L, 8L, 5L, 47L,…
neversaint
  • 60,904
  • 137
  • 310
  • 477
1
vote
1 answer

Reshape/Cast data frame - create new columns based on variable and multiple values

I have the following example dataframe that I need to reshape but am not able to use the reshape or cast functions to do what I need to df Testee Gender UniqueIdentifier BirthYear Graph V1 V2 V3 V4 1 7685906 1 33448683-29373 1996 …
1
vote
0 answers

R: "undefined columns selected" error after check.names=FALSE?

Brand new to R; trying to get my data read in and reshaped properly. File format has seven columns of "id"-ish data, then about sixty columns of annual growth values, columns labelled by year. First pass was: > firstData <-…
uhClem
  • 95
  • 10
1
vote
0 answers

Turn two-column dataframe with duplicate identifiers from long to wide, preserving scores

The problem and the desired outcome I've got a data set like the toy data here: mydf<- data.frame( id = c("AB","AB","AB","BB","BB","CD","CD","CD","CD","ED"), score = c(4,2,1,2,2,1,5,6,3,5)) And what I'd like to end up with as a data frame or…
Steve'sConnect
  • 145
  • 2
  • 8
1
vote
0 answers

reshape2: dcast margin behavior

I'm writing to ask for help understanding a behavior of reshape2::dcast that is confusing me. When I run the following four lines (the example dataset 'french_fries' comes with the 'reshape2' package), I get three data.frames with different…
DM1
  • 11
  • 2
1
vote
1 answer

Simple "R-like" melt : better way to do?

Today I tried to implement a "R-like" melt function. I use it for Big Data coming from Big Query. I do not have big constraints about time to compute and this function takes less than 5-10 seconds to work on millions of rows. I start with this kind…
Joseph Yourine
  • 1,301
  • 1
  • 8
  • 18
1
vote
1 answer

Converting specific cells of data frame to table in R

I have a data frame (read from RDS file) with 140 variables. I have subsetted 3 of them. But the subset has only one row with three column variables. I have to present it as a table and make a bar chart too. The subset data frame looks like…
LeArNr
  • 635
  • 1
  • 6
  • 12