Concept question 1

A list is a heterogenous data structure that can hold elements of different data types.

Concept question 2

a character or marker that seperates individual pieces of data.

Problem 1

telling r we are using the readr functions, uploading zoo data to dataset called Zoo, returning the milk column, taking mean from milk column without empty slots. library(readr)

library(readr)
Zoo <- read_csv("https://www4.stat.ncsu.edu/~online/ST308/Data/agschwa2_zoo.csv")
## Rows: 50 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (5): legs, predator, milk, aquatic, eggs
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Zoo$milk
##  [1] 1 1 1 0 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1
## [39] 1 0 0 0 0 1 0 0 1 0 0 0
mean(Zoo$milk, na.rm = TRUE)
## [1] 0.44

Problem 2

reading in yeast data set to dataset call yeast, specifying that there is no column names, naming the columns, printing first 5 observations of yeast dataset with the columns named.

Yeast=read_tsv("https://www4.stat.ncsu.edu/~online/ST308/Data/agschwa2_yeast.tsv",
  col_names= FALSE,
  na=c("","NA"),
  skip=0,
  col_types=NULL,
)
## Rows: 742 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (1): X3
## dbl (2): X1, X2
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
new_col_names <- c("mcg", "vac", "seq_name")
colnames(Yeast) <- new_col_names
print(Yeast, n = 5)
## # A tibble: 742 × 3
##     mcg   vac seq_name  
##   <dbl> <dbl> <chr>     
## 1  0.53  0.45 CCR4_YEAST
## 2  0.59  0.51 SC72_YEAST
## 3  0.54  0.3  RSU2_YEAST
## 4  0.63  0.51 EF1A_YEAST
## 5  0.46  0.58 ADH2_YEAST
## # ℹ 737 more rows

Problem 3

installing readxl package and saying that we are using it downloading the file then reading it in, then returning 2nd column and first 5 rows of the tibble

library(readxl)
download.file("https://www4.stat.ncsu.edu/~online/ST308/Data/agschwa2_balance-scale.xlsx", "agschwa2_balance-scale.xlsx")
BalanceScale= read_excel("agschwa2_balance-scale.xlsx")
Tib= BalanceScale[1:5, 2]
Tib
## # A tibble: 5 × 1
##   Right_Distance
##            <dbl>
## 1              5
## 2              2
## 3              5
## 4              4
## 5              1