[R] R vs Numpy
Avi Gross
@v|gro@@ @end|ng |rom ver|zon@net
Thu Oct 28 21:32:52 CEST 2021
I am not sure your overall question fits into this forum but a brief
internet search can find plenty of info.
But in brief, R is a language in which much of what numpy does was built in
from the start and many things are vectorized. Much of what the python
pandas language does is also part of native R. There are additional packages
(python called them modules) freely available that greatly extend those
capabilities and I doubt there is very much you can do in numpy that cannot
also often easily be done in R.
Realistically, there are several reasons the numpy module is so commonly
used in python. They left something like vectors out of the language. Yes,
they have dictionaries and lists and sets and all kinds of objects. So numpy
was made mostly in C to provide numeric processing of things that are more
like vectors efficiently. In R, everything is a vector as in a simple
variable is just a vector of length one!
I program in both and in other languages as many do. Reasons to choose one
or another vary. Python can do many things easily and with complexity and is
a rather full-blown and complex language with real object-oriented
capabilities and also functional programming. It is interpreted but also has
a way to save partially compiled code. R is pretty much all interpreted
albeit many things are written I C or C++ pr other compiled languages and
stuffed into libraries.
One main reason to choose is programming style but there are TONS of
differences that can bite you such as R sometimes deferring evaluation of
code which can be an advantage or the opposite. But a huge reason I think
that people choose one or the other is the availability of packages that do
much of what they want. Some, for example, love a set of packages they call
the tidyverse and do much of their work largely within it rather than base
R. Many love the graphics package called ggplot.
But over time, I see more and more functionality available within the Python
community that rivals or perhaps exceeds such as the machine learning tools.
I have an interesting solution I sometimes use as you can run programs in R
using a package that allows the same data to be accessed back and forth
between an attached R interpreter and a Python interpreter. So if you want
to use python features like dictionaries and list comprehensions to massage
the data then have R do additional things and perhaps make graphs, you can
get some of both worlds.
As noted, a detailed answer is way beyond here. R has packages that probably
let you add things and it has too many object-oriented subsystems, most of
them not complete.
Good Luck,
Avi
-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Catherine Walt
Sent: Thursday, October 28, 2021 2:57 AM
To: r-help using r-project.org
Subject: [R] R vs Numpy
Hello members,
I am familiar with python's Numpy.
Now I am looking into R language.
What is the main difference between these two languages? including
advantages or disadvantages.
Thanks.
______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list