[R] R vs Numpy
Richard O'Keefe
r@oknz @end|ng |rom gm@||@com
Mon Nov 1 03:35:56 CET 2021
Reasons for preferring one to another:
- taste.
If you like curly braces, you'll prefer R.
If you like indentation forced by syntax, you'll prefer Python.
- compatibility.
This morning I was trying to use a web site where all the Python
examples were non-functional due to either of both of two changes
to Python syntax.
- tooling
Both have pretty good tools. For some things, R has the edge.
For some, Python. (There is no R analogue of PyPy.)
- packages
Both R and Python have vast libraries of contributed packages.
Quite often you are more interested in a package than the language
it runs in. You might be surprised at what is available for R.
Tensorflow: https://tensorflow.rstudio.com/
Keras: https://keras.rstudio.com/
And of course, some people use both in the same project,
https://www.rstudio.com/solutions/r-and-python/
By the way, someone said that R is purely interpreted.
That's not completely true. In R, type
?compile
>From .py files you get .pyc, from .R files you get .Rc
On Fri, 29 Oct 2021 at 20:21, Catherine Walt <walt using purpleemail.com> wrote:
> Thanks for Avi. and all other people's helps.
>
> I am using Numpy primarily for machine learning, for example, Keras tasks
> can use Numpy heavily.
>
> Now I got a task to analyze the BIO data, for which the Prof tell me R is
> better.
> So I am looking into R. and I was just serious if Numpy can handle the BIO
> data well?
>
> Regards
> Cathy
>
>
>
> October 29, 2021 3:32 AM, "Avi Gross via R-help" <r-help using r-project.org>
> wrote:
>
> > 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.
> >
> > ______________________________________________
> > 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.
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list