Live data from Hacker News

Snippets of code for things you do all the time in R

4dpiecharts.com

1–10 of 14 posts

Re: Snippets of code for things you do all the time in R

#3
post #2

shameless plug: My book R Graph Cookbook is out soon - https://www.packtpub.com/r-graph-cookbook/book . It contains recipes for doing things with graphs, which can sometimes be obscure, annoying and time consuming.

Interesting - do you have a sample chapter you can make public?

(if there already is on the site you linked to, sorry for being obtuse).

Re: Snippets of code for things you do all the time in R

#4
post #2

shameless plug: My book R Graph Cookbook is out soon - https://www.packtpub.com/r-graph-cookbook/book . It contains recipes for doing things with graphs, which can sometimes be obscure, annoying and time consuming.

Interesting - do you have a sample chapter you can make public? (if there already is on the site you linked to, sorry for being obtuse).

Sample chapter coming up shortly. If you don't see it on the linked page in a couple of days, please email me (in profile).

Re: Snippets of code for things you do all the time in R

#7

Clearly more a comment for an R forum, but why the hell does anybody bother using '<-' instead of '='? Are you trying to obfuscate?

Using 'The operator ‘ That being said, some R community members still use '=' for assignment, but it's frowned upon. It certainly annoys me when I see it in R code.

Simple example to show when '=' won't work but '

  system.time(vec1 
And to demonstrate that you need to use '=' for argument passing:

  x 
[1] Type help('=') at an R prompt, or view it online: http://stat.ethz.ch/R-manual/R-patched/library/base/html/ass...

[2] http://www.burns-stat.com/pages/Tutor/R_inferno.pdf

edit: clarified statement.

edit: added examples.

Re: Snippets of code for things you do all the time in R

#8

Clearly more a comment for an R forum, but why the hell does anybody bother using '<-' instead of '='? Are you trying to obfuscate?

Using ' The operator ‘ That being said, some R community members still use '=' for assignment, but it's frowned upon. It certainly annoys me when I see it in R code. Simple example to show when '=' won't work but ' system.time(vec1 And to demonstrate that you need to use '=' for argument passing: x [1] Type help('=') at an R prompt, or view it online: http://stat.ethz.ch/R-manual/R-patched/library/base/html/ass... [2…

I am of the opposite opinion, but perhaps I can be converted.

Do you have an example of where it would be required to use '<-'? Not just median(x <- 10), but a use in which there no simple '=' alternative.

Re: Snippets of code for things you do all the time in R

#9

Clearly more a comment for an R forum, but why the hell does anybody bother using '<-' instead of '='? Are you trying to obfuscate?

My understanding has always been that <- is the way that S did it, so that's the way R originally did it but = is almost always equivalent. I haven't found a place in my modest R hacking yet that = hasn't worked the way I expected it to...

Re: Snippets of code for things you do all the time in R

#10

Earlier quoted context omitted.

Using ' The operator ‘ That being said, some R community members still use '=' for assignment, but it's frowned upon. It certainly annoys me when I see it in R code. Simple example to show when '=' won't work but ' system.time(vec1 And to demonstrate that you need to use '=' for argument passing: x [1] Type help('=') at an R prompt, or view it online: http://stat.ethz.ch/R-manual/R-patched/library/base/html/ass... [2…

I am of the opposite opinion, but perhaps I can be converted. Do you have an example of where it would be required to use '<-'? Not just median(x <- 10), but a use in which there no simple '=' alternative.

I've added some examples to my above comment. My example is perhaps a little closer to 'median(x <- 10)' than you were asking for, but I think it illustrates the point that using '=' will not always have the desired result in places where '<-' would.
Post reply on HN