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
0 answers

Transposing Specific columns of a data frame in R

I would like to transpose a set of columns in my data frame a. without needing to explicitly identifying the transposed column names in the script (there are >900) AND b. with the transposed columns being of varied data types My data is horribly…
D Note
  • 1
  • 1
0
votes
0 answers

R: Melt with data.table into two columns

I would like to convert a data.table from wide to long format. A "normal" melt works fine, but I would like to melt my data into two different columns. I found information about this…
Roland
  • 131
  • 7
0
votes
3 answers

how to melt a dataframe -- get the column name in the field of melt dataframe

I have a df as below name 0 1 2 3 4 0 alex NaN NaN aa bb NaN 1 mike NaN rr NaN NaN NaN 2 rachel ss NaN NaN NaN ff 3 john NaN ff NaN NaN NaN the melt function should return the…
potentialwjy
  • 133
  • 1
  • 3
  • 8
0
votes
1 answer

R - ggplot2 - plots and aes depending on multiple variables creates zigzag despite monotone data

I am given a table of prices depending on the year and various parameters. structure(list(Year = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L,…
Strickland
  • 590
  • 4
  • 14
0
votes
1 answer

R ggplot : loop over data frame source

I would like to plot 100 graphs corresponding to 100 data series in one single plot. To be more precise, I have a list ( name : ROC.df) containing 100 elements where each element is a data frame (name : df) including two columns POD and POFD. I want…
Basilique
  • 150
  • 1
  • 11
0
votes
1 answer

reshape a matrix in R and converting every n rows into one row

I have a data frame df like: year location 1 A 2 B 3 C ------------------ 1 X 5 A 10 F ------------------ 3 F 5 x 2 y I would like to reshape it to year_1 …
OverFlow Police
  • 861
  • 6
  • 23
0
votes
1 answer

How can I make a pivot_table with categorical values?

I have four categorical columns In the following code. Can I do a pivot with values (categorical column)? df.pivot_table(index=['DATE','COUNTRY'],columns='METRIC',values='VALUE',dropna=True).reset_index() I have the next error: DataError: No…
Hugo Coras
  • 35
  • 6
0
votes
1 answer

Split column into multiple columns based on variable

I'm brand new to python and data science, and I have a dataframe which is WellID x y rho1 rho2 rho3 ... rho5 dep1 dep2 dep3 dep4 dep5 0 1 5 3 44 67 34 ... 65 0 1 2 3 4 1 2 1 6 87 …
bogey992
  • 3
  • 2
0
votes
2 answers

Data transformation from columns to rows in r

I have a dataframe in this way 1954 <- c(a,b,c,d)#names of a person X2 <- c(5,6,1,2)#their score 1955 <- c(e,f,g,h) X3 <- c(2,4,6,9) 1956 <- c(j,k,l,m) X4 <- c(1,3,6,8) Girls <- data.frame(1954,X2,1955,X3,1956,X4) Girls dataframe looks something…
0
votes
2 answers

Matching columns in data set with its class, similar to VLOOKUP

I have a large data set which the head of it looks like this: Time Company 1 Company 2 ... Company 12 Company 13 Company 14 0 1/01/2015 49 19 ... 80 56 61 1 2/01/2015 2 …
user11015000
  • 151
  • 1
  • 15
0
votes
1 answer

How do I apply the same action to all Excel Files in the directory?

I need to shape the data stored in Excel files and save it as new .csv files. I figured out what specific actions should be done, but can't understand how to use lapply. All Excell files have the same structure. Each of the .csv files should have…
Oleg
  • 25
  • 4
0
votes
1 answer

How to "unmelt" data with multiple variables?

I am trying to clean this dataset and the original data is formatted terribly. This is the format that the original data came in: PATIENT_CODE PATIENT_NAME TEST TEST_RESULT 1 JOHN SMITH URIC ACID 5 1 …
Carmen
  • 11
0
votes
1 answer

Plotting multiple X variables for one continuous Y variable in a single plot

I am trying to draw a line plot having two x variables in the x-axis with one continuous y variable in the y-axis. The count of x1 and x2 are different. The df looks like the following- df <- structure(list(val =…
temp
  • 82
  • 1
  • 10
0
votes
0 answers

Unable to get dCast to work - Aggregate function missing: default to length

I have tried solutions from multiple posts on stackoverflow, but haven't had any success. If you think this is a duplicate, it's not. I have already referred to this post and this post. > head(t) locality_id observer_id observation_date…
Vijay Ramesh
  • 191
  • 1
  • 2
  • 20
0
votes
2 answers

Changing 4 columns in only 1

I am trying to convert 4 colunms from my DataFrame to a unique column. I have the following DataFrame: doggo floofer pupper puppo 0 None None None None 1 None None None None 2 None None None None 3 None …
Leandro Baruch
  • 117
  • 2
  • 11