similar to: "aggregate" in R

Displaying 20 results from an estimated 20000 matches similar to: ""aggregate" in R"

2011 Feb 22
4
identify an element in a column
Hi, R users, I'm wondering if I can identify an element in a column by an element in another column. For example: x<-1:10 y<-11:20 z<-cbind(x,y) z x y [1,] 1 11 [2,] 2 12 [3,] 3 13 [4,] 4 14 [5,] 5 15 [6,] 6 16 [7,] 7 17 [8,] 8 18 [9,] 9 19 [10,] 10 20 What I want to do is: when x=5, y=y-1 Anyone can tell me how to do this? Thanks. Gary [[alternative
2010 Oct 16
3
reduce the size of points in plot???
Hi, R users, Can anyone tell me how I can change the size of points in my plot? For example: x <- c(1,3,6,9,12) y <- c(1.5,2,7,8,15) plot(x,y,pch=20) How do I reduce the size of those points? Thanks. Gary [[alternative HTML version deleted]]
2009 Nov 27
2
set condition in R
Hi, R users, I'm using while() in R to set a condition. My condition is: i<523 or i>535. How should I write this in R? I try "while (i<523 or i>535)" and it does not work. Thanks. Garry On Tue, Nov 10, 2009 at 11:26 AM, Hongwei Dong <pdxdong@gmail.com> wrote: > Exactly! Thanks, Duncan. > > Let me re-phrase me question like this: > > 1) X_i values
2009 Jul 23
3
how to predict dynamic model in R
I have a dynamic time series model like this: dyn$lm( y ~ lag(y,-1) + x + lag(x,-1)+lag(x,-2) ) I need to do an out of sample forecast with this model. Is there any way I can do this with R? It would be greatly appreciated if some one can give me an example. Thanks. Harry [[alternative HTML version deleted]]
2009 Jun 29
2
How to use "subset" in lm function
Hi, I'm using R to do a time series analysis. In the model, I use the lags of some variables. such the lags of the variables have different length, I just can't use them directly in the lm function. Intuitively, I feel that "subset" might be useful, but I do not know how to use it. Anyone can give me an example syntax? Thanks. Harry [[alternative HTML version deleted]]
2009 Aug 17
2
memory limit in R
Hi, all, I'm doing a discrete choice model in R and kept getting this error: Error: cannot allocate vector of size 198.6 Mb. Does this mean the memory limit in R has been reached? > memory.size() [1] 1326.89 > memory.size(TRUE) [1] 1336 > memory.limit() [1] 1535 My laptop has a 4G memory with Windows Vista (32 bit). I increased the memory limit to 2500 M. But still getting the same
2009 Aug 16
1
why summary() does not work here???
Hi, R users, I'm using the function "vglm" to estimate a multinomial logit model. Every time I use "summary()" to ask for the coefficients and std error, I got this: Length Class Mode 1 vglm S4 Anyone know what's wrong here? Thanks. Harry [[alternative HTML version deleted]]
2010 Jun 01
2
Help on aggregate method
Dear R experts, I would really appreciate if you had an idea on how to use more efficiently the aggregate method: More specifically, I would like to calculate the mean of certain values on a data frame,? grouped by various attributes, and then create a new column in the data frame that will have the corresponding mean for every row. I attach part of my code: matchMean <-
2012 Jul 21
1
memory size
Dear R community, I'm running "a mlogit" function with a very large data set. Since the data size is so large, I got the Error: Error: cannot allocate vector of size 5.4 Mb In addition: Warning messages: 1: In mapply("*", X, P, SIMPLIFY = FALSE) : Reached total allocation of 16340Mb: see help(memory.size) 2: In mapply("*", X, P, SIMPLIFY = FALSE) : Reached
2011 Feb 03
1
use "summary"
Hi, dear R users, I'm running a Tobit regression and using "summary" to display model results. It used to work. But this time, I kept getting this: > summary(RES_TOBIT) Length Class Mode 1 vglm S4 Could anyone tell me how to solve this problem, and why I got this problem? Thanks. Gary [[alternative HTML version deleted]]
2011 Feb 19
1
Sample function in R???
Hi, R users, I'm wondering if there a way in R I can select cases based on a probability vector. if a case is selected, that case is marked as 1, otherwise, 0. For example: x<-12:18 y<-1:7 sample(x,2,replace=FALSE,y) I got: [1] 15 17 What I want to see is: [1] 0 0 0 1 0 1 0 Thanks. Gary [[alternative HTML version deleted]]
2011 Mar 20
1
legend position in "barplot"
Hi, R users, I there a way that I can control the position of the legend while using "barplot" function? For example: a<-matrix(c(0,0,0.5,0.8,0.9,0.9),2,3) colnames(a)<-c("X","Y","Z") rownames(a)<-c("A","B") a barplot(a,width = 0.2,legend = TRUE,axes=FALSE,col=c("coral3","steelblue3"),beside=TRUE) In this
2012 Dec 25
5
aggregate / collapse big data frame efficiently
Hi, I need to aggregate rows of a data.frame by computing the mean for rows with the same factor-level on one factor-variable; here is the sample code: x <- data.frame(rep(letters,2), rnorm(52), rnorm(52), rnorm(52)) aggregate(x, list(x[,1]), mean) Now my problem is, that the actual data-set is much bigger (120 rows and approximately 100.000 columns) ? and it takes very very long
2011 Nov 29
2
aggregate syntax for grouped column means
I am calculating the mean of each column grouped by the variable 'id'. I do this using aggregate, data.table, and plyr. My aggregate results do not match the other two, and I am trying to figure out what is incorrect with my syntax. Any suggestions? Thanks. Here is the data. myData <- structure(list(var1 = c(31.59, 32.21, 31.78, 31.34, 31.61, 31.61, 30.59, 30.84, 30.98, 30.79, 30.79,
2010 Mar 24
1
with data in the form of an R data objecte: Monte Carlo simulation in R
Hi, please use the following the matrix z as the example: x<-c(2,4,5,7,6,9,8,2,0) y<-matrix(x,3,3) z<-apply(y,2,function(x)x/sum(x)) z On Tue, Mar 23, 2010 at 6:59 PM, David Winsemius <dwinsemius@comcast.net>wrote: > > On Mar 23, 2010, at 9:05 PM, Hongwei Dong wrote: > > Hi, R-helpers, >> >> I'm trying to use R to do a Monte Carlo simulation and
2009 Nov 09
3
How to transform the Matrix into the way I want it ???
Hi, R users, I'm trying to transform a matrix A into B (see below). Anyone knows how to do it in R? Thanks. Matrix A (zone to zone travel time) zone z1 z2 z3 z1 0 2.9 4.3 z2 2.9 0 2.5 z3 4.3 2.5 0 B: from to time z1 z1 0 z1 z2 2.9 z1 z3 4.3 z2 z1 2.9 z2 z2 0 z2 z3 2.5 z3 z1 4.3 z3 z2 2.5 z3 z3 0 The real matrix I have is much larger, with more than 2000 zones. But I think it should
2009 Nov 10
1
Generate Random Draw from Gamma Distribution Re: Monte Carlo Simulation in R...
Exactly! Thanks, Duncan. Let me re-phrase me question like this: 1) X_i values are independent Gammas, with the shape 0.067 and scale 0.008 2) Min(X)=1 and Max(X)=85 3) SUM(X)=2000 4) Do I also have to define the number of draws? if yes, it could be 250. Based on these restrictions, I want to generate random draw. I'm wondering how I can do this in R. Thanks. Garry On Tue, Nov 10, 2009
2009 Jul 02
2
Plot two graphs with different ranges in one
Hi, I'm trying to plot two variables in one graph. One ranges between 0 and 1, while the other ranges between 50 and 500. Can I plot them in one graph with similar scale? Thanks Harry [[alternative HTML version deleted]]
2009 Aug 03
2
What does this error message mean?
Hi, I used R to run a linear regression and keep getting the following error message. I do not understand it very well. Anyone can help out? Thanks. Error in storage.mode(y) <- "double" : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, "numeric") : using type="numeric" with a factor response will be ignored
2009 Aug 03
2
lme funcion in R
Hi, R users, I'm using the "lme" function in R to estimate a 2 level mixed effects model, in which the size of the subject groups are different. It turned out that It takes forever for R to converge. I also tried the same thing in SPSS and SPSS can give the results out within 20 minutes. Anyone can give me some advice on the lme function in R, especially why R does not converge?