Football is full of numbers, names, lists, teams and a million other 'things' that make up our understanding of what is happening.
In the same way, R has lots of different ways of classifying things that it can understand. For example, it uses numbers to count, 'strings' for names and even has ways to group these things – like we would need for a league. This introductory post takes a look at a couple of these data types.
As its simplest, R is a calculator:
1+1 ##  2
10*2 ##  20
20/2 ##  10
# ** = to the power of 2**3 ##  8
While a calculator is incredibly useful, we can give these numbers a name and a placeholder so that they are a bit more tangible and applicable to a problem. For example, if I want to keep track of our top scorer's shots and goals:
Ronney_Goals <- 15 Ronney_Shots <- 63
I could now calculate Ronney's conversion rate! Dividing goals by shots, I can see how many shots it takes him to score.
Ronney_Conversion = Ronney_Goals/Ronney_Shots Ronney_Conversion ##  0.2380952
Now that R has some interesting information on Ronney, it wants to share it with the world. As we can see above, sharing a number by itself doesn't tell us a great deal. However, a string of text can give us a bit of context.
Surround a piece of text in quotation marks (be consistent with single or double quotes) to create a string:
"Ronney is truly a great player, his conversion rate speaks for itself." ##  "Ronney is truly a great player, his conversion rate speaks for itself."
...and let's use the print() and paste0() commands to add the evidence to our commentator's opinion.
print(paste0("His conversion rate of ", Ronney_Conversion, " is sublime")) ##  "His conversion rate of 0.238095238095238 is sublime"
That is a bit specific, Merse, but I appreciate the information! Let's take a look at those two commands:
print() - R, please print everything that I put into the brackets.
paste0() - R, combine this segments of text and numbers
Once you have a grasp of the concepts above, you should aim to move on to our other tutorials for R. Here, you'll learn about cleaning and analysing data in R, as well as visualisation of your insights.
If you have any questions, recommendations or requests, please get in touch!
This is a R conversion of a tutorial series by FC Python. I take no credit for the idea and have their blessing to make this conversion. All text is a direct copy unless changes were relevant. Please follow them on twitter and if you have a desire to learn Python then they are a fantastic resource!
This is a R conversion of a tutorial by FC Python. I take no credit for the idea and have their blessing to make this conversion. All text is a direct copy unless changes were relevant. Please follow them on twitter and if you have a desire to learn Python then they are a fantastic resource!