Introduction

Author

Jeffrey R. Stevens

Published

January 23, 2023

Let’s go to R’s console, which is the direct connection to the R engine. In the console, you give R a command, and it returns the output.

Numerical operations

R can be a very fancy calculator. Let’s do some calculations by entering numerical operations into the console. How many seconds are there in a year?

# >

On average, how many days are in each month of a leap year?

# >

Text

R also can store, manipulate, and return text. But working with text requires wrapping the characters in quotation marks (either " or '). Type this out and replace <name> with your name: "My name is <name>!".

# >

You can also apply functions to text. If we want to yell our names, let’s convert the string of characters to upper case with the toupper() function. Put the previous text inside the parentheses of toupper().

# >

Press the up arrow ⬆️ to place previous commands in the console. Navigate to the previous command and change the text a bit.

Packages

If you haven’t already, install the {palmerpenguins} and {tidyverse} packages. Remember how to do that?

# >

Let’s look at the penguins data set. What do we need to do first?

# >

View the data set by typing penguins into the console.

# >

Plot data

Excellent! We now have wrangled the data to where we want it. Let’s say we want to make a scatterplot of the bill length vs. the bill depth for all birds. We need to use the plot() function for this.

# >

Hey, hey! We have a plot! 📊 Sweet! We’ve input data, wrangled it, and plotted it. Well done! 🎉 💪