Displaying 20 results from an estimated 9000 matches similar to: "melt with complications"
2012 Oct 17
1
Comparing dcast and reshape
I'm in the middle of my own little intellectual exercise comparing
dcast() and reshape() and have successfully stumped myself. I want to
melt() a data frame, then dcast() it into a new form. After doing so, I
want to duplicate the process using reshape().
So far, I can do the melt and cast
require(reshape2)
Raw <- data.frame(site = c(1, 1, 1, 1, 2, 2, 2, 2),
id =
2012 Jul 25
2
reshape -> reshape 2: function cast changed?
Hi,
I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before.
What I did/want to do:
1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far:
dfm <- melt(df, measure.vars=n, variable_name = "species", na.rm = FALSE)
2) Recast the
2012 Aug 07
3
reshape2's dcast() Adds NAs to Data Frame
I need to understand how and why dcast() adds NAs to a data frame that
contained no missing values.
The database table of chemical concentrations has all missing values
removed because they cannot contribute to data analyses. The structure of
the R data frame of these data have no NA values, and neither does the data
frame resulting from applying the reshape2 melt() function to it. However,
2012 Jul 24
3
Simple reshape problem I am completely missing
I seem to be doing something really stupid or missing something really obvious but what?
I have a simple three column data.frame that I would like to reshape to wide preferably using reshape2.
An example from http://stackoverflow.com/questions/9617348/reshape-three-column-data-frame-to-matrix looked perfect except I wanted a data frame but it seemed okay. I just changed acast to dcast and it
2011 Oct 27
2
Syntax Check: rshape2 melt()
This is my first excursion into using reshape2 and I want to ensure that
the melt() function call is syntactically correct.
The unmodifed data frame is organized this way:
head(tds.anal)
site sampdate param quant
1 UDS-O 2006-12-06 TDS 10800
4 STC-FS 1996-06-14 Cond 280
7 UDS-O 2007-10-04 Mg 1620
9 UDS-O 2007-10-04 SO4 7580
19 JCM-10B 2007-06-21 Ca 79
20
2001 Dec 27
3
reshape error in 1.4 (PR#1231)
Full_Name: Kevin Wright
Version: 1.4
OS: Windows 95
Submission from: (NULL) (170.54.59.160)
Note: This was the 1.4 build for Windows that Brian Ripley made available.
The first example in the help for reshape doesn't work for me. When I cut and
paste, this is what happens:
> data(Indometh,package="nls")
> summary(Indometh)
Subject time conc
2012 Mar 19
0
Reshape data frame with dcast and melt
Hello,
I implemented two functions reshape_long and reshape_wide (see full working
example below) to reshape data frames.
I created several small examples and the two functions seemed to work
properly. However, using the reshape_wide function
on my real data sets (about 200.000 to 300.000 rows) failed. What happens is
set all values for X, Y and Z were set to 1.
The structure of my real data
2011 Oct 31
1
reshape2: Lost Values Between melt() and dcast()
Working with 5 subset streams from my source data frame, three of them
successfully call dcast(), but two fail:
jerritt.cast <- dcast(jerritt.melt, site + sampdate ~ param)
Aggregation function missing: defaulting to length
and
winters.cast <- dcast(winters.melt, site + sampdate ~ param)
Aggregation function missing: defaulting to length
Yet both data frames have the values in their
2013 Jan 04
3
help "reshaping" dataframe
List,
I want to reshape my data, but I'm not sure how to do it... it might be a
simple task, but don't know which package does this.
"occ.data" (see below) is how my original data are arranged, and I know
that with melt() I can reshape it like "y" (see below). However, I just
want to build a matrix like the "y" matrix, but with only 2 dimensions.
Something
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All
I have a datafram which looks like this :
CustomerID DietType
1 a
1 c
1 b
2 f
2 a
3 j
4 c
4 c
4 f
And I would like to reshape this so I can
2011 Jan 19
2
Reshape
Hi - I'm up against a complicated reshape problem. I have data of the form
X1,Y1,hr1,hr2,hr3
X1,Y2,hr1,hr2,hr3
X1,Y3,hr1,hr2,hr3
X2,Y1,hr1,hr2,hr3
X2,Y2,hr1,hr2,hr3
X2,Y3,hr1,hr2,hr3
where X and Y are factors and the hr(1,2,3) are values. I need it as
,X1, X2
Y1,hr1,hr1
Y1,hr2,hr2
Y1,hr3,hr3
Y2,hr1,hr1
Y2,hr2,hr2
Y2,hr3,hr3
..,
Any hints? I've been at it for hours.
p
--
View
2011 Sep 09
4
reshape data from long to wide format
This is my reproducible example:
example<-structure(list(SENSOR = structure(1:6, .Label = c("A", "B", "C",
"D", "E", "F"), class = "factor"), VALUE = c(270, 292.5, 0, 45,
247.5, 315), DATE = structure(1:6, .Label = c(" 01/01/2010 1",
" 01/01/2010 2", " 01/01/2010 3", " 01/01/2010
2006 Feb 22
1
unused factor levels in reshape
When reshaping a dataframe in which there are unused factor levels in the id variable, I get the following error:
Error in if (!all(really.constant)) warning(gettextf("some constant variables (%s) are really varying", :
missing value where TRUE/FALSE needed
For example,
> df <- data.frame(i = factor(rep(1:5, each = 2)), t = factor(rep(1:2, 5)), x = rep(rbinom(5, 1,
2011 Dec 23
2
cast in reshape and reshape2
> library(reshape2)
> x = melt(airquality, id=c('month', 'day'))
With reshape I can cast with multiple functions:
> library(reshape)
> cast(x, month+variable~., c(mean,sd))
month variable mean sd
1 5 ozone 23.615385 22.224449
2 5 solar.r 181.296296 115.075499
3 5 wind 11.622581 3.531450
4 5 temp 65.548387
2010 Feb 06
3
melt on OSX ignores na.rm=T
Hi list,
I run R on Linux and OSX. On both systems I use R version 2.9.2 (2009-08-24)
and reshape version: 0.8.2 (2008-11-04). When I do a melt with
na.rm=T on a data frame I get different results on these systems:
library(reshape)
x <- read.table(textConnection("char trial wn
p E10I13D0 4
r E10I13D0 4
a E10I13D0 4
c E10I13D0 4
t E10I13D0 4
i E10I13D0 4
c E10I13D0 4
e E10I13D0
2011 Mar 12
2
how to use melt cast commands in R in window7
Hi,
I have installed R on my computer with windows 7 . I also installed reshape
software, but I am not being able to work with melt cast commands . I have
chjecked the commands.It is not working.
Thankyou,
Deepika
[[alternative HTML version deleted]]
2010 Jun 18
3
inverse function of melt
Dear list,
I'm looking for an inverse function of melt(which is in package reshape).Namely, I had a data frame like this
(Table1)
YEAR VAR1 VAR2 VAR3
1995 7 3 45
1996 5 6 32
1997 6 10 15
I transformed my data by using the melt function and my data was reshaped in the following format:
(Table2)
YEAR variable
2013 Jan 22
4
Simple use of dcast (reshape2 package)
Suppose I have a small dataframe
> aa
Target Eaten ID
50 TPP 0 1
51 TPP 1 2
52 TPP 3 3
53 TPP 1 4
54 TPP 2 5
50.1 GPA 9 1
51.1 GPA 11 2
52.1 GPA 8 3
53.1 GPA 8 4
54.1 GPA 10 5
And I want to reshape it into
ID TPP GPA
1 1 0 9
2 2 1 11
3 3 3 8
4 4 1 8
5 5 2 10
I realise that
2012 May 07
2
how to deduplicate records, e.g. using melt() and cast()
Esteemed UseRs,
This must be embarrassingly trivial to achieve with e.g., melt() and
cast(): deduplicating records ("pw.X" in example) for a given set of
responses ("cond.Y" in example).
Hopefully the runnable example shows clearly what i have and what i'm
trying to convert it to. But i'm just not getting it, ?cast that is! So
i'd really appreciate some ones
2012 Nov 17
3
Reshaping a dataframe
Seems like this should be easy but I'm struggling a bit. How do I rearrange a
data frame to go from the first one to the second shown below ?
State Date lbs
TX 200701 400
TX 200702 650
TX 200703 950
TX 200704 1000
FL 200701 200
FL 200702 300
FL 200703 500
FL 200704 333
NJ 200701 409
NJ 200702 308
NJ 200703 300
NJ 200704 800
Date TX FL NJ
200701 400 200 409
200702 650