#rstudio

LIVE

Whenever people need to do something that involves a big bunch of data and making graphs/statistics/etc they think of excel. While excel is great if you actually have to analyse the data yourself qualitatively, R is a way better option for everything else. (It’s also possible to write down the data in excel, and then read that data into R where you can do all kinds of weird shit with it, and if necessary, write an output that can be opened in excel).

SO WHAT EVEN IS IT? 

R is a programming language, very similar to python, that is meant for statistics and data analysis: the making of graphs and the manipulation of data is made as easy as possible while still retaining normal programming functionality (whatever the fuck I mean by that).

WHAT R IS NOT GOOD FOR: R is made for statistics, not symbolic math, which should be left to Python (SymPy, NumPy).

WHAT YOU CAN DO WITH R: make animated graphs, filter and manipulate data, write a program that opens a file, does things, and then writes a new file based on those things, use on your CV.

HOW DO I GET THIS “R”?InstallRstudioandR.

OK I’VE OPENED UP RSTUDIO BUT NOW WHAT? There are a lot of good guidesandresourcesfor R, even the official pdf, but here’s some basic stuff for an intro cause I know we don’t always wanna immediately get into a tutorial.

 Defining a variable is done using < - (no space, tumblr makes it into an actual arrow for some reason).

A list (not a programming list, a normal list) is called a vector in R. A vector of the colours red, black, and white is defined:

The data type that is most useful is a data frame. A data frame with columns a: 1,2,3,4 (can be shortened to 1:4, where : represent the word ‘to’) and b: 0,1,1,1 would be defined like this:

Loops work the same as usual, but the most useful loop in R (at least in my experience) is the for loop, since you can go through each iteration in a vector (the column of a data frame or the row of a data frame can be treated as a vector). Here’s an example in which i make it print each value for the a column from the previous data frame because i cant think of anything cooler:

Hopefully this makes sense to people who ain’t me. In part 2 I describe how to make plots and what filters are.

loading