Skip to content

Commit b04edff

Browse files
committed
git rid of sf library
1 parent 1271fac commit b04edff

File tree

1 file changed

+13
-67
lines changed

1 file changed

+13
-67
lines changed

content/02-rstudio.qmd

Lines changed: 13 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ In this tutorial, we will provide a brief introduction to RStudio using the Jupy
1717

1818
:::
1919

20-
## Open RStudio in the JupyterHub
20+
## Open RStudio
2121

22-
1. Login the JupyterHub
22+
You can open RStudio from your computer or in the JupyterHub. We are using RStudio version 2024.04.2 Build 764 on the JupyterHub. Go to Help > About RStudio to check your version. You need to have a relatively updated version (late 2023 at least).
23+
24+
### If using the JupyterHub
25+
26+
1. Login the [NMFS Openscapes JupyterHub](https://nmfs-openscapes.2i2c.cloud)
2327
2. Click on the RStudio button when the Launcher appears
2428
![Jupyterhub Launcher](./img/jhub-launcher.png)
25-
3. Look for the browser tab with the RStudio icon
29+
30+
3. Look for the browser tab with the RStudio icon.
2631

2732
## Basic Navigation
2833

@@ -77,9 +82,7 @@ Look for the Upload button in the Files tab of the bottom right panel.
7782

7883
## Creating files
7984

80-
When you start your server, you will have access to your own virtual drive space. No other users will be able to see or access your files. You can upload files to your virtual drive space and save files here. You can create folders to organize your files. You personal directory is `home/rstudio`. Everyone has the same home directory but your files are separate and cannot be seen by others.
81-
82-
*Python users: If you open a Python image instead of the R image, your home is `home/jovyan`.*
85+
When you start your server, you will have access to your own virtual drive space. No other users will be able to see or access your files. You can upload files to your virtual drive space and save files here. You can create folders to organize your files. Your personal directory is `home/rstudio` or `home/jovyan`. Everyone has the same home directory but your files are separate and cannot be seen by others.
8386

8487
There are a number of different ways to create new files. Let's practice making new files in RStudio.
8588

@@ -111,77 +114,20 @@ C, 100, 200
111114

112115
3. Click the save icon (above your new file) to save your csv file
113116

114-
### A Rmarkdown document
117+
### A Quarto document
115118

116119
Now let's create some more complicated files using the RStudio template feature.
117120

118-
1. From the upper left, click File -> New File -> RMarkdown
121+
1. From the upper left, click File -> New File -> Quarto
119122
2. Click "Ok" at the bottom.
120-
3. When the file opens, click Knit (icon at top of file).
121-
4. It will ask for a name. Give it one and save.
122-
5. You file will render into html.
123-
124-
[Reference sheet for writing in RMarkdown](https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf) or go to Help > Markdown Quick Reference
125-
126-
### A Rmarkdown presentation
127-
128-
1. From the upper left, click File -> New File -> RMarkdown
129-
2. Click "Presentation" on left of the popup and click "Ok" at the bottom.
130-
3. When the file opens, click Knit (icon at top of file).
123+
3. When the file opens, click Render (icon at top of file).
131124
4. It will ask for a name. Give it one and save.
132125
5. You file will render into html.
133126

134-
### (advanced) An interactive application
127+
[Quarto Cheatsheet](https://rstudio.github.io/cheatsheets/html/quarto.html)
135128

136-
1. From the upper left, click File -> New File -> Shiny Web App
137-
2. In the popup, give the app a name and make sure the app is saved to `my-files`
138-
3. When the file opens, Run App (icon at top of file).
139129

140130
### And many more
141131

142132
Play around with creating other types of documents using templates. Especially if you already use RStudio.
143133

144-
## More tips
145-
146-
Learn some tips and tricks from these
147-
148-
* https://colorado.posit.co/rsc/the-unknown/into-the-unknown.html
149-
* https://www.dataquest.io/blog/rstudio-tips-tricks-shortcuts/
150-
151-
## Plotting a netCDF file
152-
153-
* https://pjbartlein.github.io/REarthSysSci/netCDF.html
154-
* https://r-spatial.github.io/sf/articles/sf1.html
155-
156-
webpage:
157-
```
158-
https://coastwatch.pfeg.noaa.gov/erddap/griddap/ncdcOisst21Agg.graph?sst%5B(2023-08-27T12:00:00Z)%5D%5B(0.0)%5D%5B(-7.8):(44.8)%5D%5B(39.7):(92.3)%5D&.draw=surface&.vars=longitude%7Clatitude%7Csst&.colorBar=%7C%7C%7C%7C%7C&.bgColor=0xffccccff
159-
```
160-
161-
url from the dropdown on that page
162-
```
163-
url <- https://coastwatch.pfeg.noaa.gov/erddap/griddap/ncdcOisst21Agg.nc?sst%5B(2023-08-27T12:00:00Z)%5D%5B(0.0)%5D%5B(-7.875):(44.875)%5D%5B(39.625):(92.375)%5D&.draw=surface&.vars=longitude%7Clatitude%7Csst&.colorBar=%7C%7C%7C%7C%7C&.bgColor=0xffccccff
164-
```
165-
166-
1. Open an R script
167-
168-
Add this code.
169-
170-
```{r message=FALSE, warning=FALSE}
171-
library(ggplot2) # package for plotting
172-
library(sf)
173-
library(stars)
174-
library(dplyr)
175-
176-
url <- "https://coastwatch.pfeg.noaa.gov/erddap/griddap/ncdcOisst21Agg.nc?sst%5B(2023-08-27T12:00:00Z)%5D%5B(0.0)%5D%5B(-7.875):(44.875)%5D%5B(39.625):(92.375)%5D&.draw=surface&.vars=longitude%7Clatitude%7Csst&.colorBar=%7C%7C%7C%7C%7C&.bgColor=0xffccccff"
177-
178-
fil <- "sst.nc"
179-
if(!exists(fil)){
180-
download.file(url=url, destfile=fil)
181-
}
182-
183-
stars_object <- raster::raster(fil) %>% st_as_stars()
184-
ggplot() + geom_stars(data = stars_object)
185-
```
186-
187-

0 commit comments

Comments
 (0)