similar to: is there a way to recursilvely lapply

Displaying 20 results from an estimated 10000 matches similar to: "is there a way to recursilvely lapply"

2009 Mar 31
4
what is the preferred method to create a package local variable?
for the moment, I'm using: .onAttach <- function(libname, pkgname) { .bbg.db.conn <<- dbConnect(dbDriver("PostgreSQL"), user="blah","blah") } .onUnload <- function(libpath) { dbDisconnect(.bbg.db.conn) } which results in a hidden global variable in the global environment. I would prefer to make the assignment only in the package namespace.
2003 Sep 17
3
Building and loading a DLL on Windows NT
I am trying to build a simple dll with Rcmd SHLIB to link into R. The results of the build are below. From my limited knowledge of building DLLs, it looks like it worked (I didn't get any errors). F:\R\dlls> Rcmd SHLIB add.C making add.d from add.C g++ -IC:/PROGRA~1/R/src/include -Wall -O2 -c add.C -o add.o ar cr add.a *.o ranlib add.a g++ --shared -s -o add.dll add.def add.a
2017 Jan 03
2
[R] Problems when trying to install and load package "rzmq"
On Tue, Jan 3, 2017 at 3:53 PM, Whit Armstrong <armstrong.whit at gmail.com> wrote: > > I maintian the rzmq project. > > love to get it running on windows, but zmq doesn't play nicely with R's > mingw. It's fairly easy to link against the libraries from rwinlib: https://github.com/rwinlib/zeromq. I'll send you a pull request later this week to fix the binary
2006 Jul 27
3
deparse(substitute(foo))
I see that plot.default uses deparse(substitute(x)) to extract the character name of an argument and put it on the vertical axis. Hence: foo <- 1:10 plot( foo ) will put the label "foo" on the vertical axis. However, for a function that takes a "..." list as an input, I can only extract the first argument name: x <- 1:10 y <- 10:20 foo <- function(...) {
2004 Sep 09
4
scoping rules
Can someone help me with this simple example? sq <- function() { y <- x^2 y } myfunc <- function() { x <- 10 sq() } myfunc() executing the above in R yields: > myfunc() Error in sq() : Object "x" not found I understand that R's scoping rules cause it to look for "x" in the environment in which "sq" was defined (the global environment in
2003 Aug 13
1
Problems with addition in big POSIX dates
Have you noticed any problems with big dates (>=1/1/2040) in R? Here is the bit of code that I'm having trouble with: > test.date <- strptime("1/1/2040",format="%m/%d/%Y") > > unlist(test.date) sec min hour mday mon year wday yday isdst 0 0 0 1 0 140 0 0 0 > > date.plus.one <- as.POSIXct(test.date) +
2008 Nov 18
2
anyone familiar with this error?
[whit at linuxsvr R.packages]$ sudo R CMD INSTALL portfolio.construction * Installing to library '/usr/local/lib64/R/library' * Installing *source* package 'portfolio.construction' ... ** R ** preparing package for lazy loading Loading required package: fts Loading required package: quadprog Loading required package: Rexcelpoi terminate called after throwing an instance of
2012 May 17
2
test suites for packages
Can anyone share some opinions on test suites for R packages? I'm looking at testthat and RUnit. Does anyone have strong opinions on either of those. Any additional packages I should consider? Thanks, Whit
2006 Jul 26
2
RODBC on linux
Anyone out there using Linux RODBC and unixODBC to connect to a Microsoft SQL server? If possible can someone post a sample .odbc.ini file? I saw a few discussions on the archives a few years ago, but no config file details were available. Thanks, Whit This e-mail message is intended only for the named recipient(s) above. It may contain confidential information. If you are not the intended
2008 Oct 28
2
color individual bar of histogram?
Anyone know a quick way to color one bar of a histogram? I want to mark the bar in which the most recent observation falls. So, for instance: x <- rnorm(100) latest.ob <- x[100] hist(x) ## how do I mark the bucket that latest.ob falls into? Thanks, Whit
2007 May 16
2
substitute "x" for "pattern" in a list, while preservign list "structure". lapply, gsub, list...?
I am experimenting with some of the common r functions. I had a question re:using "gsub" (or some similar functions) on the contents of a list. I want to design a function that looks at "everything" contained din a list, and anytime it finds the text string "pattern" replace it with "x". I also wish to preserve the "structure" of the original
2004 Oct 25
1
copyright issues when package maintainer changes
I will be taking over as maintainer of the its package from Giles Heywood. The code was originally written while he was working at Commerzbank. I have added the header below to the top of the R source file to indicate the changes in the copyrights for the code. The package was originally released under GPL2. I have no experience with copyright issues, and would appreciate it if someone who does
2008 Dec 09
1
any suggestions to deal with 'Argument list too long' for a R CMD check?
Since, gcc was using upwards of 2gb of ram to compile my package, I just split all the functions into individual files. I guess I'm too clever for myself, because now I get hit with the "Argument list too long" error. Is there a way to deal with this aside from writing my own configure script (which could possibly feed the gcc commands one by one). -Whit RHEL 5 [whit at
2004 Aug 19
2
proposed change to [.POSIXct
R developers, The "tzone" attribute is stripped from a POSIXct object when the subscript command is called ("[.POISXct"). This results in dates being printed in the locale specific format after a subscript operation is applied to a POSIXct object which has cause several problems for me in the past. Here is an example of this problem under R 1.9.1: > x <-
2005 Mar 02
2
apply a function to a rolling subset of a vector
Try this: > ?convolve > x<-rnorm(1000) > y<-rep(1,20) > z<-convolve(x,y,type="filter") > plot(x,type="l") > str(z) num [1:981] 6.31 7.28 8.16 7.39 4.65 ... > lines(c(rep(0,10),z,rep(0,10)),col="yellow",lwd=3) > lines(c(rep(0,10),z,rep(0,10))/length(y),col="red",lwd=3) #running mean You wrote: Does anyone know an easy way
2008 Oct 29
1
builtin to filter a list?
I know it's easy to write a simple loop to do this, but in the spirit of lapply, I thought I would ask if there is a builtin to filter or take a subset of a list based on a predicate in a similar way to the Erlang lists:filter/2 function: http://www.erlang.org/doc/man/lists.html#filter-2 filter(Pred, List1) -> List2 Types: Pred = fun(Elem) -> bool() Elem = term() List1 = List2 =
2004 Dec 29
2
help with Rcmd check
I've been working on a package that requires a shared library to be loaded. I have used the NAMESPACE file to load the library according to: http://cran.r-project.org/doc/manuals/R-exts.html#Load%20hooks <http://cran.r-project.org/doc/manuals/R-exts.html#Load%20hooks> my shared library is "excelpoi.so" hence I have added "useDynLib(excelpoi)" to my NAMESPACE file.
2005 May 14
2
help with eval
I've been looking at the help page for eval for a while, but I can't make sense of why this example does not work. show.a <- function() { a } init.env <- function() { a <- 200 environment() } my.env <- init.env() ls(envir=my.env) # returns this: # > ls(envir=my.env) # [1] "a" # but this does not work: eval(expression(show.a()),envir=my.env) # >
2006 Sep 22
2
behavior of [<-.foo
Can someone help me understand the following behavior of "[<-" ? If I define a simple class based on a matrix, the [<- operation only inserts into the first column: > x <- matrix(rnorm(10),nrow=5,ncol=2) > class(x) <- "foo" > "[<-.foo" <- function(x, i, j, value) { + if(missing(i)) i <- 1:nrow(x) + if(missing(j)) j <-
2012 Apr 12
1
deferred call
I must admit I'm a little ashamed to have been using R for so long, and still lack a sound understanding of deferred calls, eval, deparse, substitute, and friends. I'm attempting to make a deferred call to a function which has default arguments in the following way: call.foo <- function(f) { x <- f() } x <- 1:10 f <- function(x=x) { x^2 } call.foo(f) However, I'm