« first day (622 days earlier)      last day (2553 days later) » 

10:01 AM
Meh, can't find where I read about how to include a custom pdf as vignette for a package.
Thanks for listening, I found it after complaining: cran.r-project.org/web/packages/R.rsp/vignettes/…
 
10:20 AM
Another way is to include a ghost Rnw vignette that includes your primary file.
% \VignetteIndexEntry{vignette}
% \VignetteKeywords{keywords here}
% \VignettePackage{package name}

\documentclass[a4paper]{article}
\usepackage{hyperref}
\usepackage{pdfpages}
\begin{document}
\includepdf[fitpaper=true,pages=-]{vignette-source.pdf}
\end{document}
This is actually the solution I used in the past.
 
10:39 AM
Are the kool kids using knitr for vignettes now?
Ripley says (re: includepdf) "but we are working on
ways to avoid such subterfuges"
Curses!!!
 
11:02 AM
gentlepersons, the artist formerly known as gsk3 greets you
 
11:23 AM
Hallo, @gsk3
 
@Andrie's @ echos in the vast wasteland that is abandoned screennames
 
11:59 AM
is my comment too harsh?
0
Q: how can I extract the distances between the points after a Delaunay Triangulation with deldir in R?

AnnemarieI would like to calculate distances between cities using Delaunay Triangulations. I have the longitudes and latitudes of the twenty cities I would like to calculate distances between, but I have some trouble figuring out how to extract the distance information out of the triangulation. I've used ...

 
12:14 PM
@Ari B. Friedman No not harsh at all. The user has had plenty of help on previous questions and in many cases not even bothered to mark them as answered.
 
@Spacedman Guilty as charged. :)
 
Hi everybody!
 
12:33 PM
I'm not everybody, but hello to you to all the same, @JoshuaUlrich!
 
12:57 PM
hi @JoshuaUlrich
@joran but are you somebody? surely you're not a nobody?
 
This is a little story about four people named Everybody, Somebody, Anybody, and Nobody.

There was an important job to be done and Everybody was sure that Somebody would do it.

Anybody could have done it, but Nobody did it.

Somebody got angry about that because it was Everybody's job.

Everybody thought that Anybody could do it, but Nobody realized that Everybody wouldn't do it.

It ended up that Everybody blamed Somebody when Nobody did what Anybody could have done
4
 
Quick question about including data into a package. When I do R CMD check I get an error when I load(my.data), but my.data.rda is in /data directory. Any tips?
 
Have you declared my.data in the documentation?
I.e., my.data should have its own documentation .Rd file.
 
Hum, good point.
Forgot about that one.
 
I use roxygen to do that job for me. I can post an example if you can't find one.
 
1:05 PM
It's a documentation package with 2 functions and one data set and everything is set to go, but thanks for offering!
 
@gsk3 I think sometimes I'm not somebody, anybody, everybody or nobody. I'm just a body.
Huh. A SO question about a potential bug, that's actually a bug? That doesn't happen every day.
 
s/every/any
 
@joran the utf-8 one?
 
No, the all.equal one that @Andrie and @JoshuaUlrich just answered.
 
@joran For the record, I totally answered that first... by nearly a full minute.
 
1:14 PM
@JoshuaUlrich Don't exaggerate. It was only 58 seconds. And only because I posted an example.
PS. I'm filing a bug report on R bugzilla
 
@Andrie Now you're just bragging.
 
Just wanted to be first at something...
 
I'm first loser.
 
@JoshuaUlrich Reminds me of a conversation I had with my late grandmother about my shortness. She commented that all work is near the ground anyway. It kind of made me feel like first loser. :)
 
@JoshuaUlrich Andrie's answer had three more dots. That takes at least another second or two to type.
 
1:25 PM
I have filed my first R bug report:
 
Has anyone tried using readline when documenting examples in a package?
At least somebody had to try this. I refuse to believe that nobody ever had to make the example a bit interactive. I think everybody agrees on that.
 
@Andrie Congrats!
@RomanLuštrik Wouldn't it cause issues with R CMD check ?
 
