search for: xk2

Displaying 5 results from an estimated 5 matches for "xk2".

Did you mean: x2
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 points that are within the x1 and x2 range....
2007 Aug 28
1
alternate methods to perform a calculation
Consider a data frame (x) with 2 variables, x1 and x2, having equal values. It looks like: x1 x2 1 1 2 2 3 3 Now, consider a second data frame (xk): xk1 xk2 0.5 0.5 1.0 0.5 1.5 0.5 2.0 0.5 0.5 1 1.0 1 1.5 1 2.0 1 0.5 1.5 1.0 1.5 1.5 1.5 2.0 1.5 0.5 2 1.0 2 1.5 2 2.0 2 I have written code to calculate some differences between these two data sets; the main idea is to subtract off each element of xk1 from e...
2007 Aug 29
0
a faster and shorter way to perform calculations?
...complish: 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): xk1 xk2 0.5 0.5 1.0 0.5 1.5 0.5 2.0 0.5 0.5 1 1.0 1 1.5 1 2.0 1 0.5 1.5 1.0 1.5 1.5 1.5 2.0 1.5 0.5 2 1.0 2 1.5 2 2.0 2 In the end, there should be matrix or data frame with 3 columns, xk1, xk2, and z (the result of the algorithm). Having any NA's as a...
2007 Aug 31
2
memory.size help
...riting. 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, data[,x2], function(y,z) abs(z-y)) w1[w1 > d1] <- NA w2[w2 > d2] <- NA i1 <- ifelse(!is.na(w1),yvals[col(w1)],NA) i2 <- ifelse(!is.na(w2),yvals[col(w2)],NA) zk <- numeric(nrow(xk)) #DEFININING AN EMPTY VECTOR TO HOLD ZK VALUES for(x in 1:nrow(xk)) { k <- intersect(i1[...
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 <- do.call("expand.grid", xks) I want to perform several calculations with these variables. For only two variables, my code is successful, however, here there are thr...