Anything Py(thon) Can Do…

Indexing / Slicing Operations in R

Another quick post: In my previous post I demonstrated a technique in Python programming that I have been using as part of my assignments for the Cornell University Machine Learning Certificate program. This got me to thinking: Can you do the same thing in R — i.e. subset a matrix based on a separate list of labels, and then perform operations on the subsets to populate another array of outputs?

Yes, yes you can, as I demonstrate here. It looks and feels a little different, but you can functionally accomplish the same thing. I did this as a quick exercise, so opted for a simple R script instead of RMarkdown. I’ll post screenshots of the output below, or you’re welcome to download and run it locally to see for yourself.

The way the output looks and the nomenclature are a little different, but similar enough to make sense.

Credit to Dr. Timothy Wiemken for answering a couple of sticky questions I was struggling with when trying to put this together.

Cloud computing and data nerd who dreams of being a data scientist, probably because he's married to one and she's pretty cute.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store