@AriBFriedman Thanks. Now I'm anxiously waiting for a response saying I haven't read the FAQs...
 
though how does R CMD check deal with example(readline) ?
oh dur, if (interactive())
carry on
 
@mdsumner I think you've found @RomanLuštrik's answer
 
1:32 PM
I usually get there eventually
 
@Andrie I think bug reports involving message dispatch are unlikely to be answered in the FAQ :-)
@mdsumner 58 seconds before me in this case.
 
and I still don't have my copy of R for Dummies yet
 
I gave Uwe Ligges a copy of R for Dummies on Friday. He just laughed when he saw the title. I had to point out that I didn't write it with him in mind as the target reader!
He's a nice guy :-)
 
that is a funny idea
a complementary copy for R-core
cue jokes on Diplomacy for Dummies
 
I have a function from a package that produces a lot of output when you run summary, even when you save it to an object. How annoying.
And they're result of print, which means I can't suppressMessages on their heiny (my spell checked offered me to replace heiny with Heinrich).
 
1:44 PM
Heinz means farts
Damn spell check!
 
@mdsumner Good grief: www.heinzbaby.com
 
@gsk3 What prompted you to reveal your true identity?
 
@Andrie I bet he was impressed by Gavin, Joris, Joshua and other brave partisans.
 
@RomanLuštrik I only hide behind women and/or children in dangerous situations, but never behind a fake name on the internet. That's just cowardly.
2
 
2:18 PM
@Andrie Was revising CV and put my SO credz on there. Realized I would have to reveal my nickname to academic audiences, which was scarier than revealing my real name to y'all.
@JoshuaUlrich Trying to reinterpret "someone is wrong on the internet" comic in light of earlier conversation about somebody, anybody, nobody
 
@AriBFriedman Haha, that xkcd comic is a classic.
 
indeed
there should be a "most massive overkill" badge:
3
A: R: Replacing negative values by zero

