similar to: alternate methods to perform a calculation

Displaying 20 results from an estimated 1100 matches similar to: "alternate methods to perform a calculation"

2007 Aug 31
2
memory.size help
I keep getting the 'memory.size' error message when I run a program I have been writing. It always it cannot allocate a vector of a certain size. I believe the error comes in the code fragement below where I have multiple arrays that could be taking up space. Does anyone know a good way around this? w1 <- outer(xk$xk1, data[,x1], function(y,z) abs(z-y)) w2 <- outer(xk$xk2,
2008 Jan 30
1
re stricting points in a data frame
useR's, Consider some variables and a data frame of points: x1 <- c(1,2,3) x2 <- c(3,4,5) xk1 <- seq(min(x1)-.5, max(x1)+.5,.5) xk2 <- seq(min(x2)-.5, max(x2)+.5,.5) expand.grid(xk1=xk1,xk2=xk2) xk1 xk2 1 0.5 2.5 2 1.0 2.5 3 1.5 2.5 4 2.0 2.5 5 2.5 2.5 6 3.0 2.5 7 3.5 2.5 ... 46 2.0 5.5 47 2.5 5.5 48 3.0 5.5 49 3.5 5.5 I want to restrict the data frame to only contain
2007 Aug 29
0
a faster and shorter way to perform calculations?
This is a continuation from a previous posting of mine: The following algorithm below is what I want to accomplish: Z(xk) = Average(Yi, i belongs to Ik), where Ik contains all i such that for each j, |Xi,j - xkj?? 2. Here, j = 1, 2 and i corresponds to the elements in each X and/or xk >data x1 x2 y 1 1 2 2 2 6 3 3 12 Now, consider a second data frame or matrix (xk):
2008 Feb 21
0
extending code to handle more variables
useR's, Consider the variables defined below: yvals <- c(25,30,35) x1 <- c(1,2,3) x2 <- c(3,4,5) x3 <- c(6,7,8) x <- as.data.frame(cbind(x1,x2,x3)) delta <- c(2.5, 1.5, 0.5) h <- delta/2 vars <- 3 xk1 <- seq(min(x1)-0.5, max(x1)+0.5, 0.5) xk2 <- seq(min(x2)-0.5, max(x2)+0.5, 0.5) xk3 <- seq(min(x3)-0.5, max(x3)+0.5, 0.5) xks <- list(xk1,xk2,xk3) xk <-
2008 Jul 29
3
finding a faster way to do an iterative computation
useR's, I am trying trying to find out if there is a faster way to do a certain computation. I have successfully used FOR loops and the apply function to do this, but it can take some time to fully compute, but I was wondering if anyone may know of a different function or way to do this: > x [1] 1 2 3 4 5 > xk [1] 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 I want to do:
2008 Jan 07
1
Avoiding FOR loops
useR's, I would like to know if there is a way to avoid using FOR loops to perform the below calculation. Consider the following data: > x [,1] [,2] [,3] [1,] 4 11 1 [2,] 1 9 2 [3,] 7 3 3 [4,] 3 6 4 [5,] 6 8 5 > xk Var1 Var2 Var3 1 -0.25 1.75 0.5 2 0.75 1.75 0.5 3 1.75 1.75 0.5 4 2.75 1.75 0.5 5 3.75 1.75
1997 Aug 21
1
R-alpha: another ctest question
I have the following problem. Consider a `classical' test which works for k .ge. 2 samples. Possible interfaces are e.g. xxx.test(x, g) x ... all data, g ... corresponding groups xxx.test(x1, ..., xk) xxx.test(list(x1, ..., xk)) etc etc. Clearly, the first and the second one are nice, but cannot be combined without making `g' (i.e., `group') a named argument. Hence, in
2003 Oct 28
2
outer function problems
I'm pulling my hair (and there's not much left!) on this one. Basically I'm not getting the same result t when I "step" through the program and evaluate each element separately than when I use the outer() function in the FindLikelihood() function below. Here's the functions: Dk<- function(xk,A,B) { n0 *(A*exp(-0.5*(xk/w)^2) + B) } FindLikelihood <-
2009 Nov 04
4
unexpected results in comparison (x == y)
Dear readers of the list, I have a problem a comparison of two data from a vector. The comparison yields FALSE but should be TRUE. I have checked for mode(), length() and attributes(). See the following code (R2.10.0): ----------------------------------------------- # data vector of 66 double data X =
2007 Nov 19
2
All nonnegative integer solution
Dear all, Is there any method in R to find all possible nonnegative integer solutions to the linear equation with unit coefficients as follow: X1+X2+...+Xk=N Thank you, Amin Zollanvari
2009 Jan 19
2
Using apply to generate matrix from rows?
Dear all, I have a simple question which I unfortunately do not seem to be able to solve myself. I have a (NxK) matrix and want to generate a new matrix by multiplying each row with itself such that the new matrix has dimension ((N*K)xK) (or better, generate an array with dimension (K,K,N)). I tried apply, but that did not work. Any suggestions? Thanks! Stephan ## Here is a simple
2007 Sep 10
5
finding the minimum positive value of some data
useRs, I am looking to find the minimum positive value of some data I have. Currently, I am able to find the minimum of data after I apply some other functions to it: > x [1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 > sort(x) [1] 0 1 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 > diff(sort(x)) [1] 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 > min(diff(sort(x))) [1] 0
2007 Dec 20
1
alternate storage options
useR's. I am working with an algorithm in which I will need to create combinations of all the points I have in a matrix. When I have 2 variables, I simply use expand.grid() to do this. Sometimes I am faced with 3 or more variables and if I run expand.grid(), R cannot process it due to the huge size. Is there any efficient way to workaround this? Thanks, Derek -- View this message in
2010 Nov 14
1
score test for logistic regression
Dear R experts, I'm trying to find a code to calculate the p-value from the score test for the logistic regression. My fit is like this: logit=beta0+beta1*x1+beta2*x2 +....+ betak* xk. And my H0 is beta1=beta2=...=betak =0. Any help will be highly appreciated. Thank you! Ying
2008 Jul 24
2
simple random number generation
useR's, I want to randomly generate 500 numbers from the standard normal distribution, i.e. N(0,1), but I only want them to be generated in the range -1.5 to 1.5. Does anyone have a simple way to do this? Thanks, dxc13 -- View this message in context: http://www.nabble.com/simple-random-number-generation-tp18642611p18642611.html Sent from the R help mailing list archive at Nabble.com.
2008 Jan 16
3
color ranges on a 2D plot
useR's I am trying to color the points on a scatter plot (code below) with two colors. Red for values 0.5 -1.0 and blue for 0.0 - .49. Does anyone know a easy way to do this? x <- runif(100, 0, 1) y <- runif(100, 0, 1) plot(y ~ x, pch=16) Thanks, dxc13 -- View this message in context: http://www.nabble.com/color-ranges-on-a-2D-plot-tp14893457p14893457.html Sent from the R help
2009 Sep 27
1
Clustering with R - efficient processing of large sparse data sets (text data)
I checked the R procedure HCLUST (hierarchical clustering) but it looks like it requires a full triangular n x n similarity matrix as input, where n = number of observations. The number of variables is 200. My data set has n = 50,000 observations (keywords), and I use ad-hoc similarity measures, not available in R, to measure keyword similarity. Here, the vast majority of the n x n similarities
2006 Aug 30
1
Optimization
Dear R-list, I'm trying to estimate the relative importance of 6 environmental variables in determining clam yield. To estimate clam yield a previous work used the function Yield = (A^a*B^b*C^c...)^1/(a+b+c+...) where A,B,C... are the values of the environmental variables and the weights a,b,c... have not been calibrated on data but taken from literature. Now I'd like to estimate the
2009 May 24
2
Deleting columns from a matrix
useR's, I have a matrix given by the code: mat <- matrix(c(rep(NA,10),1,2,3,4,5,6,7,8,9,10,10,9,8,NA,6,5,4,NA,2,1,rep(NA,10),1,2,3,4,NA,6,7,8,9,10),10,5) This is a 10x5 matrix containing missing values. All columns except the second contain missing values. I want to delete all columns that contain ALL missing values, and in this case, it would be the first and fourth columns. Any column
2009 May 04
2
A variation on the bar plot
Hi all, I cannot think of the technical name of this plot, but I want to create a plot with the data below that looks like two back-to-back horizontal bar plots. Ideally, there would be a vertical line in the center of the plot at zero, and on the right hand side would be 4 bars representing the values for 2007, and on the left side of the vertical line would be the corresponding values for 2005.