Data import

1 Import data from r-intro-docs.

In the files section of your RStudio, click on the r-intro-docs directory. You should see a list of files.

Lets save the greetings R object as a csv file in the r-intro-docs directory.

# First re-create if needed
greetings <- c("Hey", "Hi", "Howdy", "Hello", "Morning")
n <- c(99, 15, 324, 54, 23)
df <- data.frame(greetings, n)
addition <- c("Afternoon", 18)

greetings <- rbind(df, addition)

Discuss tab completion!

write.csv(greetings, "r-intro-docs/greetings.csv")

Open up greetings.csv locally. What does it look like in Excel?

?write.csv()
?write.table()

1.1 Provided datasets

Import pizza using read.csv().

pizza <- read.csv("r-intro-docs/pizza.csv") 

1.2 Star Wars data

Within the Tidyverse there is a Star Wars dataset we will use to explore data manipulation and wrangling in R.

Ensure Tidyverse is installed.

library(tidyverse)

data("starwars")

View(starwars)

1.3 Activity

Choose Star Wars or Pizza and describe the data types.

1.4 Import larger data frames

Data is from an ASV table from Hu et al. 2022.

Import the ASV table and associated metadata table that are in the r-intro-docs directory. Set them equal to asv_table and metadata, respectively.

asv_table <- 

metadata <-

Use the command summary() to learn more about the data frames we’ve imported above.

summary(asv_table)
head(asv_table)
head(metadata)

We will come back to this larger dataset after we explore some tidyverse functions.