Displaying 20 results from an estimated 57 matches for "unstacking".
Did you mean:
stacking
2009 Nov 15
1
Help with unstack() function
Hi Everyone,
I am trying to understand the unstack() function but after struggling for
two days, I have given up. More specifically, I am trying the exercises at
the end of Chapter 1 of Data Analysis and Graphics Using R by Maindonald
and Braun, 2nd ed. Exercise 18 (p. 41) asks to unstack the Rabbit data frame
from the MASS package to get a certain data frame that is shown in the
exercise.
2004 Mar 19
2
using "unstack" inside my function: that old scope problem again
I've been reading the R mail archives and I've found a lot of messages
with this same kind of problem, but I can't understand the answers. Can
one of you try to explain this to me?
Here's my example. Given a regression model and a variable, I want to
use unstack() on the vector of residuals and make some magic with the
result. But unstack hates me.
PCSE <- function
2011 Mar 12
1
Column order in stacking/unstacking
...(testdat)
> stacked
values ind
1 1 X1
2 2 X1
3 3 X1
4 4 X1
5 5 X1
6 1 X2
7 2 X2
8 3 X2
9 4 X2
10 5 X2
11 1 X10
12 2 X10
13 3 X10
14 4 X10
15 5 X10
But the problem I have comes in unstacking, when the order of the columns is
changed from the original, to something alphabetical (i.e. X10 goes before
X2):
> unstacked <- unstack(stacked)
> unstacked
X1 X10 X2
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
Maintaining the order of columns is very impo...
2010 Oct 18
1
questions on unstack()
Folks,
I have the following dataframe:
> x <- structure(list(name = c("EU B", "EU B", "EU B", "EU B", "EU B",
"EU B", "AU A", "AU A", "AU A", "AU A", "AU A", "AU A"), date = c("2010-10-11",
"2010-10-12", "2010-10-13",
2016 Jun 27
1
stack problem
One would normally want the original order that so that one can stack
a list, operate on the result and then unstack it back with the
unstacked result having the same ordering as the original.
LL <- list(z = 1:3, a = list())
# since we can't do s <- stack(LL,. drop = FALSE) do this instead:
s <- transform(stack(LL), ind = factor(as.character(ind), levels = names(LL)))
unstack(s)
2011 Sep 26
1
Restructuring data - unstack, reshape?
Hi all,
I'm having a problem restructuring my data the way I'd like it. I have data
that look like this:
Candidate.ID Specialty Office Score
110002 C London 47
110002 C East 48
110003 RM West 45
110003 RM
2005 Oct 22
0
Getting univariate information from a multivariate data set
A quick question that I've had only partial success in answering. I
have a multivariate dataset, and would like to extract some simple
univariate information from it grouped by treatments, etc. I am
encountering two problems however
Note: I am importing my data with
my_data <- read.csv("/path/data.csv")
1) Scoping of unstack
If I attempt
sorted_data <- unstack(response,
2007 Jul 15
1
Restructuring data
...that I
would appreciate an easy solution if there is any.
The current data structure (variable names):
ID, TIME, BUY-A, BUY-B, SELL-A, SELL-B
Achieved structure (with the reshape command or the reshape package)
ID, TIME, BUY-A
ID, TIME, BUY-B
ID, TIME, SELL-A
ID, TIME, SELL-B
This is regular unstacking with two identifier variables. Nothing special
though. What I am looking for and did not manage is the following structure:
ID, TIME, BUY-A, SELL-A
ID, TIME, BUY-B, SELL-B
I am quite sure it's pretty easy, but I could not find how to do this.
Thanks a bunch,
Daniel
2006 Dec 30
1
Crosstab from sql dump
Hello all,,
Im looking for a simple function to produce a crosstab from a dumped
sql query result. Its very hard to produce crosstabs with most
databases (Access being the exception), so with the vast array of R
packages, Im sure this has to have already been implemented somewhere.
Examples are always good:
Take a csv dump like
name code
user1 100
user2 100
user1 200
user2 210
user1 300
user2
2016 Jun 27
2
stack problem
stack() seems to drop empty levels. Perhaps there could be a
drop=FALSE argument if one wanted all the original levels. In the
example below, we may wish to retain level "b" in s$ind even though
component LL$b has length 0.
> LL <- list(a = 1:3, b = list())
> s <- stack(LL)
> str(s)
'data.frame': 3 obs. of 2 variables:
$ values: int 1 2 3
$ ind : Factor
2012 Mar 20
2
Reshaping data from long to wide without a "timevar"
Hello All,
I was wondering if it's possible to reshape data from long to wide in R without using a "timevar". I've pasted some sample data below along with some code. The data are sorted by Subject and Drug. I want to transpose the Drug variable into multiple columns in alphabetical order.
My data have a variable called "RowNo" that functions almost like a
2010 Jun 07
2
Computing day-over-day log return for a matrix containing multiple time series
Hi all,
Thanks a lot for anyone's help in advance.
I am trying to find a way to compute the day-to-day return (log return) from
a n x r matrix containing, n different stocks and price quotes over r days.
The time series of prices are already split by using unstack function.
For the result, I would like to see a n x (r-1) matrix, where by each entry
is the day-over-day return of
2009 May 18
1
error in importing text files
Hello All:
I am very new to R and am trying to import some (107) text files into R while simultaneously manipulating the data into a structure that I can use. Below is a description of what I am trying to ultimately accomplish. However, I find that I am unable to even read one file into R using the read.table function. I get the following error:
> test<-read.table("test4.txt")
2005 Dec 09
3
R-how to group the data
Hello R - users,
This may sound simple to may people:
I have a list of data as follows
type value
y 7
y 7
y 8
y 8
y 8
y 9
y 9
y 9
y 9
y 10
y 10
y 10
y 10
y 11
y 11
y 12
y 12
y 14
y 14
y 14
y 15
y 17
y 20
y 20
y 20
y 20
y 25
2006 Jun 26
2
reshaping data.frame question
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dear R-helpers,
my data.frame is of the form
x <- data.frame( f=gl(4,3), X=rep(0:2,4), p=c(.1,.2,.3))
x
f X p
1 1 0 0.1
2 1 1 0.2
3 1 2 0.3
4 2 0 0.1
5 2 1 0.2
6 2 2 0.3
7 3 0 0.1
8 3 1 0.2
9 3 2 0.3
10 4 0 0.1
11 4 1 0.2
12 4 2 0.3
which tabulates some values p(X) for several factors f.
Now I want to put it in "wide"
2013 Apr 30
3
Line similarity
Folks,
This is probably a "help me google this properly, please"-type of question.
In TIBCO Spotfire, there is a procedure called "line similarity". I use this to determine which observations show a growing, stable or declining pattern... sort of like a mini-regression on the time-line for each observation.
So of the input is
2006 Aug 08
0
(Fwd) Re: paired t-test. Need to rearrange data?
------- Forwarded message follows -------
From: Petr Pikal <petr.pikal at precheza.cz>
To: Henrik Parn <henrik.parn at bio.ntnu.no>
Subject: Re: [R] paired t-test. Need to rearrange data?
Date sent: Tue, 08 Aug 2006 16:13:47 +0200
Hi
Uff, it takes me a bit headache but this shall do it
?unstack
?table
?t
new.list<-unstack(test.data,y~id)
2006 Oct 27
0
problem with applying regul function (pastecs)
Hi,
I'm trying to analyse some time series data on dissolved organic
nitrogen. Because it has gaps in it, I try to interpolate (linear) with
the regul method from the pastecs package.
I have a number of stations with measurement series in a matrix
constructed from a data frame with the unstack method (temp)
I also used the unstack method to make a similar matrix for the time
points
2007 May 18
0
Is formula(data.frame) documented?
The Examples section of 'unstack' includes:
formula(PlantGrowth) # check the default formula
I wanted to add a formula to my own data.frame (for unstacking), so I
start looking:
?formula # Nothing here about adding a formula to data
attr(PlantGrowth, "formula") # Nothing here--c.f. groupedData objects
dput(PlantGrowth) # Hmm, no formula here either
?formula.data.frame # Aliased to formula. Growing more frustrated.
After more experimentati...
2008 Aug 12
1
which(df$name=="A") takes ~1 second! (df is very large), but can it be speeded up?
Dear All,
I have a large data frame ( 2700000 lines and 14 columns), and I would like to
extract the information in a particular way illustrated below:
Given a data frame "df":
> col1=sample(c(0,1),10, rep=T)
> names = factor(c(rep("A",5),rep("B",5)))
> df = data.frame(names,col1)
> df
names col1
1 A 1
2 A 0
3 A 1
4 A