Displaying 20 results from an estimated 2000 matches similar to: "Function to do multiple named lookups faster?"
2009 Mar 23
3
read in large data file (tsv) with inline filter?
I have a very large tab-delimited file, too big to store in memory via
readLines() or read.delim(). Turns out I only need a few hundred of those
lines to be read in. If it were not so large, I could read the entire file
in and "grep" the lines I need. For such a large file; many calls to
read.delim() with incrementing "skip" and "nrows" parameters, followed by
grep()
2010 May 21
1
escape character OK in R environment, fails in R CMD CHECK
Hi,
I am trying to check a package via R CMD CHECK and it is failing with
Error: '\s' is an unrecognized escape in character string starting "\s"
The culprit looks something like this:
gsub('\\s\\(.*\\)',"","this is a (test, man) dude")
which is correctly escaped with the "\\"'s -- but it seems that R CMD
CHECK is pre-escaping the
2007 Sep 29
1
templates with same name before extension are cached
Hi all,
I was just wondering if this is the intended behavior. Here is my setup:
controller
def index
respond_to do |f|
f.xml { render :xml => true }
f.html { render :layout => :none }
end
end
In my views I have a file for each type
index.herb
index.xerb
The first request I send is cached and interferes with the other one.
For example, if I send an xml request
2025 Mar 30
1
Creating model formulas programmatically
Gabor, Duncan, et. al.
1. Thank you for your great comments and solutions. This is what I was
hoping for!
2. Duncan: I completely agree with your criticisms. In fact, I realized the
for() loop only needed the <- assignment, but your comment is important to
note. However, I didn't like the for() loop either; I *much* preferred your
Reduce() solution which is exactly the sort of elegant
2011 Feb 19
1
Accessing Package NEWS (NEWS.Rd)
Okay. So, after having spent quite some time never really tracking down
why my package NEWS files were unacceptable to readNEWS(), I
noticed that there was recent (to me anyway) development that allowed
the NEWS to be done as an Rd file. Sweet! A more standard format...
I converted a NEWS file in one of my unreleased packages to Rd format.
checkNEWS() gave it a thumbs up.
But then it went south.
2007 Jun 01
2
Getting names of objects passed with "..."
Is there a tidy way to get the names of objects passed to a function via the
"..." argument?
rbind/cbind does what I want:
test.func1 <- function(...) {
nms <- rownames(rbind(..., deparse.level=1))
print(nms)
}
x <- "some stuff"
second <- "more stuff"
test.func1(first=x, second)
[1] "first" "second"
The usual
2015 May 13
1
Why is the diag function so slow (for extraction)?
As kindly pointed out to me (oh my decaying gray matter), is.object()
is better suited for this test;
$ svn diff src/library/base/R/diag.R
Index: src/library/base/R/diag.R
===================================================================
--- src/library/base/R/diag.R (revision 68345)
+++ src/library/base/R/diag.R (working copy)
@@ -23,9 +23,11 @@
stop("'nrow' or
1999 Aug 18
2
diag()
I would like to suggest a slight modification to diag(). In the case
where x is a matrix with both row names and column names the same, it
would be reasonable if the resulting vector also had those names. I often
use diag() on variance matrices, where this modification is helpful.
The modification requires replacing
if (is.matrix(x) && nargs() == 1)
return(c(x)[1 +
2005 Oct 19
3
diag() problem
Hi
I have a matrix "u", for which diag() gives an error:
u <- structure(c(5.42334674128216, -2.31319389204264, -5.83059042218476,
-1.64112369640695, -2.31319389212801, 3.22737617646609,
1.85200668021569,
-0.57102273078531, -5.83059042231881, 1.85200668008156,
11.9488923894962,
-3.5525537165941, -1.64112369587405, -0.571022730886046,
-3.55255371755604,
2025 Mar 30
1
Creating model formulas programmatically
Another solution. reformulate + substitute + as.formula:
substitute(~ (.)^2, list(. = reformulate(somenames)[[2]])) |> as.formula()
On Sat, Mar 29, 2025 at 5:31?PM Bert Gunter <bgunter.4567 at gmail.com> wrote:
>
> Note: I am almost certain that this has been asked and answered here
> before, so my apologies for the redundant query.
>
> I also know that there are several
2003 May 21
2
moving onto returning a data.frame?
I've been studying some of the code and I'm still a little shakey on the
proper method for returning a data.frame from a C function (which is my
ultimate goal here). I've started some code that I've "stolen" from the
archives and I'm running into crashes, etc. I've been trying to gleen some
insight from the src/main/scan.c file and didn't find many comments in
2008 May 08
3
Setting matrix dimnames in a list
Hey All,
I was wondering if I could solicit a little input on what I'm trying to
do here. I have a list of matrices, and I want to set their dimnames,
but all I can come up with is this:
x <- matrix(1:4,2)
y <- matrix(5:8,2)
z <- list(x,y)
nm <- c("a","b")
nms <- list(nm,nm)
z <- lapply(z,function(x)dimnames(x)<-nms)
As you can see, this
2025 Mar 29
4
Creating model formulas programmatically
Note: I am almost certain that this has been asked and answered here
before, so my apologies for the redundant query.
I also know that there are several packages that will do this, but I wish
to do it using base R functions only (see below).
The query: Suppose I have a character vector of names like this:
somenames <- c("Heigh", "Ho", "Silver", "Away")
2011 May 07
1
spdep::poly2nb problem
I downloaded a US states+territories shapefile from
http://www.weather.gov/geodata/catalog/national/html/us-state.htm
and unzipped it into my working directory.
Then in R (version 12.2.0 for ms-win32):
library(rgdal) # Version: 0.6-28
library(spdep) # Version: 0.5-24 (loads sp: Version: 0.9-72)
# read in the data
states<-readOGR(".","s_01de10")
summary(states)
# now
2012 Mar 03
0
removing data look-ahead, something faster.
Hello,
Thank you for your help/advice!
The issue here is speed/efficiency. I can do what I want, but its really
slow.
The goal is to have the ability to do calculations on my data and have it
adjusted for look-ahead. I see two ways to do this:
(I'm open to more ideas. My terminology: Unadjusted = values not adjusted
for look-ahead bias; adjusted = values adjusted for look-ahead bias.)
1) I
2012 Mar 26
2
read.csv and field containing single quotes
I need to read in csv files, created by 3rd party, with fields
containing single quotes (as shown below).
"header1","header2","header3","header4"
"field1r1","field2r1","field3r1","field4r1"
"field1r2","field2r2","field3r2PartA), field3r2PartB Very" Long","field4r2"
2012 Dec 17
2
Suggestion: 'method' slot for format.ftable()
Dear R-developers,
I would like to suggest a 'method' slot for format.ftable() (see an adjusted
'format.ftable()' below, taken from the source of R-2.15.2).
At the moment, format.ftable() contains several empty cells due to the way the
row and column labels are printed. This creates problems (= unwanted empty
columns/rows) when converting an ftable to a LaTeX table; see an
2005 Sep 27
2
Integration with NMS AG-E1/T1
I want to replace a custom PBX, that is infront on a IVR system based on OLD NMS AG-E1 Card.
The Cards is configurated with CAS Digitalmode, someone can give me some info about Digim Cards CAS configuration i need a conversion Table?
I wanto to don't touch configuration on winbox, i want only replace HWPBX box with asterisk.
Diagram
Telco E1 ===>Proprietary PBX========(CAS)===>IVR
2009 Mar 23
1
using xyplot
Dear R-sians!
I am trying generate a bunch of xyplots
library(lattice)
myPanel <- function(x,y,xl=range(x),yl=range(y),...) {
panel.xyplot(x,y, pch=20,col='blue',cex=0.7,xlim=xl,ylim=yl,...)
panel.abline(v=0, col='gray30',lty=2,lwd=1.5,...)
panel.loess(x,y,
span=2/3,family='gaussian',normalize=T,col='red',lwd=1.5,...)
#
2025 Mar 30
1
[External] Creating model formulas programmatically
As always, I would like to thank all who responded for their insights and
suggestions. I have learned from them.
Thus far, my own aesthetic preference -- and therefore not to be considered
in any sense as a "best" approach -- is to use Duncan's suggestion to
produce the call directly with call() rather than substitute in my simple
for() loop; i.e.
somenames <-