Ari B. FriedmanThanks for the reproducible example. This is pretty basic R stuff. You can assign to selected elements of a vector (note an array has dimensions, and what you've given is a vector not an array): > pred_precipitation[pred_precipitation<0] <- 0 > pred_precipitation [1] 1.2091281 0.0...

or would I have to write a competitor to Rcpp to solve this problem to win that?
 
@AriBFriedman That's simply awesome. I'd up-vote again, if I could...
 
@JoshuaUlrich Heh. You started it with the benchmarks. Once I see benchmarks, I just keep going, to the detriment of my family, my education, and my career prospects.
 
@AriBFriedman ah ha! Now I know your weakness...
 
2:30 PM
case in point:
18
A: How to sort a dataframe by column(s) in R

Ari B. FriedmanI recently added sort.data.frame to a CRAN package, making it class compatible as discussed here: Best way to create generic/method consistency for sort.data.frame? Therefore, given the data.frame dd, you can sort as follows: dd <- data.frame(b = factor(c("Hi", "Med", "Hi", "Low"), le...

the first clue should have been that I wrote autoplot.microbenchmark so I could add pretty benchmark results to SO
 
@AriBFriedman I should ask a question about what the fastest way is to benchmark R functions. That would keep you busy for a while.
 
@joran Then Google recursion...
 
Haha....oh Google, you're so cute!
 
@joran Well, we could at least quibble about the most accurate way to benchmark things. Sys.time, rbenchmark, microbenchmark...fight!
@JoshuaUlrich Ha, I'd never done that before.
Bing's result is not nearly that cute.
hm, another avenue to be obsessed about...is there any way to "benchmark" memory use without going to operating system-level profilers?
 
2:48 PM
@AriBFriedman tracemem. I think Rprof can do it too, but it may be a compile-time option.
 
3:11 PM
@AriBFriedman They have now provided a working example, so part way there.
 
3:40 PM
@GavinSimpson blessed be the expeRts, for they are loving and full of forgiveness
 
3:54 PM
@JoshuaUlrich I took your suggestion to run the loop backwards but it is slower
cpp_ifbackwards_src <- '
Rcpp::NumericVector xa(a);
int n_xa = xa.size();
for(int i=n_xa; i >= 0; i--) {
if(xa[i]<0) xa[i] = 0;
}
return xa;
'
cpp_ifbackwards <- cxxfunction(signature(a="numeric"), cpp_ifbackwards_src, plugin="Rcpp")
p1 <- p2 <- p <- rnorm(100000)
microbenchmark(joshua(p),joshua.c(p),gsk3(p),gsk3.c(p),jmsigner(p),james(p),jmsigner.c(p),james.c(p), cpp_if(p1), cpp_ifbackwards(p2))
expr min lq median uq max
1 cpp_ifbackwards(p2) 104.971 112.1745 114.5120 125.7355 199.047
2 cpp_if(p1) 75.282 81.6165 88.4755 114.7170 600.810
3 gsk3.c(p) 1647.216 1678.7295 1724.6020 1830.9385 69914.939
4 gsk3(p) 1657.383 1692.9730 1724.7395 1792.0550 70990.890
5 james.c(p) 379.637 394.5850 422.8750 2773.3295 68699.095
6 james(p) 377.451 392.9720 424.2115 2734.0540 3330.472
 
@AriBFriedman you changed more than I told you to...
for(int i=n_xa; i<n_xa; i--)
            expr      min        lq    median        uq       max
1        c_if(p)    1.377    4.1780    7.9190    9.8275    14.304
2      cpp_if(p)   18.475   24.3715   28.5940   32.3815    39.394
 
4:12 PM
@JoshuaUlrich Ah. I naively assumed that you were trying to be helpful and impart some secret code optimization technique on the newbie, instead of making a funny joke ;-P.
 
@AriBFriedman Not sure I understand... I wasn't joking. c_if is a C version of your Rcpp solution, but it uses the "backward" loop above.
 
@JoshuaUlrich Care to explain to someone who doesn't know much C or C++ why that's faster?
 
But it's faster because it doesn't do anything?
> p[1:10]
[1] 0.4175930 -0.5249472 0.5586577 -0.6156030 1.5839880 0.4229304 0.1591874 -0.3885089 0.2171432 -0.3685478
> cpp_ifbackwards(p[1:10])
[1] 0.4175930 -0.5249472 0.5586577 -0.6156030 1.5839880 0.4229304 0.1591874 -0.3885089 0.2171432 -0.3685478
because it starts at length(x), goes to length(x)-1, then terminates because i is now <length(x)
no?
 
uh oh... I think I made a boo-boo in my C code
 
Oh noes! The man talonz have failed you! :)
 
4:30 PM
Sorry about that @gsk3...
I have some bad news for you though... there seems to be a bug in your code. p itself gets changed.
> set.seed(21); p <- rnorm(10000)
> head(p)
[1]  0.7930132  0.5222513  1.7462222 -1.2713361  2.1973895  0.4331308
> head(cpp_if(p))
[1] 0.7930132 0.5222513 1.7462222 0.0000000 2.1973895 0.4331308
> head(p)
[1] 0.7930132 0.5222513 1.7462222 0.0000000 2.1973895 0.4331308
I deleted my comment, btw. It was only faster because it wasn't doing anything, but I didn't catch that because I ran your function before I ran mine and your function changed p, so identical(cpp_if(p), c_if(p)) returned TRUE.
this is why it's faster: http://embeddedgurus.com/stack-overflow/2009/03/efficient-c-tips-7-fast-loops/
And also why it won't work in this case... well, it will be fine as long as the first element is non-negative.
 
 
1 hour later…
6:12 PM
@JoshuaUlrich Yeah I noticed it but decided to consider it a "feature" :-)
I believe I need to initialize another variable (call it xr) and modify and then return that rather than xa itself
but...I'm too lazy to go fix it right now
maybe later
 
...maybe a down-vote will motivate you...?
 
@JoshuaUlrich Hey, ref. This guy's abusing his talonz.
@JoshuaUlrich Those are cool tips. Albeit very embedded systems oriented.
 
7:03 PM
@JoshuaUlrich I fixed the feature.
 
I don't understand why that would fix it. xr is initialized the same way as xa.
 
it does though:
> p <- seq(-10,10)
> cpp_if(p)
[1] 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10
> p
[1] -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
I guess the first entry initialized to a gets passed by reference and the second by value?
 
That doesn't make any sense though...
 
ok now it's even weirder
I went back and tested the original version
and now it's not modifying p
but you and I both independently noticed that it was modifying p
 
/me checks again
 
7:16 PM
it's not a typo either; to check I copy/pasted from the original edit on the question just to be sure
 
still changes p for me... I'm using Rcpp0.9.10, you?
 
hm
0.9.10
here's the exact code:
> cpp_if_src <- '
+ Rcpp::NumericVector xa(a);
+ int n_xa = xa.size();
+ for(int i=0; i < n_xa; i++) {
+ if(xa[i]<0) xa[i] = 0;
+ }
+ return xa;
+ '
> cpp_if <- cxxfunction(signature(a="numeric"), cpp_if_src, plugin="Rcpp")
>
> p
[1] -5 -4 -3 -2 -1 0 1 2 3 4 5
> cpp_if(p)
[1] 0 0 0 0 0 0 1 2 3 4 5
> p
[1] -5 -4 -3 -2 -1 0 1 2 3 4 5
 
R-2.15.1?
 
R-2.15.0
 
It doesn't change p using Rcpp-0.9.13 on R-2.15.1. Weirdness.
 
7:22 PM
well it's weirder that nothing changed in my setup (it's even the same console open) and the behavior changed
this is why I generally stay away from C...too much voodoo gives me bad joojoo
 
