TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Quick Introduction to R

171 pointsby _fnhrover 3 years ago

18 comments

_Wintermuteover 3 years ago
My least favourite things about R is its desire to keep on running when it should have errored on something about 50 lines before and happily spitting out some nonsense result - maybe with a warning, often not.<p>One of my previous jobs basically turned into an in-house R consultant for a department in a pharmaceutical company, and I caught so many bugs when investigating some other issue which meant the results people were reporting were completely wrong. A really common one is multiplying 2 vectors of unequal length where broadcasting shouldn&#x27;t be possible and it just recycles the shorter vector - but hey, it ran without error and there&#x27;s an output so many researchers don&#x27;t notice.<p>Not to mention trying to handle errors is pretty miserable, if you want to catch a specific error you have to match the error string, unfortunately the error message changes depending on the locale the R session is running in.
评论 #30232300 未加载
评论 #30232356 未加载
评论 #30232046 未加载
评论 #30232060 未加载
评论 #30254520 未加载
评论 #30232956 未加载
streamofdigitsover 3 years ago
R is frequently compared with python and julia which are general purpose programming languages but it is not really a proper comparison. Once you approach R as a domain specific language &#x2F; system then its various quirks and pecularities are more palatable and explainable: they are in a sense the price to pay for tapping a large domain of statistical analysis expertise that is not available elsewhere.
评论 #30232718 未加载
legerdemainover 3 years ago
Saying that R is a domain-specific language for statisticians, and thus its quirks are ignorable, is an incomplete answer. An R program is never just a series of calls to specialized library functions. Programs still need to ingest and emit data, manipulate data ad hoc, take conditional branches based on some runtime condition, and so on. And that glue code must still be written in R. <i>I&#x27;ve had to write a lot of that glue code in R.</i><p>As someone who mostly writes not-R, my own R irritation comes from a handful of things:<p>- The dot character &quot;.&quot; has no semantic meaning in identifiers. It&#x27;s just a valid character for names. Looking at function names like &quot;is.numeric&quot; really messes with my reading comprehension.<p>- Ambiguously, &quot;.&quot; also separates identifiers of objects in one of R&#x27;s type systems from method calls. In some cases, `foo(bar)` and `bar.foo()` are equivalent. But only in some cases.<p>- Even better, a popular R library defines a function `.()` (i.e., its name is just a single period character), whose job is to expose a surprising quote&#x2F;unquote expression evaluation semantics.<p>- This is not to mention the special meaning of &quot;.&quot; in formula literals, which are fairly ubiquitous in R.<p>- Different authors use different naming conventions. Base prefers &quot;as.numeric,&quot; Tidyverse might have &quot;to_factor,&quot; another library might prefer camel case.<p>- Finally, R has a surprisingly extensive syntax, exercised by different libraries to different extents, and a correspondingly rich semantics, with &quot;types,&quot; &quot;modes,&quot; multiple class systems, &quot;expression&quot; objects, immediate and lazy evaluation, expression quoting and unquoting, metaprogramming, and homoiconicity. It is a zoo of a language.
j7akeover 3 years ago
Once you include the statistical packages, ggplot2, and dplyr, there is nothing that beats R in ease of prototyping for data exploration, model fits and sanity checks, and data visualisation of high dimensional data.
评论 #30231952 未加载
评论 #30232005 未加载
评论 #30232049 未加载
评论 #30232014 未加载
评论 #30232012 未加载
dm319over 3 years ago
I love R. Once you get it, there is something beautiful about its functional approach. I like using either tidyverse or data.table with pipes, split, map, reduce. The code looks like layers of a filter that data flows through.
评论 #30234161 未加载
zenlfover 3 years ago
On the contrary, I&#x27;m not a fan of R, I&#x27;m only a fan of Hadley Wickham and how the Tidyverse and ggplot2&#x27;s API are designed.<p>They are just incredibly intuitive and easy to use. ggplot2 has fundamentally influenced how I think about plotting.<p>With my limited experience, I have never seen anything like it.
评论 #30235615 未加载
评论 #30234052 未加载
folliover 3 years ago
If you get started with R, I heavily suggest to use some kind of IDE such as RStudio or Jupyter Notebook. It makes your life so much easier.
评论 #30232076 未加载
评论 #30232063 未加载
评论 #30233706 未加载
bitcharmerover 3 years ago
In my domain q&#x2F;kdb is used extensively. I don&#x27;t have a decade to master obscure syntax&#x2F;grammar just for one simple purpose of extracting some data set from a larger population and maybe do some basic statistics on it.<p>If you&#x27;re like me R is a godsend. You&#x27;ll also love the tonnes of free packages. You can&#x27;t get wrong with R if you appreciate simplicity and intuitiveness.
scottmcdotover 3 years ago
The difference between assigning variables via &quot;=&quot; versus &quot;&lt;-&quot; is not mentioned. That would be confusing to someone learning R.
评论 #30232880 未加载
评论 #30232782 未加载
评论 #30232824 未加载
huhtenbergover 3 years ago
&gt; Recycling<p><a href="https:&#x2F;&#x2F;github.com&#x2F;karoliskoncevicius&#x2F;tutorial_r_introduction&#x2F;blob&#x2F;main&#x2F;README.md#recycling" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;karoliskoncevicius&#x2F;tutorial_r_introductio...</a><p>Gotta say this is very elegant.
awildover 3 years ago
Maybe someone can help me with this, how do you integrate r as a cli tool? I&#x27;m in a mostly R shop but its integration is so confusing and&#x2F;or bad with other tools that we usually just rewrite everything in python for integration (which obviously is a huge waste of time). R packages etc have me as an outsider confused,though seem like the obvious choice?
评论 #30236711 未加载
评论 #30236632 未加载
评论 #30236167 未加载
jack_squatover 3 years ago
This is the R resource I recommend: <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Using-Introductory-Statistics-Chapman-Hall-dp-1466590734&#x2F;dp&#x2F;1466590734&#x2F;ref=dp_ob_title_bk" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Using-Introductory-Statistics-Chapman...</a><p>Takes a weekend to work through the book and you get a statistics refresher as a bonus.
Gatskyover 3 years ago
Great overview. Slight shame it leaves out &#x27;lapply&#x27; etc though (and says as much at the top). I just remember realising that you can have lists and run functions on them when I was learning R, and it seemed like a superpower.
upbeat_generalover 3 years ago
R reminds me a lot of matlab. Used mainly for compatibility&#x2F;libraries&#x2F;ecosystem but still a frustrating interpreted language at its core.
aseerdbnarngover 3 years ago
This is probably written by a programmer for that reason (and reading the ‘why R is bad’ comments) shows how misunderstood R is by most programmers. Its like giving someone an introduction to the english language by showing them the alphabet and listing punctuation. Yes technically all true, but none of it will stick
评论 #30236453 未加载
curiousgalover 3 years ago
Best thing about R is Shiny
fithisuxover 3 years ago
bookdown has a wealth of online books for R.
nomilkover 3 years ago
1^NA is 1, and 2^NA is NA. Bizarre!
评论 #30232681 未加载
评论 #30232035 未加载
评论 #30232094 未加载