Displaying 20 results from an estimated 10000 matches similar to: "scoping rules"
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
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) +
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.
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)
# >
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(...) {
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
2008 Dec 11
2
is there a way to recursilvely lapply
for a simple example:
x <- list()
x[["a"]] <- list(a=c(1,2,3),b=c(3,4,5))
x[["b"]] <- list(a=c(6,7,8),b=c(9,10,11))
lapply(x,sum)
this fails w/
Error in FUN(X[[1L]], ...) : invalid 'type' (list) of argument
Just wondering if I have overlooked something obvious.
one can also do:
lapply(x,lapply,sum)
but that assumes that you already know how many levels
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
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
2002 Aug 03
2
variable scope
Dear R-guRus:
I would like to pass variables to a function in R in "by reference",
e.g Fortran style.
For example, suppose I have the following code
x<-c(1:10)
y<-1
MyFunc<-function(x,y) {y<-sum(x); return(NULL)}
MyFunc(x,y)
print(y)
in this case print(y) will produce "1" instead of 55 (which is sum(x)) -
how do I make sure that afte the function is run, y
2002 Aug 03
2
variable scope
Dear R-guRus:
I would like to pass variables to a function in R in "by reference",
e.g Fortran style.
For example, suppose I have the following code
x<-c(1:10)
y<-1
MyFunc<-function(x,y) {y<-sum(x); return(NULL)}
MyFunc(x,y)
print(y)
in this case print(y) will produce "1" instead of 55 (which is sum(x)) -
how do I make sure that afte the function is run, y
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 =
2010 Mar 31
2
Simplifying particular piece of code
Hello, everyone
I have a piece of code that looks like this:
mrets <- merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret="BMM.AV120",
stdev="BMM.SD120"))
mrets <- merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret="GM1.AV120",
stdev="GM1.SD120"))
mrets <- merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret="IYC.AV120",
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.