Displaying 20 results from an estimated 57 matches for "unstack".
Did you mean:
onstack
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 certai...
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 (tmodel,groupVar) {
myres1 <- resid(tmodel)
resUnstacked <- unstack(myres1, form = myres1 ~ groupVar));
E <- as.matrix(resUnstacked)
SIGMA <- (1/nrow(E))*(t(E) %*% E)...
2011 Mar 12
1
Column order in stacking/unstacking
Dear R users,
I'm having some problems with the stack() and unstack() functions, and
wondered if you could help.
I have a large data frame (400 rows x 2000 columns), which I need to reduce
to a single column of values (and therefore 800000 rows), so that I can use
it in other operations (e.g., generating predictions from a GLM object).
However, the problem I...
2010 Oct 18
1
questions on unstack()
...2010-10-18 1.3992 1.3917
9 AU A 2010-10-11 0.9864 0.9859
10 AU A 2010-10-12 0.9859 0.9842
11 AU A 2010-10-13 0.9842 0.9919
12 AU A 2010-10-14 0.9919 0.9925
13 AU A 2010-10-15 0.9925 0.9907
16 AU A 2010-10-18 0.9901 0.9881
I'm trying to collapse the frame so that I get columns of names:
> unstack(x, Jem ~ name)
AU.A EU.B
1 0.9864 1.3924
2 0.9859 1.3888
3 0.9842 1.3867
4 0.9919 1.3949
5 0.9925 1.4054
6 0.9901 1.3992
Three questions:
1. The column names are converted from "EU B" to "EU.B" - how to preserve the original names?
2. The column names are sorted alphabe...
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)
On Mon, Jun 27,...
2011 Sep 26
1
Restructuring data - unstack, reshape?
...apply for the same job specialty in up to 2 offices (never
more). They can apply for different specialties in further centres. I
would like to look at score differences when candidates apply for the same
specialty in two different offices. With the help of the archives I have
tried various stack/unstack and reshape/melt/cast combinations, and I've
managed to get a huge matrix where the columns are all possible combinations
of Specialties & Offices - and there are many. This leaves a very sparse
matrix with mainly null values, and this is not what I want. I'd like the
scores from the...
2005 Oct 22
0
Getting univariate information from a multivariate data set
...rtial 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, response ~ treatment, data=my_data)
I get
Error in unstack(response, response ~ treatment, data=my_data): Object
response not found
However, if I first use attatch(my_data) and drop the data statement in
unstack, I'm fine. This is all wel...
2007 Jul 15
1
Restructuring data
Hi folks,
I am new to the list and relatively new to R. I am trying to unstack data
"arraywise" and could not find a convenient solution yet. I tried to find a
solution for the problem on help archives. I also tried to use the reshape
command in R and the reshape package but could not get result. I will
illustrate the case below, but the real dataset is quite large...
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"
...xel appears in Drug.2 and Erlotinib appears in Drug.3 when it should be the other way around.
The next two bits of code represent a couple of other things I've tried. The cast function almost works but unfortunately makes a separate column for each drug (at least the way I'm using it). The unstack function works almost perfectly but to my surprise creates a list instead of a dataframe (which I understand is a different kind of list). Thought it might take a single line of code to convert the former structure to the latter but this appears not to be the case.
So can I get what I want without...
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 each stock.
I tried to look into the zoo package, however it seems to give only the
plots but not the actual data.
Would apply function work in this case?
Thanks a lo...
2009 May 18
1
error in importing text files
...y moving a slider on a 100 point scale. The palms recorded the date, time, palm pilot ID number, response to the beep (non-response = -32767), question number, response latency in milliseconds, response to each question, and three addtiional data points of no interest. The data are arranged in an unstacked (long) text file such that each line contains all of the above information and there are 34 (32 responses plus 2 extra lines of meaningless data) lines per measurement occasion (upto 850 lines of data if all 34 lines are present for all 25 measurment occasions). Below is an example of how the dat...
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
...evels appear as
column heads. Note also that X starts from zero. It would be nice if I
could simply access p_f[X==0] as f[0]. How can I possibly do that?
(The resilting object does not have to be a data.frame. As there are
only numeric values, also a matrix would do.)
I tried the following
y<-unstack(x,form=p~f)
row.names(y) <- 0:2
y
X1 X2 X3 X4
0 0.1 0.1 0.1 0.1
1 0.2 0.2 0.2 0.2
2 0.3 0.3 0.3 0.3
Now, how to access X3[0], say?
Maybe reshape would be the right tool, but I could not figure it out.
I appreciate your help. Thanks!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2....
2013 Apr 30
3
Line similarity
...So of the input is something like this:
Name Year_1_value Year_2_value Year_3_value
A 1 2 3
B 2 7 19
C 3 4 2
D 10 7 6
E 4 4 5
F NA 3 6
Then the desired output is as follows:
A Growing
B Growing
C Stable
D Declining
E Stable
F Growing (or NA is also fine)
The data can also be unstacked, i.e. the three years could be separate rows if necessary.
Is there a package for R that implements something like the above? I can obviously try do a set of simple regressions to classify the rows, but I want to gain from the thoughts and learnings of others who may have taken th...
2006 Aug 08
0
(Fwd) Re: paired t-test. Need to rearrange data?
...-
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)
new.test.data<-t(as.data.frame(new.list[table(test.data$id)>1]))
# if you have more than 2 catches you need to modify this^^^
t.test(new.test.data[,1], new.test.data[,2], paired=T)
HTH
Petr
On 7 Aug 2006 at 16:43, Henrik Parn wrote:
Date se...
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 (time)
Now I have two matrices with the names of the stations as column
headers. The form is the same (35 cols, 192 rows) but the first one has
time points and the other the actual measurements.
I wo...
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...
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