News for hackers. Stuff that matters.
Re:Why do we use R rather than Excel? by corty on Sunday July 11, 2021 @09:12AM (#27800510)
Big big reason: R doesn't alter data without being asked to, Excel does so, silently, sneakily. Anything important should not be done in Excel.

https://www.theverge.com/2020/8/6/21355674/human-genes-renam... https://stackoverflow.com/questions/165042/stop-excel-from-a...

Re:Why do we use R rather than Excel? by roenxi on Sunday July 11, 2021 @09:53AM (#27800796)
While that is a very real problem, it isn't totally persuasive. It is just as easy to create traps in R (I lost days of my youth to R's challenging-to-defend jungle of an almost-type-system). It is even harder to debug than in Excel too - I would expect less bugs are found in R scripts because less people are up to the challenge of trying.

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.

Re:Why do we use R rather than Excel? by corty on Sunday July 11, 2021 @09:59AM (#27800848)
I agree that R isn't ideal, and a proper programming language is preferable to both. Which one of course will depend on the domain, but proper control over float precision, fixed-point arithmetics, bignum and debuggability isn't good in R either. It's just that R is still far above Excel.
Re:Why do we use R rather than Excel? by fighterpilot on Sunday July 11, 2021 @10:15AM (#27801007)
I mostly agree, but at least Excel is more easily inspectable by a human, which makes a certain class of errors (specifically, silly logic bugs) less likely to get through.
Re:Why do we use R rather than Excel? by corty on Sunday July 11, 2021 @10:25AM (#27801082)
Not really. Logic in Excel is based on stuff like SUMIF( ...) which is totally unreadable without lots of context about the cell or range it refers to. If someone fumbled the fill command and some cell is missing the formula? You'll never know and the result will be automatically and silently zero. References to that result will just use the zero as input. Mixed fixed/nonfixed references like A$3? Unreadable and hard to understand. References per se? Unreadable because undescriptive, maybe there will be a column or field label, maybe there won't. Also, formulas are always hidden by default, you'll just get a sea of numbers.

Calling Excel easily inspectable is laughably wrong imho. Just the opposite.

Re:Why do we use R rather than Excel? by andy81 on Sunday July 11, 2021 @12:55PM (#27802496)
Data tables and keeping one tab per table solves all of those.

Sounds more like an issue with the skill of average excel users than a feature gap.

Re:Why do we use R rather than Excel? by jrochkind1 on Sunday July 11, 2021 @10:20AM (#27801045)
It's not obvious to me that Excel is more easibly inspectable, can you say more?

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.

Re:Why do we use R rather than Excel? by fighterpilot on Sunday July 11, 2021 @10:52AM (#27801292)
It's the visualization of logic that I'm thinking of. You can press F2 on a cell and visually see what data is being pulled into the function, and you can easily manually check that that single calculation is accurate by re-creating that calculation by hand, and then infer that all the other stuff in the column is also accurate.

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.

Re:Why do we use R rather than Excel? by dm319 on Sunday July 11, 2021 @06:55PM (#27805154)
Why isn't R a proper programming language? What would you use over R for data analysis or statistical analysis?

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).

Re:Why do we use R rather than Excel? by ivirshup on Sunday July 11, 2021 @10:25PM (#27806283)
Can data.table play well with the tidyverse yet?

And as a side note, I believe it's moving down the rankings in the h2o benchmarks [1].

[1]: https://h2oai.github.io/db-benchmark/

Re:Why do we use R rather than Excel? by dm319 on Monday July 12, 2021 @04:43AM (#27808322)
Oh that's great. I'm really glad to see Julia getting faster there.
Re:Why do we use R rather than Excel? by bradleyjg on Sunday July 11, 2021 @11:15AM (#27801468)
> Anything important should not be done in Excel.

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.

Re:Why do we use R rather than Excel? by belter on Sunday July 11, 2021 @11:43AM (#27801716)
Do not shutdown the global economy. Just maybe move to tools with less issues around process governance:

"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...

Re:Why do we use R rather than Excel? by eyeball on Sunday July 11, 2021 @12:03PM (#27801932)
As though mistakes wouldn’t happen with non-programmers working in R.
Re:Why do we use R rather than Excel? by corty on Sunday July 11, 2021 @12:15PM (#27802063)
In R, you can use accepted methods of software development and engineering, such as version control, automated testing, CI/CD to catch mistakes and prevent them from causing harm. In Excel? Not really.
Re:Why do we use R rather than Excel? by eyeball on Sunday July 11, 2021 @12:33PM (#27802279)
Do you think the average finance department employee is going to do that?
Re:Why do we use R rather than Excel? by corty on Sunday July 11, 2021 @01:43PM (#27802948)
Especially those departments should do so and learn to do it. Financial departments are always the ones complaining about the cost of mistakes, compliance risks (of the monetary kind) and doing due diligence. Preventing the production of wrong figures in financial excel sheets ticks all those boxes. They should bloody well be doing it, but I'm also not holding my breath ;)
Re:Why do we use R rather than Excel? by kenjackson on Sunday July 11, 2021 @03:00PM (#27803663)
And there are massive bugs in programs that use these tools like the Linux kernel still.
Re:Why do we use R rather than Excel? by shakow on Sunday July 11, 2021 @11:28AM (#27801560)
Would not necessarily be a bad idea.

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.

Re:Why do we use R rather than Excel? by manishsharan on Sunday July 11, 2021 @11:32AM (#27801597)
This. Most finance people who live by Excel have ninja level skills with Excel. I have had to unpack logic from some excel sheets into webapps and they had so much sophisticated programming embedded into it. And it is so much easier intuitive to use Solver for linear equations in Excel than any web application.

Regarding the graphing ability , R may have more power but plotting the graphs in Excel is so much more WYSIWYG.

Re:Why do we use R rather than Excel? by tomlue on Sunday July 11, 2021 @11:58AM (#27801878)
finance people who learn to program will outperform those who don't.
Re:Why do we use R rather than Excel? by bradleyjg on Sunday July 11, 2021 @12:05PM (#27801958)
I believe that’s true. There still aren’t enough to go around and won’t be for a very long time.

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.

Re:Why do we use R rather than Excel? by Nicholas_C on Sunday July 11, 2021 @01:10PM (#27802659)
I’m a hobbyist programmer who has worked in various finance jobs and is now working in investment banking. I would love to use programming in finance but I have to say it’s come in handy very little.
Re:Why do we use R rather than Excel? by Jorge1o1 on Sunday July 11, 2021 @01:49PM (#27803014)
Well, prolly not in IBD. But in Sales and Trading or at a lot of quant funds it is very common.
Re:Why do we use R rather than Excel? by temp8964 on Sunday July 11, 2021 @09:57AM (#27800834)
Actually when you use R functions to import CSV files, they also guess data types and make some conversions by default. The difference is that in R you can turn them off if you want to. But in Excel there are automatic changes you can't turn off.
Re:Why do we use R rather than Excel? by HPsquared on Sunday July 11, 2021 @10:01AM (#27800867)
You can set the data type to "text" when importing CSVs, that turns most things off.
Re:Why do we use R rather than Excel? by croes on Sunday July 11, 2021 @10:32AM (#27801120)
If you try reading an Excel file via SSIS you are out of luck. You can't turn of the auto guessing feature.
Re:Why do we use R rather than Excel? by corty on Sunday July 11, 2021 @10:07AM (#27800917)
Most, but not all. That is the entire point: Excel is never safe in any configuration.
Re:Why do we use R rather than Excel? by FabHK on Sunday July 11, 2021 @10:12AM (#27800976)
Not sure about that. It is my understanding that Excel only tries to guess the type of an input if it has not been explicitly specified by the user.

The problem with "things that look like dates being interpreted as dates" comes from not specifying that a column has type "text".

Re:Why do we use R rather than Excel? by Xelbair on Sunday July 11, 2021 @12:11PM (#27802019)
Even if you do specify a column as a text excel WILL assume that it contains dates sometimes.

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.

Re:Why do we use R rather than Excel? by crazygringo on Sunday July 11, 2021 @10:23AM (#27801061)
If "not all", can you provide an example of what gets converted if you specify text?

Just want to know to avoid future gotchas.

Re:Why do we use R rather than Excel? by HPsquared on Sunday July 11, 2021 @02:03PM (#27803137)
I'm not sure, have to try it out but text fields can be delineated by starting with a single quote ('), that might be a special case. It might not be though, I don't have Excel open to check. Pretty much everything is left alone if you specify "text" at the import stage though. (This is using the text import wizard, or text-to-columns)
Re:Why do we use R rather than Excel? by capnahab on Sunday July 11, 2021 @11:52AM (#27801806)
As a total R beginner I was hugely put off by the complexities of data cleansing especially columns with ?different data types.
Re:Why do we use R rather than Excel? by belter on Sunday July 11, 2021 @09:44AM (#27800729)
"Floating-point arithmetic may give inaccurate results in Excel"

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...

Re:Why do we use R rather than Excel? by FabHK on Sunday July 11, 2021 @10:09AM (#27800937)
Almost all of these are issues with floating point in general, I'd say. Some are with naive implementations of Excel functions, fair enough (for example variance as (sum x_i^2/n - (sum x_i/n)^2) that are indeed better implemented in R or Julia.

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://people.eecs.berkeley.edu/~wkahan/ARITH_17.pdf

Re:Why do we use R rather than Excel? by belter on Sunday July 11, 2021 @10:46AM (#27801242)
But you also have issues like 'Catastrophic cancellation':

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."

Re:Why do we use R rather than Excel? by FabHK on Wednesday July 14, 2021 @09:55AM (#27833019)
That's an issue inherent in floating point computations with fixed precision (such as IEEE 754).

  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.0
Re:Why do we use R rather than Excel? by washadjeffmad on Sunday July 11, 2021 @12:14PM (#27802054)
We never got the results of our covid tests from early in the pandemic because someone imported the medical data into Excel, which predictably and destructively modified the patient IDs by stripping all leading zeroes.

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.

Re:Why do we use R rather than Excel? by gunshai on Sunday July 11, 2021 @02:13PM (#27803232)
> 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.

Please tell me you have said this to someone in a work meeting. This is hilarious.

Re:Why do we use R rather than Excel? by Akronymus on Monday July 12, 2021 @07:41AM (#27809266)
Even if it wasn't used, I may end up using it at work myself.
Re:Why do we use R rather than Excel? by WastingMyTime89 on Sunday July 11, 2021 @11:59AM (#27801897)
There is nothing sneaky about it. Excel imports things it thinks are dates as dates. It's not a silent modification. It's a loading issue. Properly loading data into R is not particularly easy either.
Re:Why do we use R rather than Excel? by user3939382 on Sunday July 11, 2021 @09:48AM (#27800756)
So if I have Zip codes with leading 0’s, use R?
Re:Why do we use R rather than Excel? by jasode on Sunday July 11, 2021 @09:55AM (#27800808)
>So if I have Zip codes with leading 0’s, use R?

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))

Re:Why do we use R rather than Excel? by user3939382 on Sunday July 11, 2021 @12:12PM (#27802034)
The problem that I've had with this issue and Excel is that Excel performs overly-clever-automagic type conversions in certain situations where you don't want them. And then especially when you're collaborating on files with non-technical normal office workers, they're not expecting this behavior. So the end result has been that this issue has bitten me many times, despite knowing how to ideally tell Excel to handle it.
Re:Why do we use R rather than Excel? by shawnz on Sunday July 11, 2021 @10:39AM (#27801171)
If you have zip codes, don't store those in a numeric type (doesn't matter if it's Excel, R, or any other system)

Zip codes aren't numbers, they are strings that happen to contain only numeric characters

Re:Why do we use R rather than Excel? by TeMPOraL on Sunday July 11, 2021 @10:40AM (#27801185)
WAIT. All these words on SO and here have been written because people don't know to change the column type from "General" to "Text"?
Re:Why do we use R rather than Excel? by Linosaurus on Sunday July 11, 2021 @10:46AM (#27801244)
They would like to be able to just open a csv file in excel without going through a file import wizard. Changing the column type after the fact is too late.
Re:Why do we use R rather than Excel? by intended on Sunday July 11, 2021 @10:57AM (#27801335)
If you get to the point that you are using r and python, it should be because you are doing working with larger data sets, or it’s specifically sophisticated.

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

Re:Why do we use R rather than Excel? by globular-toast on Sunday July 11, 2021 @12:58PM (#27802519)
I haven't used Excel since I was a child and learnt to program. I didn't realise just how bad it was. Someone asked for a list of ids for some inventory and they imported it into Excel. They were all 4 digit alphanumeric but the ones that looked like numbers, like "0001" it just treated it as a number, showed it as 1 no option to disable this ridiculous behaviour.
Re:Why do we use R rather than Excel? by tssva on Sunday July 11, 2021 @09:48AM (#27800755)
Excel doesn't alter data without being asked either. What it does do by default is try to change how the data is displayed. If the column is properly set to the correct data type the data will be shown correctly because Excel doesn't change the actual data. Column types can be set when csv files are imported.

The 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.

Re:Why do we use R rather than Excel? by tsbinz on Sunday July 11, 2021 @10:58AM (#27801342)
> Excel doesn't alter data without being asked either. What it does do by default is try to change how the data is displayed.

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.

Re:Why do we use R rather than Excel? by tssva on Sunday July 11, 2021 @01:18PM (#27802725)
If you enter it prior to specifying the formatting you are entering it as a date. The number you see when you change to text is the numeric value reflecting the date/data you entered.
Re:Why do we use R rather than Excel? by formercoder on Sunday July 11, 2021 @11:14AM (#27801455)
Just type ‘0002.
Re:Why do we use R rather than Excel? by dendriti on Sunday July 11, 2021 @10:11AM (#27800955)
the only way to prevent Excel from converting date-like number values into 'real dates' is to format the number values as text. or escape each and every number value so this doesn't occur.

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"?

Re:Why do we use R rather than Excel? by tssva on Sunday July 11, 2021 @01:50PM (#27803022)
That is how spreadsheets work. Try Libreoffice or Google Sheets. You will find they operate the same. Spreadsheets format all cells as a generic type where the value entered to it is gets assigned a more specific type by the spreadsheet application. If you want to insure that the value you entered is interpreted as a specific type you need to identify that to the spreadsheet application prior to entering the value.
Re:Why do we use R rather than Excel? by dendriti on Monday July 12, 2021 @03:49AM (#27808051)
I was responding to the claim that Excel "doesn't alter data without being asked either." I guess it does, and it should?
Re:Why do we use R rather than Excel? by undreren on Sunday July 11, 2021 @09:55AM (#27800812)
It also interprets and coerces values in formulas.

Empty cells are interpreted as zero, which can be downright catastrophic, if the data is just missing.