Lab 0: Getting Started and Intro to R, RStudio, and Quarto

Author

Heidi Nydam

Lab 0: Getting Started

Heidi Nydam
Question 1 I reopened R, closed my previous projects from the summer, and began working on this project. I followed this tutorial from Professor Baumann.
Question 2
I set up my working directory, titled “282 R Data Practice”
Question 3
This question is all about creating this doc and the specifications.
Question 4

# install.packages("tidyverse")
# install.packages("lubridate")
# install.packages("performance")
# install.packages("palmerpenguins")
# install.packages("patchwork")
# install.packages("ggsci")
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lubridate)
library(performance)
library(palmerpenguins)
library(patchwork)
library(ggsci)

Question 5

labzero<- read.csv('https://raw.githubusercontent.com/jbaumann3/BIOL234_Biostats_MHC/main/belize_coral_survey_data_2016.csv')
head(labzero)
  method site      type lat transect diver    life.history species
1  Video    1 Back Reef   3        1     4 Stress Tolerant    SSID
2  Video    1 Back Reef   3        1     4            <NA>    MCOM
3  Video    1 Back Reef   3        1     4 Stress Tolerant    SSID
4  Video    1 Back Reef   3        1     4      Generalist    OFAV
5  Video    1 Back Reef   3        1     4           Weedy    UTEN
6  Video    1 Back Reef   3        1     4 Stress Tolerant    SSID
  percent.of.cover        l           w        area pale bleached total.pb
1             0.30  5.62500       5.625   31.640625    0        0        0
2             0.90 10.80000         5.4       58.32    0        0        0
3             0.80 29.41176 12.94117647 380.6228374    0        0        0
4             0.90 26.71875    18.28125 488.4521484    0        0        0
5             0.30 11.78571 16.07142857 189.4132654    0        0        0
6             0.85 21.25000 13.66071429 290.2901787    0        0        0
  percent.pb new trans old total.mort percent.mort disease percentdisease
1          0 0.7     0   0         16           70       0              0
2          0 0.0     0   0          2            0       0              0
3          0 0.0     0 0.4         10           40       0              0
4          0 0.0     0   0          2            0       0              0
5          0 0.0     0   0          2            0       0              0
6          0 0.1     0   0          4           10       0              0
tail(labzero)
     method site       type lat transect diver    life.history species
5218  AGRRA   14 Patch Reef   1        6     3           Weedy    PAST
5219  AGRRA   14 Patch Reef   1        6     3            <NA>    PDIV
5220  AGRRA   14 Patch Reef   1        6     3 Stress Tolerant    SSID
5221  AGRRA   14 Patch Reef   1        6     3            <NA>    MCOM
5222  AGRRA   14 Patch Reef   1        6     3           Weedy    PAST
5223  AGRRA   14 Patch Reef   1        6     3           Weedy    PAST
     percent.of.cover  l  w area pale bleached total.pb percent.pb new trans
5218               NA 20 10  200    0        0        0          0   0     0
5219               NA 25 15  375    0        0        0          0   0     0
5220               NA 40 30 1200    0        0        0          0   0     0
5221               NA 35 25  875    0        0        0          0   0     0
5222               NA  5  5   25    0        0        0          0   0     0
5223               NA 10 10  100    0        0        0          0   0     0
     old total.mort percent.mort disease percentdisease
5218   0          2            0       0              0
5219   0          2            0       0              0
5220   0          2            0       0              0
5221   0          2            0       0              0
5222   0          2            0       0              0
5223   0          2            0       0              0
str(labzero)
'data.frame':   5223 obs. of  23 variables:
 $ method          : chr  "Video" "Video" "Video" "Video" ...
 $ site            : int  1 1 1 1 1 1 1 1 1 1 ...
 $ type            : chr  "Back Reef" "Back Reef" "Back Reef" "Back Reef" ...
 $ lat             : int  3 3 3 3 3 3 3 3 3 3 ...
 $ transect        : int  1 1 1 1 1 1 1 1 1 1 ...
 $ diver           : int  4 4 4 4 4 4 4 4 4 4 ...
 $ life.history    : chr  "Stress Tolerant" NA "Stress Tolerant" "Generalist" ...
 $ species         : chr  "SSID" "MCOM" "SSID" "OFAV" ...
 $ percent.of.cover: num  0.3 0.9 0.8 0.9 0.3 0.85 0.8 0.4 0.9 0.85 ...
 $ l               : num  5.62 10.8 29.41 26.72 11.79 ...
 $ w               : chr  "5.625" "5.4" "12.94117647" "18.28125" ...
 $ area            : chr  "31.640625" "58.32" "380.6228374" "488.4521484" ...
 $ pale            : num  0 0 0 0 0 0 0 0 0 0 ...
 $ bleached        : num  0 0 0 0 0 0 0 0 0 0 ...
 $ total.pb        : num  0 0 0 0 0 0 0 0 0 0 ...
 $ percent.pb      : num  0 0 0 0 0 0 0 0 0 0 ...
 $ new             : num  0.7 0 0 0 0 0.1 0 0 0 0 ...
 $ trans           : chr  "0" "0" "0" "0" ...
 $ old             : chr  "0" "0" "0.4" "0" ...
 $ total.mort      : int  16 2 10 2 2 4 2 2 2 2 ...
 $ percent.mort    : chr  "70" "0" "40" "0" ...
 $ disease         : int  0 0 0 0 0 0 0 0 0 0 ...
 $ percentdisease  : int  0 0 0 0 0 0 0 0 0 0 ...
summary(labzero$l)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   2.57    8.75   14.22   22.19   26.92  600.00 

In this section, I looked at both the first 6 rows with (head), the last 6 with (tail) and then creating some summary statistics using (summary). This allows for easy data visualization. Question 6

labzero$l=as.factor(labzero$l)

This changes all of the data in the selected column (which is chosen by $), from numerical continuous value and then changes it to a new column where it is a factor. This is a different type of data and is non continuous and easier to graph.
Question 7

write.csv(labzero,file='labzero.csv')
labzero<-read.csv('labzero.csv')