Why do we use R rather than Excel?
shkspr.mobi
shkspr.mobi
If you need to do something ten times, use hotkeys and shortcuts.
If you need to do something a hundred times, write a script (R).
I usually use the command line as the example for why writing code and scripts are better than the more intuitive and lower-learning-curve GUIs.
If I want to move a file from one folder to another then I just drag it across. Easy.
If I want to move a thousand files from one folder to another, I will benefit from learning `CTRL-A` or shift-clicking (slightly more obscure than the 'intuitive' drag each file across individually or drag a large box around them all to select them).
If I want to move a thousand files beginning with 'UTR-77' and ending with '.csv' then I would benefit from learning `mv UTR-77*.csv $folder`, but I could still do it manually if I didn't know that was an option.
If I want to move a thousand files beginning with 'URT-77' to another folder at a moment's notice or at Thursday 1am, then the only options I really have are scripting.
I almost feel like before people learn the 'basic' stuff as outlined at the beginning of the article, they should be shown some 'magic' that is only really possible with scripting so that it's clear from the outset why you wouldn't 'just use excel'.
Other than that, I usually document some ops/quick read me about how to use or prepare the project
1. Use a file manager with stable sorting [1] (I use Thunar which does this, but I suspect lots of file managers keep the sort order stable).
2. Sort by type.
3. Sort by name.
4. Select the first file named UTR-77.
5. Scroll to the last file, and Shift+Click it.
6. Cut then paste to your desired directory.
[1] - https://en.wikipedia.org/wiki/Sorting_algorithm#Stability
With thousands of files, this won't be particularly fast or easy.
Another way is to hold down the Ctrl key and use the PgDn/PgUp keys to scroll. If you hold down Ctrl+PgDn you can whip through thousands of files quickly. Because you have the Ctrl key down, it won't affect your selection of the first file.
If all you know is two finger touchpad scrolling, then it will be very tedious.
Unfortunately, from observing a number of people - and apps that hide the scrollbars - it seems to me that two finger scrolling has largely taken over from scrollbar scrolling or the scroll keys.
- Remotely accessing a system (terminal or GUI). - An overloaded system (GUI response is ... inconsisstent) - Remotely accessing a system from a touch-based device. An increasingly common scenario. - Walking someone through a process (text is unambiguous). - Repeated operations (something that has to be done multiple times, in multiple directories, on an ongoing basis, on a scheduled basis, reliably, consistently, provably, with documentation and debuggability).
Additionally, the scrollbar seems to be increasingly unpopular. I'm on record as not being happy about this.
https://ello.co/dredmorbius/post/0hgfswmoti3fi5zgftjecq (HN discussion: https://news.ycombinator.com/item?id=21356511)
But the parent comment was responding to a portion of its parent that specifically said "there's no option other than scripting". It sounds like he's responding to that, not making some general claim about the GUI being a better option.
(And then it saves time anyway, because it turns out I had to do the thing 20 more times after all.)
if you're doing something once and once only, maybe it's a candidate for the manual or gui way.
if you think you might do it twice, it's almost certainly time to automate or start programming it.
Anything encountered in business that you encounter more than 1 time is likely to be encountered N times more.
Even this is easier with scripting, especially if you're already used to thinking in wildcards and tab-completion. Scrolling, hunting for files, dragging, clicking: these are inherently clumsier and slower steps, optimized for new-user intuitiveness and simplicity over efficiency. The upfront investment of making your brain think in CLI is fairly high, but once you've done it, there's vanishingly little reason to bother with file browsers. I don't think I've used one in a decade, even with (eg) Nautilus's ability to match wildcards with ctrl+s.
For example, How did I do that magical ffmpeg thing last time? Just hit ctrl-r, type ffmpeg, and keep hitting ctrl-r to find previous examples until I find what I'm after.
I’ve got a bunch of saved notes with various incantations that would become redundant if so!
https://stackoverflow.com/questions/41780746/searching-your-...
Good to double check how to turn off the history size limit before throwing away the post it notes entirely.
Throw them in scripts! Another advantage of using a CLI is that it provides a friction-free path from ad hoc commands to saved commands to messy scripts to properly supported tools. I've ridden this gradient multiple times prfoesssionaly, especially now that I work with a bunch of PhDs who are less comfortable around OSes than I am. It's a good feeling to have such a clean pipeline from "this command/series of commands feels awkward to me" to a reviewed, checked-in tool that becomes a critical part of the team's workflow. The best part is that there's value at every incremental step, so you don't need to invest any organizational effort, which is especially useful in a chaotic execution environment.
I have a few of them glancing at me from the corner of my desktop and I hope to do something "over the summer".
In far manager (freeware, open source) and total commander (commercial, not too expensive, trial available), numpad `+` key open “expand selection” popup, where you can type “utr-77.csv”, and it will select just these files.
Unlike the command line, you can inspect what had been selected before moving these files. You can also use insert/numpad +/numpad - keys to modify the set of files going to be moved/copied/deleted/zipped/etc.
Most file systems and file managers don’t have undo support. It can be important to review what going to happen before actually moving any files.
https://www.theverge.com/2020/8/6/21355674/human-genes-renam... https://stackoverflow.com/questions/165042/stop-excel-from-a...
https://docs.microsoft.com/en-us/office/troubleshoot/excel/f...
"Align numerical precision Excel 2013 and R"
https://stackoverflow.com/questions/39531655/align-numerical...
"Numeric precision in Microsoft Excel"
https://en.wikipedia.org/wiki/Numeric_precision_in_Microsoft...
IEEE 754 just has unintuitive properties.
Kahan (the "father of IEEE 754") has a rant (among many others) about Excel as well, and how it tries to hide some of the floating point complexities more or less successfully:
Floating-Point Arithmetic Besieged by “Business Decisions”
https://carolomeetsbarolo.wordpress.com/2012/07/20/catastrop...
Or:
"OOPS XL Did It Again"
https://carolomeetsbarolo.wordpress.com/2014/06/22/oops-xl-d...
From the Wikipedia article:
"Although Excel can display 30 decimal places, its precision for a specified number is confined to 15 significant figures, and calculations may have an accuracy that is even less due to five issues: round off,truncation, and binary storage, accumulation of the deviations of the operands in calculations, and worst: cancellation at subtractions resp. 'Catastrophic cancellation' at subtraction of values with similar magnitude."
julia> 1e20 + 1000 - 1e20
0.0
julia> 1e20 + 10000 - 1e20
16384.0
Python 3.9.6 (default, Jun 28 2021, 19:24:41)
>>> 1e20 + 1000 - 1e20
0.0
>>> 1e20 + 10000 - 1e20
16384.0The problem described in the article isn't an Excel issue. It is an issue of the geneticist failure to learn the basics of how their tools work.
Empty cells are interpreted as zero, which can be downright catastrophic, if the data is just missing.
this is not just a workaround - it's recommended by Microsoft. because you literally cannot turn this functionality off.
how is that not an "Excel issue"?
This is easily falsifiable. In a "general" cell, when I enter 0002, it gets changed into 2, not just in display, but in actual content. When I change the cell type to text, it'll still be 2. Only if I enter 0002 after changing the type to text is the content kept.
Similar when I want to have the text 3/17 or SEPT1 in a cell, I have to format it before typing or the data does get altered. If you try setting it to "text" after you typed it, you'll get some number that's not very useful to you.
Several other software tools also mess up leading 0s including R if used in a naive way without specifying extra options. My previous comment about this: https://news.ycombinator.com/item?id=25017116
Like R, MS Excel can also preserve leading 0s -- if you specify the option on import. (Click on Excel 2019 Data tab and import via "From Text/CSV" button on the ribbon menu and a dialog pops up that provides option "Do not detect data types" (Earlier version of Excel has different verbiage to interpret numbers as text))
Zip codes aren't numbers, they are strings that happen to contain only numeric characters
If you can learn a language, you could constrain type conversions easily once you have for knowledge.
Its not like there aren’t painful gotchas in other tools- it’s an issue if you aren’t aware of them and if they impact your work.
If it’s big, unusually complex, you probably want a DB before analysis.
If it’s repetitive, or advanced modeling/ml: python/r
People shouldn't do important work in Excel. If it is important, people should be involved who have invested the time in learning something more powerful. Indeed, we could ask they aspire all the way to good practice and store their data in a database and their code in git. But there needs to be a process to verify model correctness no matter what tool is being used and bugs will exist in R as well as in Excel.
To me, R seems more easily inspectable, as all the logic of a program is visible just by looking at text files, where in Excel it's hidden "under the surface", you have to click on cells, look at what's there, go click on other cells that relate to it, remember what you were looking at in the first one that's now invisible, etc.
For anything very complicated though, I'd prefer R, as Excel eventually gets unwieldy. Although, I'm saying that from the perspective of being a reasonably experienced coder. The majority of the population should just use Excel, especially in a work context in non-technical teams. No matter how much you push for R, other people in the team aren't going to see the value and aren't going to go along with it, and your R code will be useless after you've left.
Calling Excel easily inspectable is laughably wrong imho. Just the opposite.
Sounds more like an issue with the skill of average excel users than a feature gap.
R has a beautiful functional ability based on S-expressions, allowing some clever stuff to be done (i.e. tidyverse), incredibly fast (data.table is faster than Python, Julia, Matlab etc).
And as a side note, I believe it's moving down the rankings in the h2o benchmarks [1].
The problem with "things that look like dates being interpreted as dates" comes from not specifying that a column has type "text".
Happened to me multiple times, even when i set each cell as a text.
Seems like copypasting a tab separated values resets the cells to their default state.
Just want to know to avoid future gotchas.
Hold on a second while I go shut down the global economy for two years so we can teach everyone finance person how to program.
https://theconversation.com/economists-an-excel-error-and-th...
Not that this is Excel's fault, but researchers should definitely either seriously learn how to use computer stuff, or just don't.
A person can't drive on the highway without a license, the same rigor should be applied here, especially in academic circles.
Regarding the graphing ability , R may have more power but plotting the graphs in Excel is so much more WYSIWYG.
"The 7 Biggest Excel Mistakes of All Time"
https://www.teampay.co/insights/biggest-excel-mistakes-of-al...
"The financial fails and business risks of spreadsheets"
https://www.webexpenses.com/2020/10/financial-fails-business...
"Nightmare on spreadsheet: take Excel use seriously"
https://www.icaew.com/insights/viewpoints-on-the-news/2020/o...
"Excel – The Dirty Secret"
https://tax.thomsonreuters.co.uk/blog/excel-the-dirty-secret...
"8 Challenges When Using Excel For Accounting"
https://www.senacea.co.uk/post/excel-for-accounting-challeng...
Excel is the closest we’ve come as an industry to building a tool that enables non-programmers to program. If it disappeared tomorrow, as some arrogant posters apparently wish it would, tremendous value would be destroyed. Not just in terms of existing workflows but in terms of new workflows that would not be done in R but instead would be done by hand or not at all.
I've used perl, python, and R for scientific data for a really long time but have always made a concerted effort to avoid Excel. My reasoning feels the same as when people say Java is the best language because it can be run on any device, which is like saying anal sex is the best sex because you can do it with any animal.
Maybe I'm missing out on a great experience, but the notion has always made me uncomfortable.
Please tell me you have said this to someone in a work meeting. This is hilarious.
The steps of an algorithm are reflected by cells that reference cells that reference cells.
I've always thought that every highschooler should be taught how to use Excel properly, it really is a superpower in many contexts.
Excel has PowerQuery too, which is very nice but you hit the ceiling pretty easy. Knime eats a lot of data down the throat with modest PC, Excel really struggles with large datasets, not matter how you use or tune PowerQuery.
I know here in HN people talk down visual programming, but I've done pretty heavy and complicated stuff with it. It would be way more complicated with pandas.
Let's say my volunteer org wants to keep track of events, who volunteered in them, etc. and wants to give an award to the volunteer who gave the most hours. How do you do that in Python? Why would you?
Personally, I'd go to something like haskell or f# though, because of a even better type system IMO.
Altough, for learning it, typescript is probably easier and more applicable in the real world.
It's a trap because once you get comfortable in Excel you have a lot of resistance to try anything more productive than Excel. Seen that numerous times with people who work really fast with Excel yet end up very limited as to what they can actually deal with beyond simple problems.
Basically it grew out of the fact that many of these companies are focused on Windows, given the software of the data readers and laboratory robots.
So it is quite common to have Visual Studio licenses around.
A common pattern for the history of many VB packages I found out across the business units, was software that started in Excel, alongside VBA macros, and eventually was ported into VB.
It is a very hard language and community to get into! The documentation is very sparse. Library documentation is published as PDF (I guess?) and also very sparse. The default `print` behavior is pretty hard to understand. It's 1-indexed and it took me a while to realize every time I think `array[1]` I should write `array[[1]]`. I can't tell the difference between `<-` and `=`.
My guess is that it was probably a great language at some point but is way behind other numeric scripting languages like Julia or Matlab in terms of community attention and language ergonomics.
I know it's highly used but other than legacy reasons I'm not sure why you'd want to learn it over Julia.
I'm also curious to investigate how the aspects I'm critical of differ in Octave.
Edit: totally fair, 1-indexing shouldn't have been a "critique". Lots of languages do that.
Over the last decade, the R community has largely standardized around tools like dplyr, ggplot, tibble, purrr, and so on that make doing data science work way easier to reason about. Much more ergonomic. At my company we switched from using Python to using R for most analytical data science work because the Tidyverse tools make it so much easier to avoid bugs and weird join issues than you get in a more imperative programming environment.
|>
Avoid tidyverse like the plague, except when you can't, or when you don't actually care about the sanity of your code and are happy copy/pasting pre-prescribed snippets without needing to understand let alone modify them.
Consider this example:
# base R
starwars[starwars$height < 200 & starwars$gender == "male", ]
# dplyr
starwars %>% filter(
height < 200,
gender == "male"
)
(Source: https://tidyeval.tidyverse.org/sec-why-how.html)Where'd `height` and `gender` come from in the dplyr version? They're just columns in a DF, not variables, and yet they act like variables... Well that's the dplyr magic baby!
dplyr (and other tidystuff) achieves this "niceness" by doing a whole bunch of what amounts to gnarly metaprogramming[1] -- that example was taken from a whole big chapter about "Tidy evalutation", describing how it does all this quote()-ing and eval()-ing under the hood to make the "nicer" version work. it's (arguably) more pleasant to read and write, but much harder to actually understand -- "easy, but not simple", to paraphrase a slightly tired phrase.
---
[1] IIRC it works something like this. the expressions
height < 200
gender == "male"
are actually passed to `filter` as unevaluated ASTs (think lisp's `quote`), and then evaluated in a specially constructed environment with added variables like `height` and `gender` corresponding to your dataframe's columns. IIRC this means it can do some cool things like run on an SQL backend (similar to C#'s LINQ), but it's not somthing i'd expose a beginner to.> My experience is that this weird evaluation order stuff is only confusing for students with a lot of programming experience who already expect nice lexical scope
fair point, but for the most part, R itself does use pretty standard lexical scoping unless you opt into "non-standard evaluation" by using `substitute`[1]. so building a mental model of lexical scoping and "standard evaluation" is a pretty important thing to learn. after that, the student can see how quoting can "break" it, or at least be able to understand a sentence like "you know how evaluation usually works? this is different! but don't worry about it too much for now". and i think dropping someone new straight into tidyverse stuff gets in the way of this process.
> and even then, base R isn’t any simpler: the confusing evaluation order is built into R itself at the deepest level.
i mean, quoting can't really work without being deeply integrated into the language, can it? besides:
- AFAICT base R data manipulation functions don't use it a lot. [2]
- for the most part, R's evaluation order can be ignored (at a certain learning stage) because it's not observable if you stick to pure stuff, which you probably should anyway.
---
[1] http://adv-r.had.co.nz/Computing-on-the-language.html#captur...
[2] admittedly, stuff with `formula`s is similarly wacky, and if you're doing stats you're going to run into that sooner or later...
But try out this bit of base R:
> hello = function(cats, dogs) { return(cats) }
> hello(100, honk) # where honk has never been defined
> hello(100, print("hello!"))
> hello(100)
---
[1] well, not "natural", but aligned with how math stuff is usually taught/done. in most cases, when asked to evaluate `f(x+1)`, you first do `x+1` and then take `f(_)` of that.
tldr: basically, R passes all function arguments as bundles of `(expr_ast, env)` [called "promises"]. normally, they get evaluated upon first use, but you can also access the AST and mess around with it. AFAIK this is called an "Fexpr" in the LISP world.
(originally i had a nice summary, but my phone died mid-writing and i'm not typing all that again, sorry!)
it's very powerful (at the cost of being slow and, i imagine, impossible to optimize). it enables lots of little DSLs everywhere - e.g. lm() from stats, aes() from ggplot2, any dplyr function - which can be both a blessing and a curse.
One day I’ll have a whole week free so I can sit down and learn an entire graphical grammar so that I can remove the egregious amounts of chart-junk in the ggplot defaults.
The two best reasons to use R, IMO, are that many statisticians write up their new methods in R, so it is a window into current statistical research and practice [0], and that R is home to ggplot and the rest of the tidyverse (or Hadley-verse), a systematic approach to common data analysis tasks.
[0] https://cran.r-project.org/web/packages/available_packages_b...
Just learn it, it's more powerful than the alternatives.
P.S. I'm a Python person and not at all an R fanboy, but it's undeniably more powerful and versatile for data science tasks than Python or Julia.
1. Documentation is accessible via the interpreter. You can type ?funcname to get documentation or ?libname for the entry point for almost every library, or use the Help tab in RStudio, the most common interpreter. Package documentation is typically hyperlinked text and of a high quality. You can also see syndicated versions of library documentation online in HTML format. Here is for instance, the HTML documentation for the stats library (the built-in library which covers most of the statistical functions you want): https://stat.ethz.ch/R-manual/R-patched/library/stats/html/0... or rdocumentation.org or really any dozens of web syndicated versions. The PDF version you mentioned is linked from CRAN, the package repository, but is by no means the only entry point for documentation.
2. The print function -- actually not a single function, but rather a commonly implemented S3 method -- is easy to understand if you understand how the S3 object system in R works and how function dispatch works. What it does depends on the class of the object and whether an S3 print method has been implemented for the class of the object. This is true in most languages. If you're looking to something closer to a bare metal print function you should consider cat, but in general I don't find print confusing at all.
3. The subset operators available in R are documented. Because everything is a function in R, you can easily see the documentation by typing ?`[` or ?`[[` -- both have the same documentation page, which describes the essential difference between the two subsetting operators. This is tricky to learn at first but given that the two operators do different things, both desireable in different contexts, it's sort of difficult to argue this is an ergonomics issue and not a user error. If you want a more hands on discussion of the differences, you can try http://adv-r.had.co.nz/Subsetting.html
4. Assignment, similarly, is documented. You can check ?`=` if you have some concerns or read the documentation online here: https://stat.ethz.ch/R-manual/R-patched/library/base/html/as... The short version is that although <- is idiomatically preferred by style guides, there are basically no contexts where = would do anything different. You may want to be aware of -> and <<- as other assignment operators. The former allows right hand assignment, which is a fun bit of syntax, and the latter overrides the default assignment scope and forces a global which I personally find distasteful.
One final note: the inner workings of any R function for which the implementation is in R can be inspected. Simply type the name of the function and press enter to see the source code of the function. A lot of low level stuff is implemented in C, so you'll find a stub function that calls internal things, but for almost anything else, this is a good way to learn how things work. Like, run-length encoding is implemented in the rle function so just type rle and press enter and voila, you see the full implementation.
R has a number of core language issues and things that are annoying but the ones you named read like you puttered around for 10 minutes and didn't do the kind of basic homework you need to do to learn a new language. I wouldn't complain about what a bad language Go is because I don't understand the distinction between := and = as assignment operators.
Far more severe is the scant documentation online.
Don't take this as an attack on the language or community. I'm a huge fan of Standard ML and it's arguably in a worse state!
I was interested in supporting R in the first place because I knew of its importance (if only vaguely).
Here’s a good example: https://dplyr.tidyverse.org
Equally confused about your take on the community. R community is sort of a perfect example of an inclusive community actively trying to include everyone with organizations like “rladies” for women in tech.
Then I went looking for how to interact with JSON. There's no builtin library I guess but rjson seems to be what people use. There's no official documentation I can find on how to install a package but there are many blog posts. The rjson's only official documentation seems to be in PDF and again it's pretty minimal: https://cran.r-project.org/web/packages/rjson/rjson.pdf.
Again, to be fair, anyone looking into Common Lisp or Standard ML or OCaml would probably feel the exact same way about their ecosystems.
Does it cause a problem for existing users? Probably not. Is it the friendliest thing for first-timers to get into? Probably not. Is that a problem? Again probably not?
There are manuals that you can find there.
R Studio (the IDE): https://www.rstudio.com/
R Studio cheat sheets: https://www.rstudio.com/resources/cheatsheets/
There is usually enough information on stack overflow / stack exchange to get through some questions. There is also a stats specific version that can sometimes be helpful. https://stats.stackexchange.com/
You are talking about documentation for user / community contributed packages. There is a minimum amount of standardization that needs to be followed, but yes, I do agree that the documentation could be better.
Hopefully this helps with installing packages: https://jtleek.com/modules/01_DataScientistToolbox/02_09_ins...
Regarding first timers, I think that once they’re aware of RStudio and the content they put out, learning becomes much more friendly and modern.
Still, I definitely agree and would appreciate a modern manual on base R.
If it’s statistical methods, then you’ll need to look outside of R because R documentation isn’t trying to teach statistical methods.
You can try [1] the series of books teaching statistical methods using R.
In my stats degree we learned R methods alongside the statistical methods. R, to us at the undergrad level, is a fancy calculator. Yes it has functions and can do some “programming,” but it’s purpose is to facilitate using statistical methods and writing up reports.
If the audience of your IDE is programmers who want to do data analysis, then I think that’s a different audience than statisticians, who I think are the majority of users of R. R studio is already a decent IDE that statisticians are familiar with, so it might be a hard group to get to switch.
The syntax in R isn’t great. There are multiple ways of sub setting that depend on the data type you're subsetting.
Many of the top stats programs have notes on R or courses designed to teach R that are freely accessible on the internet.
[1] https://www.routledge.com/Chapman--HallCRC-The-R-Series/book...
Personal opinion, but happy to oblige.
> It is a very hard language and community to get into!
Same. Especially where "Matlab isn't Octave; Octave isn't Matlab" is concerned. Having said that, on stackoverflow at least, the matlab community seems more hostile to octave questions than the other way round.
> The documentation is very sparse.
Octave is actually fairly well documented, but unfortunately this is spread out significantly between manuals, helpstrings, and esoteric gems hidden as comments in the actual source code. However, this tends to be less of a problem, since often enough an equivalent function is documented in matlab, which is typically somewhat better in the documentation aspect. (octave is pretty good too though).
As for R, I think R is actually really well documented; you do kinda have to get used to its documentation format, but once you do there is nothing you'd want to do that you'll find yourself lacking documentation for.
(Proper R, that is. Tidyverse is a slightly different issue; but then again Tidyverse isn't R).
> Library documentation is published as PDF
You can have excellent in-terminal documentation using "?" and "??" (or "help" / "help.search" ). I have never needed to look at external manuals, but, yes, they do exist, typically in PDF form on CRAN. Furthermore, R is very good at accompanying documentation with examples / vignettes/ demos etc.
Octave, in theory, also does the same, but in practice I find many functions don't actually provide the demos. Typically they provide an in-doc example though.
> The default print behaviour is hard to understand.
Indeed. In fact, R seems to have some sort of infatuation with bash commands doing things in R-space, when in fact it would probably have been much more reasonable to leave the bash commands to do bash things. E.g. ls to list variables, rm to remove them, etc. And, yes, 'cat' to effectively print strings on the terminal verbatim, without other markings.
Octave is better here, bash-commands are generally identical within octave. 'print' is provided, but basically it's a wrapper to fprintf.
> It's 1-indexed.
Yes. Yes it is. This is not a bug, it's a feature. Same with octave, and same with julia. 0-indexing makes sense when you're working primarily with structures that depend on offsets (like pointers). 1-indexing is far more appropriate for languages that abstract such offset-based-structures away, and require ordinal, 'human-indexing' logic instead.
> it took me a while to realize every time I think `array[1]` I should write `array[[1]]`
Perhaps the chosen syntax is rather unfortunate, but Octave effectively uses the exact same logic here. If you have a cell array, you can either index it with () to obtain another cell array structure, OR you can index it with {} to obtain the 'contents' of that cell element.
> I can't tell the difference between `<-` and `=`
There are two main differences.
1. "<-" is assignment. "=" is "define" and is only valid at 'top level' of a particular scope; as such, its most appropriate use is to define default arguments in a function's signature. You can use it elsewhere, as long as it's toplevel, but you're discouraged from it.
2. Contrary to '=', the '<-' operator can be interpreted in a way that calls an appropriate 'assignment' function (typically denoted as 'functionname<-' when searching for help). E.g. the line "rows(var) <- x" calls the "rows<-" function, which assigns x to var.rows. It does not evaluate rows(var) first, and then assign x to that.
> My guess is that it was probably a great language at some point but is way behind other numeric scripting languages like Julia or Matlab in terms of community attention and language ergonomics
False. Not sure what else to say about that. Once you start looking you'll be very surprised how active and cutting edge the R ecosystem is. It's just that language-preference seems very compartmentalised within different communities. R happens to be thriving in genomics / psychology crowds, whereas it's virtually unheard of in mainstream CS crowds.
> I know it's highly used but other than legacy reasons I'm not sure why you'd want to learn it over Julia.
Because, it has very interesting language designs. In fact, having effectively learned Julia first and R second, it became obvious to me that many of the aspects that I liked in Julia were effectively ideas taken from R. In fact, even though Julia is often compared to Matlab due to its superficially similar syntax, Julia is probably far more similar to R than matlab/octave.
1 indexing is standard for numerical languages. The documentation is referenced to papers on the statistical method - I find it usually sufficient, but depends on what package you are talking about.
I get that some of the basic operations probably create expressions that are too wordy / very "specific data" intensive. That is, if you took the first step and just did your best to create that code view it would have a lot of stuff conditional on specific things.
But it's the next step that gets interesting. Now that you've got it, in what ways can the visual UI change to have the code view create tighter expressions. Now that you've got this view, how can it become super handy for doing things that today are clunky?
IMO there's an interesting "no-code" path in there somewhere and there's also an interesting "make spreadsheet re-use more powerful." Or maybe not, what do I look like, an Excel engineer? Ha!
Isn't that VBA?
Again, not an expert. I'd expect I've never written one line of VBA. (Yay for me!)
Step-by-step repeatable transformations where the UI records steps and writes code in the background.
Almost exactly what you're talking about, and comes out-of-the-box in the last few versions.
The MS Excel grid with code underneath each cell is declarative (not iterative loop) formulas so what would the ideal "code view" be?
Because of the architecture based on formulas, Excel does already have "Show Formulas" option (keyboard shortcut Ctrl+`) and "Trace Precedents" and "Trace Dependents".
For Excel iterative code like VBA Macros, it does have a typical "code view" (keyboard shortcut Alt+F11).
SQL?
There is, just press Ctrl+`. There's also dependency tracking, sort of debugger.
I don't remember the macro, it was more than a decade ago. Something along the lines of:
function foo(c)
s = c.Formula
' do something with s
foo = s
Then in a cell, I could write something like: =foo(A32)I am well familiar with R, but for simple data manipulation, quick chart, pivot table, usually resort to a spreadsheet program. I maintain my Options Trading Journal in spreadsheet where I record all the Options trade I made, positions I hold, P&L, etc. I just can’t imagine doing that in R.
R starts with CSV, Excel ends with CSV.
I think the problem is more nuanced because Excel can do a lot. There is a large set of use cases and tasks that are possible in Excel but your team would be a lot more efficient and productive using a programming language instead. The trick is to recognise those tradeoffs and it it's not as simple as sticking to Excel as long as things are still possible there.
When running any process in excel after enough times there will be an error. It just depends on whether that error will cost you a lot of money or not.
However, there is also a cost to automating these processes that goes beyond the initial investment. Someone needs to make sure the input data stays clean and coordinate any system-wide changes to the interfaces. This is a new thing that can break whenever system-wide changes get made so data governance becomes a priority.
While Hadley Wickham has done amazing things to make the R language actually useful, Python and Julia are better for data applications. Also, bindings to the R language exist, obviating the need to be tied into it completely. Thus, even if you need the frontier, you have it available to you.
I believe working in pandas/sklearn/jupyter ecosystem is much slower (>50%) if you are doing EDA and statistical modelling (ML) than tidyverse/tidymodels/rstudio. The exception is deep learning and adjacent fields (like computer vision).
Of course Python is better at everything else, so adding an extra languages might or might be worth the hassle.
Attempting to solve a complex analytical problems in Excel is similar to a doctor trying to solve medical problems by reference only to atoms.
Instead doctors use a variety of abstractions: organs, cells, enzyme, etc. to understand and explain a problem.
By using a programming language, we can develop appropriate abstractions to solve our problem in a way which keeps a lid on complexity.
I think this concept does make sense to an advanced Excel user, and can help explain the situations in which they may reach for a different tool. Having made some very complex Excel spreadsheets in the past, I think was aware it can become very difficult to develop them or generalise them further, even before I became a programmer.
The reason I use python scripts instead of spreadsheets for important calculations is that I can unit test the logic extensively and be sure that the code works as expected. This also makes sure I don't break stuff when adding functionalities / refactoring code.
I would never ever use Excel for something important, unless it's completely trivial (e.g., sum/average values of a column).
I assume the same applies to R vs spreadhseets, of course.
I'm particularly interested in "half-way" solutions - something between R and Excel. I've been looking at https://www.causal.app/ - no affiliation but I find their approach similar to a Mac app I like called Numi.
The more complex the analysis, the more reasons there are to get out of Excel.
• Put all the static data first in one section, broken into tables with PDF’s word-boundary logic (the one that allows you to highlight text, despite it being a bunch of individually laid-out graphemes)
• reverse-postorder (topological sort) the formula cells’ definitions, grouping them into “stanzas” by which “tables” of static data they’re transitively touching.
The result would read a lot like the definition of an expert system in Prolog. Facts, then predicates.
R is more of a free and de-bloated SPSS than an alternative to scipy or excel.
1. The language itself isn’t great, but the tidyverse packages are amazing. There’s really not a reason to use R if you’re not going to use tidyverse.
2. It’s integration to make quick webapps, books, Markdown reports, blogs. Is amazing. In a team where we process a lot in Excel, it’s so convenient I can just make a quick webapp that does that task a lot quicker for everyone to use.
I feel the same way, except for the data.table package.
But when you say the language isn't great, what exactly is the problem?
IMO, R is a fascinating language from a programming perspective. The combination of first class environments, lexical scoping, non-standard evaluation and metaprogramming allows for extremely performant and expressive domain specific languages, e.g. data.table, tidyverse and ggplot.
I really like the R tooling. What do you find clumsy about it?
It feels like the reason it’s popular is mostly just people not wanting to update skills
I have the opposite view. I find its the people who complain about R because its a bit different are the ones who are inflexible about learning new skills.
I found my partner, Jess, to be using some fairly niche packages for stats, which admittedly would be harder to replicate in other languages. I personally think it’s fine to use, there’s no harm, but as someone comfortable with many languages, most the people i found debating the pros of R (since this project and it coming up in discussion) often are in non software fields and it’s their only language. I personally wouldn’t choose it over python and i might even consider something old school like Java for similar projects if i didn’t have an audience that only understood the work in R.
In the end we supported an R environment and left its usage up to DS team including any ongoing reports or models and inferences they needed to perform, and encouraged a move to python for any code base that would get thrown back over the fence to us for official support.
There is also an aspect that if you are using a technique you don't really understand you can do the same thing in python and R and compare if the results are the same.
I actually really enjoyed it, there's something a bit magical about taking a task that takes somebody hours to do, and putting it under a single button press, or even running it overnight and having everything ready for them when they start work the next day.
The company I'm at had this process for doing salespersons commissions that would take days to do. It was painful to watch the process the first time I was trained on it. They were sorting rows manually in excel, exporting csv's from the ERP software.
Over a couple of months I worked automation into the project using SQL queries and vba/python, I even automated sending out all the personalized reports to each salesperson. Showed it to my boss last week (he had to run the reports this month) and he was blown away by how much time and energy it saved.
It felt so good to reduce a process that took days to do down to a couple of button clicks.
If I share a computation as a spreadsheet, people already know how to work with the GUI, which is actually quite sophisticated, even if it doesn't prevent you from screwing up. People could extend my spreadsheets, e.g., adding columns to do the same computation on multiple input sets, etc. They could easily extract the output in text format and paste it into something else. And so forth.
A Python program with GUI created the expectation that I was writing commercial quality "software," and that if it wasn't 100% intuitive, I would hand-hold each colleague, and make changes on demand, including converters to multiple file formats (often, so they could put the data back into a spreadsheet). And of course I also had to help each person install Python on their computer.
Of course I'm not a full fledged software developer, just a "scientific" programmer, and of course the lesson I learned is common knowledge: Writing and supporting real software is orders of magnitude more costly than just writing a one-off program to solve a problem, to the point where the conversion to "proper code" could be a net liability to the business. You have to assess whether it will actually add value. In one sibling comment, it sounds like the answer was yes, so I acknowledge that.
The difference was not so much the technology, but the cultural expectations associated with Excel versus "software."
Today, I do all of my work in Python, but when I share a simple computation with colleagues, I will often convert it back into Excel for them.
What that means to me is that I use excel for "toys" (small data set analysis, rough charts) and ephemeral-yet-shared lists where it is easier to say "evening batch tab, line 3" to communicate which job needs to be updated than try to communicate the same thing in a written request or pull a database table report.
I use R where I need more power: automated reports, automated statistics, and more complex analysis where the paradigm of textual code fits better than the paradigm of a 2D grid. I teach R (or python) when I want to give someone more reproduceable tools than a "magic" spreadsheet that, under the covers, is really a contraption held together with sticky tape and positive thinking.
We can, and should, teach both. Ideally side-by-side with a constant stream of "why are you doing task X this way?" that is largely missing from formal education.
AWS : https://aws.amazon.com/marketplace/pp/prodview-brc4ybuoee6he...
GCP : https://console.cloud.google.com/marketplace/product/techlat...
Azure : https://azuremarketplace.microsoft.com/en-us/marketplace/app...
Support & Documentation : http://www.techlatest.net/support/r-studio-support/
"Visibility: How do you see the code inside an Excel document? How do you tell exactly what is going on? You have to go clicking through cells, or reverse engineer what settings a graph has."
PowerQuery it's a functional way of transforming data step after step. You can see the code/function of each step and it's very easy to reason about those functions. You can transform data to the format you want, and do calculations on it before it enters the spreadsheet. One of the main advantages is that it's easy! I've taught non programmers to reliably use this tool.
"Repeatability: [...] With R, you just change read.csv("1.csv") to read.csv("2.csv") and the exact same calculations are run on two different data sets."
Again, with PowerQuery this is doable, and a normal procedure on my day to day. You change the file parameter PowerQuery will use on step 1, and the rest of steps will follow.
"Batch processing: Related to the above, you can read every CSV in a directory and produce a graph for each of them. You can read data from an API and run the same process on it that you did yesterday."
You can use PowerQuery on folders, it can take a set of files and transform or aggregate them all at once.
In my opinion Excel has gotten pretty powerful after data model and powerquery were added, I think around excel 2013. I barely use cell functions anymore; data model and pivot tables make for robust spreadsheets that are easy to reason about. I know a decent programmer can do most of it in many other ways, but the accessibility of Excel is amazing.
The biggest defect Excel has for me at the moment is control change tracking. Wish I could git Excel changes.
None of the article's reasons matter to non-IT people and no IT department has the juice to override the CFO and accountants. Unlike, every other interactive tool that displeases programmers, Excel survives.
If you want R to replace Excel you need to build an interactive front end that can do everything Excel can as easily as Excel. Sitting in a class is not and option.
This is one of many, many things that is terribly wrong with Excel. It is arguably well suited for neither of those applications. I will continue to do my statistics in R, and be very glad that I do not work somewhere with either CFOs or powerful accountants ;-).
And just like, in accounting, you're not going to get the CFO to choose R over Excel, in many circles involving data analysis and statistics you won't get to choose anything but R.
Also you don't need an interactive front end for R any more than you need an interactive front end for any other programming language. The scope of use is too large to allow for a single GUI. There are some packages that provide a GUI for specific purposes, like rattle, which provides an interface for common data mining tasks and models. I'd you want a pretty good spreadsheet GUI for viewing and modifying data, you can use rhandsontable. Just a few examples.
Replacing Excel with R isn't necessary and I think would miss the point & relative strengths of the different tools. Recognizing where each tool is better suited for your needs, and if R is worth the learning curve for your specific needs, is what is important.
Excel is good for accounting tasks because that's what it and other spreadsheet software were originally designed for. Data science tasks are tacked on.
To me, similar reasons surface to why it's a disaster waiting to happen.
Formulae hidden away in non document DAX columns. Its horrendous. Its the worst thing to happen to "BI", "Data analysis" that I've seen.
Given me a clearly defined single R markdown document that's easy to follow. If you can't follow the Markdown document, you shouldn't be running analysis in the first place.
In 2020, for a grassroots PPE-relief organization, however, I found that I had sometimes been mistaken. What our group managed to achieve by eschewing (eventually as a watchword) fancy tools and building our entire backend around Google Sheets was speed. Moreover, I learned along the way that simple database tools are sometimes more-efficient or faster than anything I'd have written myself.
I had been blinded by the GUIs -- the (frequently correct) notion that GUIs are generally inferior in the long run to scripting/programming had blinded me to the very idea that perhaps another tool could be superior.
As my career takes me in new directions, I'm presently reprising that experience, this time with SQL. Physicists rarely use it, so we have no idea what it can do. The syntax looks old/quirky/muddy, but the tools behind it are extremely powerful.
If you're great at R, consider sitting down with someone whom you know is just crushing problems with Excel. I'm pretty sure you'll both learn something useful.
We used RStudio and Shiny to build this: https://henvic.shinyapps.io/accidents https://github.com/henvic/accidents
Pivotcharts (and tables) help quite a bit for removing some of the tedium, but now suddenly it's interactive. Sometimes you want a format where BAM, everything is there laid out. There's nothing to misclick, all the tables and charts are there, you can just tell whoever, "look at the 3rd figure from the top on the 2nd tab".
The other things that people usually laugh at excel about (aside from silently changing values... that's just baaaaad) is the gong-show of naming files and versioning. R and friends + CSVs by themselves don't fix that problem. They just make it somewhat easier to solve (as in they play with git better).
It's the same reason I took the doors off my pantry and cabinets
For those who aren't as familiar with Excel, all the functionality the author is describing as missing in Excel is actually built into it out of the box - as a feature called Get & Transform (or 'PowerQuery'). You can load in a CSV, manipulate it, do batch processing, and all the steps are visible, editable, resequencable and deletable (showing you the M code behind it!).
You can even handle hundreds of millions of records this way.
For those who want to learn, I would wholeheartedly recommend this book: https://www.amazon.co.uk/Power-Pivot-Bi-Excel-2010-2016/dp/1...
Many people to this day aren't even aware cells can be named like proper variable names.
While I use wide range of data integration and visualization tools, Excel/Power Query with pivot tables & charts is often my go-to for quick data analysis or exploration.
Recently used it to retrieve Our World in Data Github hosted csv file data into an Excel file and then click refresh to get most recent data: https://009co.com/?p=1491
There's no good way to check if you've made a mistake in the logic of your excel spreadsheet. You can easily test your R code.
If you need to work with multiple people excel is a nightmare. It works fine when one person needs to build something for themselves or just to show to someone else. When you get two or more people working together it's like sharing a keyboard with someone else.
Excel can do a lot of things, but there is a limit to what it can do. R or Python is typically what you would reach for when you need to do something beyond what excel is capable of.
This is also how it works in Power BI, but I guess it's a bit of a different way of working than how most people are used to work.
Programming languages come into their own when the tasks stop being basic, but the learning process usually goes through "Hello, World" first.
I mean, if you're just going to print a line of text to the screen, why use Python? Just open an MS Word document. MS Word can even include variables and insert them dynamically!
My BiL is this breed. He's a financial analyst. He's got a hilarious mental block about using any kind of coding language in his work to the point that he actually developed a web-scraping app in excel. Don't ask me how. But jimmeny-christmas, use the right too for the damn job.
It's actually one of excel's great features - they so strongly constrained the way you represent data that it's easy to reason about.
Different levels of difficulty and customization for different applications.
period. full stop.
Overall, for serious data analysis work, I’d use R or Python, but Excel is popular enough to have its place, just need to know the risks.