similar to: Function reference

Displaying 20 results from an estimated 3000 matches similar to: "Function reference"

2007 Dec 10
4
Reading through a group of .RData files
Hi. I have a procedure that reads a directory, loops through a set of particular .RData files, loading each one, and feeding its object(s) into a function, as follows: cvListFiles<-list.files(fnDir); for(i in grep(paste("^",pfnStub,".*\\.RData$",sep=""),cvListFiles)){ load(paste(fnDir,cvListFiles[i],sep="/")); myFunction(rliObject); rm(rliObject); };
2008 Jan 07
3
Seeking a more efficient way to find partition maxima
Hi. Suppose I have a vector that I partition into disjoint, contiguous subvectors. For example, let v = c(1,4,2,6,7,5), partition it into three subvectors, v1 = v[1:3], v2 = v[4], v3 = v[5:6]. I want to find the maximum element of each subvector. In this example, max(v1) is 4, max(v2) is 6, max(v3) is 7. If I knew that the successive subvector maxima would never decrease, as in the example,
2007 Dec 26
1
Can you recover default argument values of a function?
Hi. Maybe this is a stupid question. If so, I apologize, but here goes. Suppose I have a function f1(x,...) that calls a function f2(y1,y2,...,yn) in the following way: if x satisfies a certain condition, then I want to call f2(x,y2,...,yn); otherwise I want to use the default value of y1, if there is one. I could do something like the following: v <- ifelse ( is.null(x), f2( , y2,...,
2008 Jan 02
2
Seeking a more efficient way to read in a file
Hi. I have a matrix stored in a large, tab-delimited flat file. The first row contains column names. Because the matrix is symmetric, the file has lower triangular format, so the second row contains one number, the third row two numbers, etc. In general, row k+1 contains k numbers; the matrix has 3000 rows, so the file has 3001 rows. The file has variable length records, so each row ends
2007 Mar 05
2
Linear programming with sparse matrix input format?
Hi. I am aware of three different R packages for linear programming: glpk, linprog, lpSolve. From what I can tell, if there are N variables and M constraints, all these solvers require the full NxM constraint matrix. Some linear solvers I know of (not in R) have a sparse matrix input format. Are there any linear solvers in R that have a sparse matrix input format? (including the
2007 Jan 11
1
rank function and NA in 2.3.1
Hi. I am using R 2.3.1 on WIndows XP, and I am having trouble with the rank function in the presence of numerical NA data. I want the NA's all to get the same rank, but they don't. Here is an example from my session: >ct_align_rets_f2$liq[6851:6859] [1] 115396 NA 362595 NA 242986 340805 NA 692905 251533
2007 Feb 01
3
Can this loop be delooped?
Hi. I have the following code in a loop. It splits a vector into subvectors of equal size. But if the size of the original vector is not an exact multiple of the desired subvector size, then the first few subvectors have one more element than the last few. I know that the cut function could be used to determine where to break up the vector, but it doesn't seem to provide control over
2007 Dec 20
1
Quote: An embedded and charset-unspecified text was scrubbed...
Occasionally when I click on a posting in the archives, I don't see the actual message, but instead, something like the following: An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/200712XX/aXXXXXXX/attachment.pl In fact, this is what has happened with the past few messages I have posted. Is this because
2007 Jul 27
2
Matrix Multiplication, Floating-Point, etc.
Hi. I recently tried the following in R 2.5.1 on Windows XP: >ev2<-c(0.8,-0.6) >ev1<-c(0.6,0.8) >ev1%*%ev2 [,1] [1,] -2.664427e-17 >sum(ev1*ev2) [1] 0 > (I got the same result with R 2.4.1 on a different Windows XP machine.) I expect this issue is very familiar and probably has been discussed in this forum before. Can someone please point me to some
2007 Jan 18
1
Robust PCA?
Hi. I'm checking into robust methods for principal components analysis. There seem to be several floating around. I'm currently focusing my attention on a method of Hubert, Rousseeuw, and Vanden Branden (http://wis.kuleuven.be/stat/Papers/robpca.pdf) mainly because I'm familiar with other work by Rousseeuw and Hubert in robust methodologies. Of course, I'd like to obtain
2007 Aug 31
1
gsub warning message
Hi. I am using R 2.5.1 on a Windows XP machine. Here is an example of a piece of code I was running in older versions of R on the same machine. I am looking for underscores and replacing them with periods. This result is from R 2.4.1: >gsub ( "\\_+","\.","AAA_I") [1] "AAA.I" > Here is what I get in R 2.5.1: >gsub (
2007 Feb 28
1
Efficient way to repeat rows (or columns) of a matrix?
Hi. If I have a vector, v_1, and another vector of positive integers, i_1, the same length as v_1, then rep(v_1,i_1) will repeat v_i[j] exactly i_1[j] times, like so: >rep(c(1,2,3),c(3,2,1)) [1] 1 1 1 2 2 3 > I'd like to do the same sort of thing where I replace v_1 with a matrix, and the jth row of the matrix is repeated i_1 times. Obviously, I could do this with for loops, like
2007 Jul 09
1
factanal frustration!
Hi. It seems that nearly every time I try to use factanal I get the following response: >faa2db1<-factanal(mretdb1,factors=2,method="mle",control=list(nstart=25)) Error in factanal(mretdb1, factors = 2, method = "mle", control = list(nstart = 25)) : unable to optimize from these starting value(s) > In the case cited above, mretdb1 is synthetic data created
2007 May 15
2
Testing for existence inside a function
Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f<-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or
2007 Feb 02
1
Another loop - deloop question
Hi. You folks are so clever, I thought perhaps you could help me make another procedure more efficient. Right now I have the following setup: p is a vector of length m g is a list of length n, g[[i]] is a vector whose elements are indices of p, i.e., integers between 1 and m inclusive); the g[[i]] cover the full set 1:m, but they don't have to constitute an exact partition, theycan
2007 Jan 03
1
na.action and simultaneous regressions
Hi. I am running regressions of several dependent variables using the same set of independent variables. The independent variable values are complete, but each dependent variable has some missing values for some observations; by default, lm(y1~x) will carry out the regressions using only the observations without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will be to use
2010 Mar 10
1
Strange result in survey package: svyvar
Hi R users, I'm using the survey package to calculate summary statistics for a large health survey (the Demographic and Health Survey for Honduras, 2006), and when I try to calculate the variances for several variables, I get negative numbers. I thought it may be my data, so I ran the example on the help page: data(api) ## one-stage cluster sample dclus1<-svydesign(id=~dnum, weights=~pw,
2007 Sep 12
1
"Save to File..." option on File menu
Hi. There was an interesting thread about a year ago, called 'Command equivalent of rgui "File, Save to File"?' (http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0553.html) started by Michael Prager, and contributed to by Duncan Murdoch (I didn't notice anything beyond the four entries they posted). The question was how to replicate programmatically the "Save to
2006 Dec 29
1
Failure loading library into second R 2.3.1 session on Windows XP
Hi. I am using R 2.3.1 on Windows XP. I had installed a library package into my first session and wanted the same package in my second session, so I went out to the CRAN mirror and tried to install the package, and got the following message: ********************************************************************* >utils:::menuInstallPkgs() trying URL
2005 Jul 01
4
Lines for plot (Sweave)
Dear List: I am generating a series of plots iteratively using Sweave. In short, a dataframe is subsetted row by row and variable graphics are created conditional on the data in each row. In this particular case, this code ends up generating 17,000 individual plots. In some cases, all student data (this is working with student achievement data) are available and my code below works very well in