Introduction to R and RStudio

-

Last updated on 2024-02-27 | +

Last updated on 2024-03-05 | Edit this page

@@ -440,7 +440,8 @@

Organising working directory
R project organization

You can create these folders as you would any other folders on your +

RStudio project logo with five lines, each leading from the logo towards one of the five boxes with texts: 'data/', 'data_output/', 'documents/', 'fig_output/', 'scripts/'
R project organization
+

You can create these folders as you would any other folders on your laptop, but R and RStudio offer handy ways to do it directly in your RStudio session.

You can use RStudio interface to create a folder in your project by @@ -470,13 +471,12 @@

Two main ways to interact with Rwrite and save an R script (.R file) -
+
-
-

Callout -

+
+

Callout

When you open the RStudio or create the Rstudio project, you will see Console window on the left by default. Once you create an R script, it @@ -536,13 +536,12 @@

Running the codeCtrl + Alt + B on Windows/Linux or Command + option + B on Mac.

-
+
-
-

Escaping -

+
+

Escaping

The console shows it’s ready to get new commands with > sign. It will show + sign if it still @@ -575,13 +574,12 @@

R install.packages('here')

-
+
-
-

Callout -

+
+

Callout

If you are not sure if you have tidyverse packaged installed, you can check it in the Packages tab in the @@ -598,13 +596,12 @@

R

-
+
-
-

Commenting your code -

+
+

Commenting your code

Now we have a bit of an issue with our script. As mentioned, the packages need to be installed only once, but now, they will be installed @@ -685,13 +682,12 @@

Rdownload.file('https://bit.ly/geospatial_data', here('data','gapminder_data.csv'))

-
+
-
-

Importing data into R -

+
+

Importing data into R

Three of the most common ways of importing data in R are:

+
@@ -823,8 +826,8 @@

Key Points +

@@ -7335,7 +7339,7 @@

Key Points

Content from Basic GIS operations with R and sf


-

Last updated on 2024-02-27 | +

Last updated on 2024-03-05 | Edit this page

@@ -7436,13 +7440,12 @@

R ggplot(data = old_buildings) + geom_sf(colour="red")

-
+
-
-

Callout -

+
+

Callout

If you encounter an error linked to your internet proxy (“Error: Overpass query unavailable without internet R”), run this line of code. @@ -7662,7 +7665,7 @@

Challenge: Conservation rules have -
+

R @@ -7838,8 +7841,8 @@

Key Points

+

@@ -852,8 +855,8 @@

Key Points +

@@ -7416,7 +7420,7 @@

Key Points

Content from Basic GIS operations with R and sf


-

Last updated on 2024-02-27 | +

Last updated on 2024-03-05 | Edit this page

Estimated time: 70 minutes

@@ -7518,13 +7522,12 @@

R ggplot(data = old_buildings) + geom_sf(colour="red")

-
+
-
-

Callout -

+
+

Callout

If you encounter an error linked to your internet proxy (“Error: Overpass query unavailable without internet R”), run this line of code. @@ -7744,7 +7747,7 @@

Challenge: Conservation rules have -
+

R @@ -7920,8 +7923,8 @@

Key Points