reshape2 Questions

3

Solved

Say I have a dataframe df with dozens of identifying variables (in columns) and only a few measured variables (also in columns). To avoid repetitively typing all the variables for each argument, ...
Rafaelle asked 12/2, 2015 at 18:8

4

Solved

Suppose I have a 3-dimensional array g with dimensions [x,y,z]. reshape2::melt(g) would produce a data frame with columns giving indices of x,y,z and value where value contains the values in each e...
Flyfish asked 25/8, 2022 at 17:4

4

Solved

Forword: I provide a reasonably satisfactory answer to my own question. I understand this is acceptable practice. Naturally my hope is to invite suggestions and improvements. My purpose is to plo...
Chignon asked 24/10, 2015 at 12:48

4

Solved

I don't know whether this is an integer64 (from bit64) problem, or a melt problem (from reshape2, but if I try to reshape a data.frame containing integer64 data then the class information is destro...
Resentment asked 15/2, 2013 at 10:37

2

Solved

I have a survey file in which row are observation and column question. Here are some fake data they look like: People,Food,Music,People P1,Very Bad,Bad,Good P2,Good,Good,Very Bad P3,Good,Bad,Good...
Scald asked 10/8, 2013 at 3:50

3

How do I specify the column order, based on column 'Col' when using dcast? df <- dcast(x, ID ~ ColumnName, value.var = "Answer") I need the solution to be non specific to the data as x can be...
Kilkenny asked 5/9, 2018 at 17:36

3

Solved

I'm trying to pivot to a longer format using dplyr::pivot_longer, but can't seem to get it to do what I want. I can manage with reshape::melt, but I'd also like to be able to achieve the same using...
Carolus asked 12/1, 2022 at 14:27

8

Solved

I have a dataframe in a wide format, with repeated measurements taken within different date ranges. In my example there are three different periods, all with their corresponding values. E.g. the fi...
Transported asked 17/9, 2012 at 20:17

3

Solved

I love the reshape2 package because it made life so doggone easy. Typically Hadley has made improvements in his previous packages that enable streamlined, faster running code. I figured I'd give ti...
Legibility asked 23/10, 2014 at 19:51

2

My df looks like this: Id Task Type Freq 3 1 A 2 3 1 B 3 3 2 A 3 3 2 B 0 4 1 A 3 4 1 B 3 4 2 A 1 4 2 B 3 I want to restructure by Id and get: Id A B … Z 3 5 3 4 4 6 I tried: df_wide <- dca...
Converse asked 10/10, 2015 at 7:17

2

Solved

Happy Weekends. I've been trying to replicate the results from this blog post in R. I am looking for a method of transposing the data without using t, preferably using tidyr or reshape. In ex...
Karonkaross asked 7/3, 2015 at 16:26

3

Solved

I would like to convert a matrix/array (with dimnames) into a data frame. This can be done very easily using reshape2::melt but seems harder with tidyr, and in fact not really possible in the case ...
Minyan asked 15/8, 2018 at 20:58

4

Solved

I was trying to use ggplot2 to plot the built-in anscombe data set in R (which contains four different small data sets with identical correlations but radically different relationships between X an...
Yeomanry asked 8/11, 2015 at 22:18

7

Edit -- This question was originally titled << Long to wide data reshaping in R >> I'm just learning R and trying to find ways to apply it to help out others in my life. As a test case, I'...
Dunston asked 3/5, 2013 at 20:57

1

Solved

I have a program that uses reshape2's melt function to melt a 5-dimensional array with named and labelled dimensions to a long-form data frame, which by definition has only two dimensions. Each dim...
Bare asked 8/8, 2020 at 3:1

3

Solved

I have a list of lists that have names. I want to add them all together into a dataframe but keep all the columns past_earnings_lists[1] successfully returns one list from the list of lists names(...
Astrometry asked 19/9, 2017 at 21:53

3

Solved

RStudio was crashing when I tried to reshape a particular data frame using dcast (from the reshape2 package). I discovered that the crash was actually happening in R itself, so I ran my casting cod...
Meiny asked 5/3, 2013 at 18:31

3

Solved

I'm trying to use dcast from the latest reshape2 package (1.2.1) to denormalize a data frame (or data.table) where the value.var is a POSIXct type, but in the resulting data frame, the date values ...
Hamill asked 5/9, 2012 at 21:2

3

Solved

I am relatively new to R and have data in wide format as follows subject_id age sex treat1.1.param1 treat1.1.param2 treat1.2.param1 treat1.2.param2 ------------------------------------------...
Sylas asked 24/1, 2020 at 7:16

4

Solved

I'm using ggplot2 to do a boxplot comparison of two different species, as indicated by the third column shown below: > library(reshape2) > library(ggplot2) > melt.data = melt(actb.raw.dat...
Korfonta asked 21/6, 2013 at 16:55

5

Solved

I am trying to convert the following format: mydata <- data.frame(movie = c("Titanic", "Departed"), actor1 = c("Leo", "Jack"), actor2 = c("Kate", "Leo")) movie actor1 actor2 1 Titanic Leo...
Bari asked 27/8, 2013 at 20:32

3

Solved

I have the following dummy data: library(dplyr) library(tidyr) library(reshape2) dt <- expand.grid(Year = 1990:2014, Product=LETTERS[1:8], Country = paste0(LETTERS, "I")) %>% select(P...
Rundlet asked 24/7, 2014 at 9:27

2

Solved

I have a program that gives me data in this format toy file_path Condition Trial.Num A B C ID A B C ID A B C ID 1 root/some.extension Baseline 1 2 3 5 car 2 1 7 bike 4 9 0 plane 2 root/thing.exte...
Buchenwald asked 18/1, 2017 at 20:2

4

Solved

I am trying to obtain counts of each combination of levels of two variables, "week" and "id". I'd like the result to have "id" as rows, and "week" as columns, and the counts as the values. Example...
Selfrespect asked 18/11, 2011 at 17:7

1

Is there a function similar to melt in SparkR library? Transform data with 1 row and 50 columns to 50 rows and 3 columns?
Superabundant asked 12/10, 2018 at 15:19

© 2022 - 2025 — McMap. All rights reserved.