similar to: help!! warning:only the first element has been used

Displaying 20 results from an estimated 10000 matches similar to: "help!! warning:only the first element has been used"

2008 Aug 18
2
matrix row product and cumulative product
I spent a lot of time searching and came up empty handed on the following query. Is there an equivalent to rowSums that does product or cumulative product and avoids use of apply or looping? I found a rowProd in a package but it was a convenience function for apply. As part of a likelihood calculation called from optim, I?m computing products and cumulative products of rows of matrices with
2009 Sep 16
2
Generalized cumsum?
Is there anything like cumsum and cumprod but which allows you to apply an arbitrary function instead of sum and product? In other words, I want a function cumfunc(x, f) that returns a vector, so that for all n up to the length of x cumapply(x,f)[n] = f(x[1:n]) This would give cumsum and cumprod as special cases when f=sum or f=prod. I could write such a function, but I can't see
2010 Apr 01
1
how to construct a time series
Hi, I need to generate the time series of the production, but as I'm new to this topic I am not able to do that. This is what the time series should be: PROD(t)=PROD(t,T) PROD(t-1)=PROD(t-1,T) PROD(t-2)=PROD(t-1)*PROD(t-2,T-1)/PROD(t-1,T-1) PROD(t-3)=PROD(t-2)*PROD(t-3,T-2)/PROD(t-2,T-2) ... ... ... from PROD(t-2)...it will get the same expression; where PROD(t,T) is the value of the
2006 Feb 28
2
vector math: calculating a rolling 12 row product?
I have a dataframe of numeric values with 30 ?rows? and 7 ?columns?. For each column, beginning at ?row? 12 and down to ?row? 30, I wish to calculate the ?rolling 12 row product?. I.e., within each column, I wish to multiply all the values in row 1:12, 2:13, 19:30. I wish to save the results as a new dataframe, which will have 19 rows and 7 columns.
2008 Jan 13
3
product of vector elements
All, I would like to find a simper method that I now have to find the product of all elements in a vector: #get product of vector elements: (1,2,3,4,5) vec.product <- exp(sum(log(c(1,2,3,4,5)))) I have not found a vector product function, if one has been written. Thanks, Gerard [[alternative HTML version deleted]]
2008 Sep 03
2
optimizing speed of calculation (recursive product)
Dear list, I'm wondering how to optimize functions/processes like the one shown below (which simplifies something we're trying to do with very large datasets). In many cases I've noticed that using apply, sapply etc can help speeding up processes, but in this case I don't see how I could do so. a <- runif(10000000,0.5,1.6) C <- 2 M <- 10000000 system.time( for (i in
2011 Feb 01
6
help
PLEASE HELP I actually want to do the following: a[j] = (1/(j!))*Π (i-1-d), j = 500, Π means product i = 1 to j   Yet, j! will stop at 170 and Π (i-1-d) at 172; so, a[j] will not exceed 170. I would like to have at least 200 a[j].   WHAT SHOULD I DO?   PLEASE SEE MY CODE FOR DETAIL!! #################################################### R CODE:
2010 May 05
1
testInstalledBasic question
Hi, I'm currently in the process of writing an R-installation SOP for my company. As part of that process I'm using the recommendations from the 'R Installation and Administration' document, section 3.2, "Testing an installation". This is done on an XP machine, using the latest binary of 2.11.0. The binary is downloaded and then installed from the installer. I then
2009 Nov 09
6
Find the first values in vector
Hi ! I have a vector: vec= TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE and I'm looking for a method which let me get only the first values equal TRUE from this vector. It means that I want to get a vector: vec_out = TRUE TRUE TRUE TRUE or posictions values = TRUE: vec_out = 1,2,3,4 -- View this message in context:
2006 Jan 09
3
prod(numeric(0)) surprise
It surprised me that prod(numeric(0)) is 1. I guess if you say (operation(nothing) == identity element) this makes sense, but ?? Looking in the code, this makes sense: basically (s=1; for i=0 to length(x), multiply s by x[i]) -- which comes out to 1. What *should* prod(numeric(0)) produce? I couldn't find the answer documented anywhere. (And how about sum(numeric(0))==0, which for
2011 Nov 27
1
generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})
Dear R-help, I have been trying really hard to generate the following vector given the data (x) and parameter (alpha) efficiently. Let y be the output list, the aim is to produce the the following vector(y) with at least half the time used by the loop example below. y[1] = alpha * x[1] y[2] = alpha^2 * x[1] + alpha * x[2] y[3] = alpha^3 * x[1] + alpha^2 * x[2] + alpha * x[3] ..... below are
2003 Mar 22
1
cumprod doesn't work with data frames (PR#2667)
Full_Name: J. Sisk Version: 1.6.1 OS: Linux (RedHat 8) Submission from: (NULL) (67.119.41.66) Suppose you make a data-frame like so: xxx <- data.frame(a=10,b=20,c=30,d=40) Then cumprod(xxx[1,]) returns > cumprod(xxx[1,]) a b c d 1 10 20 30 40 The documentation for cumprod says that it should work on "numerical objects", and this is a data-frame, but it
2005 Apr 29
2
Subarrays
Define an array > v<-1:256 > dim(v)<-rep(4,4) Subarrays can be obtained as follows: > v[3,2,,2] [1] 71 87 103 119 > v[3,,,2] [,1] [,2] [,3] [,4] [1,] 67 83 99 115 [2,] 71 87 103 119 [3,] 75 91 107 123 [4,] 79 95 111 127 In the general case this procedure is very tedious. Given an array A, dim(A)=(dim_1,dim_2,...,dim_d) and two vectors
2009 Feb 17
2
cumsum vs. sum
I recently traced a bug of mine to the fact that cumsum(s)[length(s)] is not always exactly equal to sum(s). For example, x<-1/(12:14) sum(x) - cumsum(x)[3] => 2.8e-17 Floating-point addition is of course not exact, and in particular is not associative, so there are various possible reasons for this. Perhaps sum uses clever summing tricks to get more accurate results? In some
2011 Jan 27
1
How do I fix this ?
Just when I think I'm starting to learn .... Statement z1 works, statement z doesn't. Why doesn't z work and what do I do to fix it ? Clearly the problem is with the first NA, but I would think it's handled through the loop vectorization. y1 <- rnorm(20, 0, .013) y1 [1] -0.0068630836 -0.0101106230 -0.0169663344 -0.0066314769 0.0075063818 [6] -0.0033548024 0.0015647863
2003 Jul 30
6
reverse array indexing
Hi, Suppose I have a multidimensional array: tmp <- array(1:8, c(2,2,2)) is there a function out there that, given a one-dimensional array index, will return the separate indices for each array dimension? for instance, tmp[8] is equivalent to tmp[2,2,2]. I'd like to derive the vector (2,2,2) from the index 8. thanks, Brad Buchsbaum
2009 Oct 13
7
lapply() reccursively
Hi all, I was wondering whether it is possible to use the lapply() function to alter the value of the input, something in the spirit of : a1<-runif(100) a2<-function(i){ a1[i]<-a1[i-1]*a1[i];a1[i] } a3<-lapply(2:100,a2) Something akin to a for() loop, but using the lapply() infrastructure. I haven't been able to get rapply() to do this. The reason is that the "real"
2008 Oct 15
2
Condition warning: has length > 1 and only the first element will be used
Hello, I've been learning R functions recently and I've come across a problem that perhaps someone could help me with. # I have a a chron() object of times > hours=chron(time=c("01:00:00","18:00:00","13:00:00","10:00:00")) # I would like to subtract 12 hours from each time element, so I created a vector of 12 hours (actually, more like a
2010 Jul 09
3
apply is slower than for loop?
I thought the "apply" functions are faster than for loops, but my most recent test shows that apply actually takes a significantly longer than a for loop. Am I missing something? It doesn't matter much if I do column wise calculations rather than row wise ## Example of how apply is SLOWER than for loop: #rm(list=ls()) ## DEFINE VARIABLES mu=0.05 ; sigma=0.20 ; dt=.25 ; T=50 ;
2006 Aug 31
2
cumulative growth rates indexed to a common starting point over n series of observations
What is the R way of computing cumulative growth rates given a series of discrete values indexed . For instance, given a matrix of 20 observations for each of 5 series (zz), what is the most straight forward technique in R for computing cumulative growth (zzcum) ? It seems for the solution I'm after might be imbedding the following cum growth rate calc as a function into a function call