Calling microbenchmark(cpp_if(p)) changes p
Good times.
I so don't get it.
 
posted a q
0
Q: Rcpp pass by reference vs. by value

Ari B. FriedmanI made a first stab at an Rcpp function via inline and it worked really nicely (thanks Dirk!): R: Replacing negative values by zero The initial version looked like this: library(inline) cpp_if_src <- ' Rcpp::NumericVector xa(a); int n_xa = xa.size(); for(int i=0; i < n_xa; i++) { ...

expect "read the FAQ" soon
enjoy the third tag...
 
7:38 PM
@AriBFriedman You should expect, "post this to rcpp-devel" more than "read the FAQ".
 
@JoshuaUlrich If this were something other than my first attempt at Rcpp, I'd do that
but I'd rather take my pounding here first than bug the developers
the prior (that I'm making a mistake) is still overpowering the likelihood here
 
 
1 hour later…
9:11 PM
@JoshuaUlrich Turns out Dirk knows Rcpp pretty well for some reason. Inconsistency explained.
1
A: Rcpp pass by reference vs. by value

Dirk EddelbuettelThey key is 'proxy model' -- your xa really is the same memory location as your original object so you end up changing your original. If you don't want that, you should do one thing: (deep) copy using the clone() method, or maybe explicit creation of a new object into which the altered object g...

 
@AriBFriedman very nice. I'll have to read that later...
 
if by that you mean it was very nice of @Dirk to answer, then I'll concur :-)
0
Q: Data-driven off-topic migration suggestions

gsk3I am pretty active on the R tag on SO. It's a language designed for statistical programming, so we wind up with a lot of questions that are off-topic for the R tag but on-topic for CrossValidated. Here's the rub. When I vote to close a question as off-topic, the system suggests: Of those, o...

 
9:27 PM
@AriBFriedman The migration suggestions have always been data driven, based on past migrations, site-wide. I'd edit your question slightly to make the part about the suggestions being tag-dependent more obvious. Otherwise meta regulars may jump to conclusions and shut you down.
 
9:40 PM
@joran Suggestion implemented.
 
@joran Finally figured out the asymmetrical fill gradient question. Took me awhile to finally get the arguments right to scale_fill_gradientn. I think I need to submit a documentation patch now that I understand it.
 
10:07 PM
@BrianDiggs Ah, now I see what they meant!
 

« first day (622 days earlier)      last day (2553 days later) »