similar to: using mapply to avoid loops

Displaying 20 results from an estimated 5000 matches similar to: "using mapply to avoid loops"

2011 Jul 11
1
plot means ?
Hi, I need this plot: given: x,y - numerical vectors of length N plot xi vs mean(yj such that |xj - xi|<epsilon) (running mean?) alternatively, discretize X as if for histogram plotting and plot mean y over the center of the histogram group. is there a simple way? thanks! -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031 http://thereligionofpeace.com
2008 Aug 27
2
r function for calculating extreme spread in group
I'm trying to figure out how to write a r function that will calculate the extreme spread of a group of points given their (x,y) coordinates. Extreme Spread is the maximal Euclidean distance between two points in a group ex.spread = max{ sqrt [ (xi-xj)^2 - (yi-yj)^2 ] } for i not equal to j I have 60 levels to apply this to. There is the combination function in the dprep package but
2001 Nov 21
2
distances from points to line
Dear all, I have discovered that there are many things that I used to do in my GIS which are easily done directly in R, for example calculating interpoint distances using geoR and pick out points inside a polygon using splancs. I now wonder, is there a function to create a line object like a watercourse and then calculate the distances between many points in space and this line? I couldn't
2005 Nov 04
2
Simplify iterative programming
Dear, I am looking for the simplification of a formula to improve the calculation speed of my program. Therefore I want to simplify the following formula: H = sum{i=0..n-1 , [ sum {j=0..m-1 , sqrt ( (Ai - Bj)^2 + (Ci - Dj)^2) } ] } where: A, C = two vectors (with numerical data) of length n B, D = two vectors (with numerical data) of length m sqrt = square root Ai = element of A with index
2009 Jul 16
1
Theil test help
Hello, I have a series of questions that I hope will be simple to answer. Basically I would like a code to do the following so that I can compute the distribution free test for the slope of a postulated regression line (Theil test). As I am testing the null hypothesis that slope = 0 against the general alternative the slope does not equal 0, it should be pretty straight-forward. I have a data
2011 Oct 18
1
Repeat a loop until...
Dear all, I know there have been various questions posted over the years about loops but I'm afraid that I'm still stuck. I am using Windows XP and R 2.9.2. I am generating some data using the multivariate normal distribution (within the 'mnormt' package). [The numerical values of sanad and covmat are not important.] > datamat <-
2009 Dec 04
1
Saving predict
Hi all,,Im using function arima() I.e series is my data model<-arima(series,c(1,0,0)) forecast<-predict(model,80) I want to create a variable: b1<-forecast$pred - 1.96*forecast$se and save in a txt file but using this: save(b1, file= "b1.txt") creates afile butwith this inside: ]{HQ ~|LJIiW*-l)% )m#), RIiSfdbGur9p94; H"L#Rez 1y3pN8{,I6W!6= {6l?OMw_5KZ+ =
2006 Jan 11
1
F-test degree of freedoms in lme4 ?
I have a problem moving from multistratum aov analysis to lmer. My dataset has observations of ampl at 4 levels of gapf and 2 levels of bl on 6 subjects levels VP, with 2 replicates wg each, and is balanced. Here is the summary of this set with aov: >> summary(aov(ampl~gapf*bl+Error(VP/(bl*gapf)),hframe2)) > >Error: VP > Df Sum Sq Mean Sq F value Pr(>F) >Residuals
2011 Dec 02
1
1.6x speedup for requal() function (in R/src/main/unique.c)
Hi, FWIW: /* Taken from R/src/main/unique.c */ static int requal(SEXP x, int i, SEXP y, int j) { if (i < 0 || j < 0) return 0; if (!ISNAN(REAL(x)[i]) && !ISNAN(REAL(y)[j])) return (REAL(x)[i] == REAL(y)[j]); else if (R_IsNA(REAL(x)[i]) && R_IsNA(REAL(y)[j])) return 1; else if (R_IsNaN(REAL(x)[i]) && R_IsNaN(REAL(y)[j])) return 1;
2011 Feb 09
2
Generate multivariate normal data with a random correlation matrix
Hi All. I'd like to generate a sample of n observations from a k dimensional multivariate normal distribution with a random correlation matrix. My solution: The lower (or upper) triangle of the correlation matrix has n.tri=(d/2)(d+1)-d entries. Take a uniform sample of n.tri possible correlations (runi(n.tr,-.99,.99) Populate a triangle of the matrix with the sampled correlations Mirror the
2008 Jul 01
1
[.data.frame speedup
Below is a version of [.data.frame that is faster for subscripting rows of large data frames; it avoids calling duplicated(rows) if there is no need to check for duplicate row names, when: i is logical attr(x, "dup.row.names") is not NULL (S+ compatibility) i is numeric and negative i is strictly increasing "[.data.frame" <- function (x, i, j,
2011 Oct 06
1
sum of functions
Dear all, I would like to create a code for semiparametric Klein and Spady's estimator. For that I created a function that provides the log-likelihood function for each observation (so it is a function of betas and i, where i denotes the observation). Now, in order to maximize the log-likelihood function, I have to sum these log-likelihood functions for each i and so to get another function
2008 Oct 02
3
Adding plane in a 3D scatterplot
I have drawn a 3D scatter plot : library(mnormt) library(scatterplot3d) dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3) scatterplot3d(dat) Now I want to do 2 things : 1 : In the Z-axis (i.e. height), I want to see only numbers 1,2,3, etc NOT, 1,1.5,2,2.5............. 2. I want to add two Horizontal planes at hight z=2 and z=3. Those two planes should look like "bottom" of that 3D plot
2004 May 24
1
as.matrix.data.frame() in R 1.9.0 converts to character when it should (?) convert to numeric
Conversion of a data frame to a matrix using as.matrix() when a column of the data frame is POSIXt and all other columns are numeric has changed in R 1.9.0 from R 1.8.1. The new behavior issues a warning message and converts to a character matrix. In R 1.8.1, such an object was converted to a numeric matrix. Here is an example. #### R 1.9.0 #### > foo <- data.frame(
2017 Dec 01
1
Bug is as.matrix.data.frame with nested data.frame
Converting a data.frame with a nested data.frame to a matrix fails: x <- structure(list(a = data.frame(letters)), class = "data.frame", row.names = .set_row_names(26)) as.matrix(x) #> Error in ncol(xj) : object 'xj' not found The offending code is here, in the definition of as.matrix.data.frame (source/base/all.R): for (j in pseq) {
2001 Dec 11
0
VirtualProtect and app crash: what's your interpretation?
Here is my thought process on why the application crashes with a protection violation reading a section of memory. I used IDA to disassemble the app. Here's the section where it reads from memory and crashes because of a protection violation: 00760D4A sub_760D4A proc near ; CODE XREF: sub_75FCB0+159^Xp 00760D4A push ebp 00760D4B mov
2009 Oct 29
3
Weird error: Error in xj[i] : invalid subscript type 'list'
I got the error. I haven't been able to get a stand along case so that I can show it here. But could somebody give some clue on what could cause this error? Since I never defined xj[i], I don't understand where this error come from. Error in xj[i] : invalid subscript type 'list'
2011 May 16
2
about spearman and kendal correlation coefficient calculation in "cor"
Hi, I have the following two measurements stored in mat: > print(mat) [,1] [,2] [1,] -14.80976 -265.786 [2,] -14.92417 -54.724 [3,] -13.92087 -58.912 [4,] -9.11503 -115.580 [5,] -17.05970 -278.749 [6,] -25.23313 -219.513 [7,] -19.62465 -497.873 [8,] -13.92087 -659.486 [9,] -14.24629 -131.680 [10,] -20.81758 -604.961 [11,] -15.32194 -18.735 To calculate the ranking
2003 Jun 18
1
suggestion for make.names
I would like to suggest a modification to the make.names() function. The current implementation has two problems: 1. It doesn't check if a name matches an R keyword (like "function"). 2. The uniqueness algorithm is not invariant to concatenation. In other words, make.names(c("a","a","a"),unique=T) !=
2003 Jun 18
1
suggestion for make.names
I would like to suggest a modification to the make.names() function. The current implementation has two problems: 1. It doesn't check if a name matches an R keyword (like "function"). 2. The uniqueness algorithm is not invariant to concatenation. In other words, make.names(c("a","a","a"),unique=T) !=