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.
Credit to Dr. Timothy Wiemken for answering a couple of sticky questions I was struggling with when trying to put this together.