Displaying 20 results from an estimated 210 matches similar to: "question about reshape"
2009 Dec 04
0
simple reshape of a large data frame (reshape() runs out of memory)
Hello everyone,
I'm having a problem performing reshape() on a large data frame. The
operation is fairly trivial but it makes R run out of memory.
The data frame has the following structure:
ID DATE1 DATE2 VALTYPE
VALUE
'abcd1233' 2009-11-12 2009-12-23 'TYPE1'
123.45
...
VALTYPE is a string and is a factor with
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 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
2008 Sep 28
1
reshape package does not recognize second id variable
I am trying to use the reshape package for the first time. I have two
waves of a survey, so the id variables include a subject
identification number and a variable denoting the wave of the survey.
I used the following arguments:
library(reshape)
svy.melt <- melt(svy, id=c("id", "WAVE"))
svy.wide <- cast(svy.melt, id ~ WAVE + ...)
and got the following error:
2004 Jun 21
0
reshape speed improvement?
Hi,
have anybody a hint how i can perform my speed for
a big reshape jobs?
My "long" data.frame have dim 1.342.116 3 and the "wide" data.frame
could occur (if i don't filter the timevar) max. in a
246744 x 1444 data.frame with a lot of NA what could be set to 0.
Neverthless i didn't need really 1444 columns
(idependent's for data-mining) , but
2002 Nov 01
1
Reshape function
Can someone help me with the proper usage of the
reshape function?
Let's say I have a dataset with columns like this
(wide format):
Id Sex Group Test Day1 Day 2 Day 3...
And I want to transpose this into something like this
(thin):
Id Sex Group Test Time
Where the new column labeled time contains all the
time variables (Day 1, Day 2, Day 3...) that were in
the wide
2008 Jun 17
1
re sultant column names from reshape::cast, with a fun.aggregate vector
try this:
scores.melt = data.frame(grade = floor(runif(100, 1,10)), variable =
'score', value = rnorm(100));
cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, length))
it has the nice column names of:
grade score_mean score_length
1 1 0.08788535 8
2 2 0.16720313 15
3 3 0.41046299 7
4 4 0.13928356 13
...
but
2012 Jan 18
1
Reshape with multiple aggregate functions
I have a data frame and I would like to reshape it to wide format while at
the same time applying different aggregate functions to each column AND at
times multiple aggregate functions:
test1 = data.frame(
id = c(rep('101',8),rep('102',8)),
phase = rep(c('D','D','L','L'),4),
day =
2011 Aug 20
2
reshape a matrix
Hi all,
I have a data.frame like following
A<-c('d0','d0','d1','d1','d2','d2')
B<-rep(c('control','sample'),3)
C<-c(rep(100000,2),200,300,400,500)
dataframe<-data.frame(A,B,C)
I want to reshape the matrix, so the matrix with 'd0', 'd1' and 'd2' in rows
and 'control' and 'sample'
2008 Jul 30
1
bug in 'margins' behavior in reshape - cast
according to the documentation of the cast function in the reshape function,
I would expect this bit of code from the examples to calculate marginal
means over only the 'diet' variable.
#Chick weight example
names(ChickWeight) <- tolower(names(ChickWeight))
chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE)
cast(chick_m, diet + chick ~ time, mean, margins="diet")
But,
2011 Mar 13
1
install.packages & reshape failure
I'm not sure where I should send this, I don't have a bugzilla account,
but ... it concerns an interaction between library(reshape) and
install.packages() ...
My current .Rprofile includes: library(reshape)
After which install.packages fails ... e.g.,
> install.packages("quantreg")
Warning in install.packages("quantreg") :
argument 'lib' is missing:
2008 Nov 26
1
Reshape with var as fun.aggregate
I used to be able to use variance for fun.aggregate, but since I
upgraded from R 2.6 to 2.7 (Ubuntu hardy to intrepid), it no longer
works.
> library("reshape")
> data("french_fries")
> ffm <- melt(french_fries, id=1:4, na.rm = TRUE)
> cast(ffm, rep ~ treatment, length)
rep 1 2 3
1 1 579 578 575
2 2 580 579 580
> cast(ffm, rep ~ treatment, mean)
2007 Apr 11
0
Reshape and column order
If I try to reshape a data frame into a long format with more than one
column it seems to mix up the column headings (or the columns, depending on
how you look at it). For example:
> d <-
data.frame(row=1:2,b.1=c("1b1","2b1"),b.2=c("1b2","2b2"),a.1=c("1a1","2a1"),a.2=c("1a2","2a2"))
> d
row b.1 b.2 a.1 a.2
1
2006 Apr 06
1
reshape question
Hi,
I have a data fram like this:
date column1 column2 column3 value1 value2 value3
1-1 A B C 10 5 2
2-1 A B D 5 2 0
3-1 A B E 17 10 7
How can I reshape it to:
date column1 column2 column3 v x
1-1 A B C value1 10
1-1 A B C value2 5
1-1 A B C value3 2
2-1 A B D value1 5
2-1 A B D value2 2
2-1 A B D value3 0
3-1 A B E value1 17
3-1 A B E value2 10
3-1 A B E value3 7
Thx!
Regards,
Richard
2018 Jan 25
0
Stats reshape non-Longitudinal Example Correctness
Good day,
In the Examples section of the reshape function documentation is an example that reshapes that data frame state.x77. However, the resulting long data frame doesn't seem correct. It has three columns; Characteristic, Population and state. The second column probably shouldn't be named Population because it stores all of the values for all of the variables and only one of the
2010 Apr 19
1
Formatting data, adding column names, use reshape, a newbie question
Hi all,
I'm an R novice.
I have data that's already formatted as "molten" that reshape should be able
to work with. For example, the following was read in with
read.csv(filename,sep=" ", header=FALSE)
V1 V2 V3 V4
V5
1 original book book.source1.txt 328900494 3039.525
2 original book book.source1.txt
2010 Mar 28
2
installing package reshape and plyr on Debian Lenny
Hi all,
has anyone tried and possibly succeeded in installing "reshape" package on Debian Lenny? I have a permanent failure because i cannot find the "plyr" package. I tried 10 mirrors. I contacted Hadley Wickham and James Long who seemed to have been closed to do it but it didn't work (meaning so far I haven't the answer from them). So has anyone any ideas as how to
2002 Oct 16
1
documentation: Missing paranthesis in reshape.Rd (PR#2170)
Full_Name: Michale Na Li
Version: 1.6.0
OS: i386-linux
Submission from: (NULL) (140.142.172.141)
In src/library/base/man/reshape.Rd, one paranthesis is missing, here is the
patch.
*** reshape.Rd.old 2002-10-15 23:32:25.000000000 -0700
--- reshape.Rd 2002-10-15 23:32:35.000000000 -0700
***************
*** 12,18 ****
idvar = "id", ids = 1:NROW(data),
times =
2012 Nov 14
1
Typo in documentation for reshape?
When I go ?reshape I get told, amongst other things
new.row.names
logical; if TRUE and direction = "wide", create new row names in long
format from the values of the id and time variables.
This seems to me to be illogical, surely it should read direction = "long"?
Reading the code and observing its behaviour I find that (a) the
default for new.row.names is in fact NULL (b)
2019 Oct 29
0
stats::reshape quadratic in number of input columns
Hi R-core,
I have been performance testing R packages for wide-to-tall data reshaping
and for the most part I see they differ by constant factors.
However in one test, which involves converting into multiple output
columns, I see that stats::reshape is in fact quadratic in the number of
input columns. For example take the iris data, which has 4 input columns to
reshape, and the desired output