Displaying 20 results from an estimated 6000 matches similar to: "How to write efficient R code"
2004 Mar 02
3
error() and C++ destructors
Hi,
I am writing C++ functions that are to be called via .Call() interface.
I'd been using error() (from R.h) to return to R if there is an error,
but then I realized that this might be not safe as supposedly error()
doesn't throw an exception and therefore some destructors do not get
called and some memory may leak. Here is a simple example
extern "C" void foo() {
string
2004 Feb 10
4
The ttest.c example in R under MS Windows
We are trying to compile and run the ttest.c example that comes with R (in
C:\Program Files\R\rw1081\src\library\windlgs\src\ttest.c). After compiling
it with MS Visual C++ we load the DLL with dyn.load.
So far it seems good, but when we try to call it from R (after running
C:\Program Files\R\rw1081\src\library\windlgs\R\windlgs.R) R crashes.
We have tried changing the exports from DLL but have
2005 May 17
2
cumsum on chron objects
Hi,
Is there some alternative to cumsum for chron objects? I have data frames
that contain some chron objects that look like this:
DateTime
13/10/03 12:30:35
NA
NA
NA
15/10/03 16:30:05
NA
NA
...
and I've been trying to replace the NA's so that a date/time sequence is
created starting with the preceding available value. Because the number of
rows with NA's following each available
2005 Apr 07
2
newline in lattice axis label
Hi,
I have a 3 panel xyplot with different variables in the y axis. I'm trying
to insert a newline after "Width (cm)," in the ylab argument as in the
example below. My goal is to have the y axis label broken into two lines,
split after the string just mentioned.
plotfun <- function() {
fakedf <- data.frame(A = sample(1:100, 50),
B = rnorm(50),
2005 Feb 23
1
MS Access, Endnote, among others
Hello,
Has anybody been able to successfully install MS Office XP Pro in Wine? I
don't care much about the whole suite, I need MS Access, but since I have
a bundled cd, I don't have much choice. Apparently several folks have had
similar problems in this list, and I haven't found solutions. Wine-version
is 0.0.20041201-1 Debian unstable package.
I'm not sure I'm starting the
2005 Mar 23
2
alternative to 'groups' for lattice bwplot()
Hi,
Is there some alternative to the 'groups' argument in lattice's bwplot
function for boxplots? Say in the example below:
bwplot(yield ~ site | year, data = barley)
you want to have two side by side boxplots per site, corresponding to each
year in the barley data frame. Ideally, the space between boxplots of the
same site should be smaller than that between boxplots of different
2005 Nov 30
3
setting R_LIBS
Hello,
I'm adding a private library tree in my home directory by adding this to
my ~/.Renviron:
R_LIBS="~/R/library:${R_LIBS}"
so that once in R:
R> cat(Sys.getenv("R_LIBS"), "\n")
~/R/library:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
Is this the best way to proceed?
Cheers,
--
Sebastian P. Luque
2005 Feb 22
6
rodbc or unixodbc error
Hi,
I'm trying to establish a connection to a MySQL database, and am using the
rodbc package for it. This is in a GNU/Debian Linux box, with the
corresponding Debian unstable packages. I can login to my MySQL databases
from any shell and directory, so the problem is probably not there. Here's
an example of what I'm doing:
R> odbcConnect("test",
2004 Feb 22
2
nested loop
Hi all,
Does anybody know whether one can nest an 'if' statement in a 'for'
loop. According to the results of my code, the for loop is performed
first, but I'm not sure I got something else wrong with my code. I'm
trying to perform the if statement for each step of the for loop. Thanks
in advance.
Best regards,
Sebastian
2004 Feb 18
0
Ang: How to write efficient R code
Hej Lennart,
I would like to add one thing:
Often, there already exists an R function that solves the problem at hand. Instead of writing your own function, search the help files [apropos(), help.search()]. What I some times find difficult though, is guessing what key words will produce relevant search hits...
Mvh
Sixten
>>> <Lennart.Borgman at astrazeneca.com> 2004-02-17
2002 Apr 16
2
Multithreading
Hi !
I wonder if the R application is capable of utilizing more than one CPU. I
need to know since we run it on a SunFire 3800 with 8 750 USIII cpu:s and on
a E420R with 4 USII cpu:s and we don't feel like we get the performance we
could expect.
I've seen some old discussions claiming that it isn't.
With kind regards
Lennart Araskoug
2006 Jul 14
2
chron vs. POSIX
Hi,
One of the big decisions when writing code is how to handle dates and
times. Gabor Grothendieck provided an excellent overview of the issue in
his R News 4/1 (2004) article, and many users and developers are probably
using it as a guide. The proposed guideline is to use the simplest class
required; as Gabor put it "use Date if possible, otherwise use chron, and
otherwise use
2002 Apr 16
1
Benchmarks
Hi !
Is there anyone that has any current benchmark results from Sparc CPU's ?
I'm mostly interested of US-III 750 and US-II 450, But any US-II/III would
be interesting.
Regards
Lennart Araskoug
Astra Zeneca R & D
Lund, Sweden
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
2011 May 25
1
L-BFGS-B and parscale in optim()
Hi,
When using method L-BFGS-B along with a parscale argument, should the
lower and upper bounds provided be on the scaled or unscaled values?
Thanks.
Cheers,
--
Seb
2006 Mar 15
3
concatenating factor from list
Hi,
I've run into a ridiculous problem I can't find any solutions for in the
archives or help pages:
data(barley)
cutYield <- with(barley, by(yield, variety, cut, breaks = c(0, 30, 60, 90)))
As in this example, I'm using 'by' to return a factor for each level of
another factor. The problem is that 'by' returns a list of the factors,
and I need all these factors
2009 Nov 05
3
Bhattacharyya distance metric
I need to use the Bhattacharyya distance metric to determine population
separation. Has anyone written a Bhattacharyya distance metric function in
R?
--
View this message in context: http://old.nabble.com/Bhattacharyya-distance-metric-tp26221259p26221259.html
Sent from the R help mailing list archive at Nabble.com.
2006 Sep 26
3
standardization of slot access
Hi,
I'm usually confused about when to use 'slot' or '@'. I've frequently
read that it's always preferable to use accessor functions, so I would
think the '@' operator should be avoided. However, ?slot contains the
following advise:
"Generally, the only reason to use the functional form rather than the
simpler operator is _because_ the slot name has to
2005 Sep 20
3
annotating an axis in bwplot (lattice)
Hi,
I'd like to add, say, the sample size for every group in a bwplot as a
parenthetical annotation to the axis. Here's a sketch:
--8<---------------cut here---------------start------------->8---
require(Hmisc)
age <- sample(1:100, 1000, replace = TRUE)
sex <- gl(2, 8, 1000, c("Male", "Female"))
grp <- gl(4, 6, 1000, letters[1:4])
bwplot(grp ~ age |
2016 Feb 06
1
building R Devel --enable-R-shlib
On Fri, 5 Feb 2016 06:29:46 -0600,
Dirk Eddelbuettel <edd at debian.org> wrote:
> On 4 February 2016 at 22:56, Sebastian P. Luque wrote:
>> Hello,
>>
>> It has been a while since my last R Devel build, and now I'm running
>> into an issue I'm not sure how to isolate. After updating to the
>> latest SVN sources, and using:
>>
>>
2005 Oct 04
1
pdf plotting of splom
Hi,
The following code produces a plot on X11:
splom(~iris[1:4], groups = Species, data = iris,
panel = panel.superpose,
key = list(title = "Three Varieties of Iris",
columns = 3,
points = list(pch = super.sym$pch[1:3],
col = super.sym$col[1:3]),
text = list(c("Setosa", "Versicolor", "Virginica"))))
However,