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

How to handle "variable" and "value" in melt reshape2 with Roxygen2

I'm trying a different method to boxplot two population means.I'm using reshape2's melt function which comes inbuilt with 2 columns, variable and value. Below is the code. It works but I get a warning that plot.Rttest: no visible binding for…
0
votes
1 answer

How do you stack rows under a specific column in pandas without using pd.melt?

I'm trying to pivot this table so that columns 1-8 are stacked under column 0. Basically, I want to put this into tableau eventually so I want to have workable data. I'm planning on dropping the "None" values after I pivot the table. I've tried…
Zoey K
  • 1
  • 1
0
votes
0 answers

How to transpose the panel data in python?

Consider the first data structure. I need to transpose it as in the second structure. I tried df.melt and df.pivot_table, but did not work.
OzodBeck
  • 11
  • 2
0
votes
1 answer

find what variables changed per value of another variable

Given the following data.frame: t x y --------- 1 1 3 1 1 3 1 1 2 2 1 2 2 2 2 I would like output of the form t cnt cux cuy --------------- 1 3 1 2 2 2 2 1 where cnt is the count of all rows with a particular…
hoffmanc
  • 614
  • 9
  • 16
0
votes
2 answers

melt data.table using patterns with automated extraction of measure names

Here's example of data and the code to reshape it, with current output: DT <- data.table( parent.name = words[101:103], parent.dob = as.Date(1:3, origin="2020-01-01"), child_boy = words[11:13], child_girl = words[21:23], …
IVIM
  • 2,167
  • 1
  • 15
  • 41
0
votes
0 answers

Transpose a column vector in dataframe to row vector

As titled,I have a dataframe that looks like this: Date Asset_name trade_price 2022-08-01 Asset 1 96 2022-08-01 Asset 2 94 2022-08-01 Asset 3 99 2022-08-01 Asset 4 98 2022-08-01 Asset 5 91 2022-08-02 …
Alex
  • 81
  • 6
0
votes
1 answer

DT::dataTableOutput with table in long form and still having full functionality?

In R Shiny, I have a data table in wide form, let's all this Representation A of the data: Rank Person School 1 Sean Boston 2 Alicia I'm using DT::dataTableOutput to present this table. I want to instead present this table in long…
SimonSimon
  • 47
  • 6
0
votes
2 answers

How to melt a dataframe so repeated items become the values that correspond to the index

I have this dataframe: df = pd.DataFrame({'Status':['CO','AD','AD','AD','OT','CO','OT','AD'], 'Mutation':['H157Y','R47H','R47H','R67H','R62H','D87N','D39E','D39E']}) print(df) Status Mutation 0 CO H157Y 1 AD …
Cam
  • 111
  • 1
  • 8
0
votes
1 answer

How to melt a dataframe with tidyverse, and create a new column

I have pet survey data from 6 households. The households are split into levels (a,b). I would like to melt the dataframe by aminal name (id.var), household (var.name), abundance (value.name), whilst adding a new column ("level") for the levels…
Paul
  • 5
  • 3
0
votes
0 answers

Is there an efficient way to combine dcast, melt and merge on large dataset in R?

I have 4 csv files of 63290 obs and 6 columns each. I transform them into datatable format. I am trying to use dcast and melt on each to create a count variable. But I am getting this error message: cannot allocate vector of size 8.0Gb I will then…
Guyle
  • 1
0
votes
0 answers

Get All Combinations From Two Data Frames with Multiple Columns in R

I've got two data frames, df1 and df2, which both contain 3 columns of genetic data. I am trying to figure out a way to concatenate (merge? multiply?) the data frames to get all possible combinations in a 6-col data frame. For example, if df1 looks…
Doda
  • 285
  • 1
  • 9
0
votes
1 answer

Got stuck while changing data format from wide to long

I am a complete beginner in R. I installed R couple of days ago to complete my course assignment. One of the instructions was that I have to change the data format from wide to long format. The data was a time series data on Remittance inflows from…
0
votes
0 answers

explode function on struct type pyspark

I would like to get the seperate df per level from JSON file. Below code allows me to go 2 level deep but later I cant use explode function due to data type mismatch: input to function explode should be array or map type, not struct error on…
Greencolor
  • 501
  • 1
  • 5
  • 16
0
votes
0 answers

how to merge dataset after applying dcast and melt for occurrence count purposes?

I have a panel dataset of firms with multiple variables. I create one dummy variable treat2 which equals 1 when a given firm takes one action in two consecutive months within a given year and 0 otherwise using dcast. I am looking for a way to…
Guyle
  • 1
0
votes
1 answer

Pandas Melt Dataframe headers into rows

I have a data frame that needs to be converted like so below. I would like to convert the headers accts into their own values in rows while keeping accts grouped together in the "Acct" Column. Understand that melt could achieve this but I am having…
Evan
  • 29
  • 6