PNNL-PREMIS / SULI2019

Repository for summer 2019 SULI interns
0 stars 0 forks source link

R Workshop: Part 1 2019-06-04 #1

Open bpbond opened 5 years ago

bpbond commented 5 years ago

Goal:

to use CO2 flux data to open a dataset in RStudio and create a basic plot

Data used: https://github.com/PNNL-PREMIS/SULI/blob/master/Rworkshop1_20190604_CO2.csv https://github.com/PNNL-PREMIS/SULI/blob/master/Rworkshop1_timeseries_HSLEcontrols.csv

RStudio

Handling data: using tidyverse functions

Visualizing with ggplot

Handouts used: https://www.rstudio.com/resources/cheatsheets/

stephpenn1 commented 5 years ago

Functions complete a task, here's how they are structured:

function_name (argument1, argument 2, ...)

Example: If you want to take the sum of 160, 47, and 10, you can use the sum() function in R

> sum(160, 47, 10) [1] 217

bpbond commented 5 years ago

Good meeting. We covered:

Here's the program we wrote:


# Script to find the distance traveled by the fastest car
# B,H,L,M 2019-06-04

car_speeds <- cars$speed

print("The length of the speed vector is:")
print(length(car_speeds))
print(summary(car_speeds))

# Compute position of max speed
max_speed_pos <- which.max(car_speeds)
print("The index of the maximum speed value is:")
print(max_speed_pos)

print("The corresponding distance is:")
print(cars$dist[max_speed_pos])