Getting started with R and Rstudio

Built in functions

Next let’s explore some more built in functions, type the following into your script:

sum(b)
mean(b)
median(b)
quantile(b)
min(b)
max(b)
var(b)
sd(b)
summary(b)

This will calculate the sum, mean, median, quantiles, minimum value, maximum value, variance and standard deviation of the numbers stored in your variable b. There is also the summary() function which will output a combination of some of these values in one go. Highlight the lines and click Run again to see the output in the console.It should look like this:

Finally to get a visual summary of our data we can use the in built hist() plotting function.Type the hist command as shown below into your script.

hist(b)

Highlight the command and Run, the plot will be displayed in the viewer panel, your window should look like this:

That’s it for now, there is a lot more to go over but I hope this helps getting started with the fundamentals!