Skip to content

Commit dffb3f5

Browse files
committed
Taster guide tweaks
1 parent 7fbfa3d commit dffb3f5

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

_freeze/posts/setting_up_w_r_online/index/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"hash": "905bb286f467a9800b7cf886286ec5bc",
2+
"hash": "45589ecefb91697157611e13990348f6",
33
"result": {
44
"engine": "knitr",
5-
"markdown": "---\ntitle: \"Getting started with using R and RStudio (in the cloud or on your own machine)\"\nauthor: \"Dan Olner\"\ndate: \"2025-05-16\"\ncategories: [training,code]\n---\n\n\n\n## Using R and RStudio: (1) on your own computer or (2) posit.cloud in the browser\n\nI'm running an \"R + regional economic data\" taster session in June. It won't be necessary to use R during the session to follow along - **but if you want to have a go at running the code I'll be talking through and don't yet have R/RStudio, here's how to get quickly set up**, either online or on your own computer[^2].\n\nTo do this, you'll need to do **one** of the following:\n\n1. **Use RStudio in your browser with a [posit.cloud account](https://posit.cloud)**. The **free version** is limited (very small memory, for instance) but **it's a very quick and easy option to have a play with R, if you don't have it installed already** and will be fine for the taster session. **The next section below talks through setting up in posit.cloud.**\n\n2. **Use R and RStudio on your own computer** If you have a machine where you're able to install your own software [then go here](https://cran.rstudio.com/) to download/install the right version of R for your operating system, and [here to download/install RStudio](https://posit.co/download/rstudio-desktop/) (again, pick the correct one for your OS). (Or if a work machine, ask IT, but note the bullet point at the bottom - firewall issues may stop play if your systems aren't set up for R already!)\n\n* The next chunk will talk through **setting up a posit.cloud project.**\n* The chunk after that talks through the setup for this project, and will **be nearly the same** whether you're using RStudio online or on your machine (with just one tweak, explained in the breakout box).\n\nAny questions/issues, let me know at d dot older at sheffield dot ac dot uk or [message me on LinkedIn](https://www.linkedin.com/in/danolner/) and I'll try to answer.\n\n## If using RStudio online: set up posit.cloud account and create your RStudio project\n\nHere's the steps to get up and running through a browser using posit.cloud.\n\n* [Create an account at posit.cloud](https://login.posit.cloud/login) using the 'sign up' box, and then log in. That'll take you to your online workspace.\n* Click the **new project** button, top right\n* Select 'new project from template' and then \"Data Analysis in R with the tidyverse\" (if not already selected). This comes pre-installed with the tidyverse package, which we'll be using. Select then click OK down at the bottom. **This will open your RStudio project where we'll do the coding.** \n\n## Make a new R script and add a library\n\nNow you should **either be in RStudio online through posit.cloud** or **you've opened RStudio on your own machine.** From here...\n\n* **Create a new R script** by going to 'file > new file > new R script' (or using the **CTRL+SHIFT+N** shortcut). A new script will appear, currently just called *'Untitled1'* until it's saved for the first time. \n* **At this point, it should look something like this:**\n\n![](rstudio_online.png)\n\nLet's stop for a moment and look at the separate windows in RStudio.\n\n* **Bottom left is the console**. Commands run here. You can test it by clicking in the console and trying a random command or two like those below (press enter to run a command in the console).\n\n(Note that all code blocks in this post have a **little 'copy to clipboard' icon in the top right** when you hover, if you want to just copy the code for pasting into RStudio).\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\n2+2\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 4\n```\n\n\n:::\n:::\n\n\n\nOr e.g.\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsqrt(49)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 7\n```\n\n\n:::\n:::\n\n\n\n* Bottom right of the RStudio window has various tabs, including local **files** (all kept inside your project folder so everything is self contained) and a list of available **packages**[^1].\n\n::: {.callout-note}\n## NOTE: IF USING RSTUDIO ON YOUR OWN COMPUTER...\n\nWe will be using the **tidyverse package/library** in the session. If you're using posit.cloud, this package comes pre-installed in the template we selected. However, **if you're using RStudio on your own machine, you will need to install the tidyverse package yourself** before we load it as a library. \n\nTo do this, just **run the following code in the console** (the same place we just did our '2+2' test, in the bottom left panel in RStudio.)\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\ninstall.packages('tidyverse')\n```\n:::\n\n\n\n**You should get a confirmatory message once the package has installed successfully** (though it may take a minute or two).\n\n:::\n\nNow, whether in posit.cloud or on your own computer, you should have the tidyverse package available.\n\n**It now needs to be loaded as a library** before we can use it:\n\n* **Put the following text at the top of the newly opened R script in the top left panel.** \n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(tidyverse)\n```\n:::\n\n\n\nWhen you've put that in, **the script title will go red**, showing it can now be saved (it should look something like the image below).\n\n![](script1.png)\n\n* **Save the script** either with the CTRL + S shortcut, or file > save. Give it whatever name you like, but note that it **saves into your self-contained project folder.**\n\n\n\n## Running code in an R script / loading the tidyverse library\n\nAll code will run in the console - what we do with scripts is just send our written code to the console. We do this in a couple of ways:\n\n1. In your R script, if no code text is highlighted/selected, RStudio will **Run the code line by line** (or chunk by chunk, but we'll come to that).\n2. If a block of text is highlighed, the whole block will run. So e.g. if you select-all in a script and then run it, the entire script will run.\n\nLet's do #1: **Run the code line by line**.\n\n* **To test this, we'll load the tidyverse library with the code we just pasted in**: put the cursor at the end of the `libary(tidyverse)` line in the script (if it's not there already), either with the mouse or keyboard. (Keyboard navigation is mostly the same as any other text editor like Word, but [here's a full shortcut list](https://support.posit.co/hc/en-us/articles/200711853-Keyboard-Shortcuts-in-the-RStudio-IDE) if useful.)\n* Once there, either use the 'run' button, top right of the script window, or (much easier if you're doing this repeatedly) **press CTRL+ENTER to run it.**\n\nYou should see the code get sent to the console, and a message like the one below confirming that R is 'Attaching core tidyverse packages'. **The tidyverse library is now loaded**.\n\n\n\n::: {.cell}\n::: {.cell-output .cell-output-stderr}\n\n```\n── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──\n✔ dplyr 1.1.4 ✔ readr 2.1.5\n✔ forcats 1.0.0 ✔ stringr 1.5.1\n✔ ggplot2 3.5.0 ✔ tibble 3.2.1\n✔ lubridate 1.9.3 ✔ tidyr 1.3.1\n✔ purrr 1.0.2 \n── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──\n✖ purrr::%||%() masks base::%||%()\n✖ dplyr::filter() masks stats::filter()\n✖ dplyr::lag() masks stats::lag()\nℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors\n```\n\n\n:::\n:::\n\n\n\n\n**That's it for now!** That'll be enough to be set up for the session. Any questions/issues, let me know at d dot older at sheffield dot ac dot uk or [message me on LinkedIn](https://www.linkedin.com/in/danolner/).\n\n\n[^1]: You can treat the terms 'package' and 'library' as interchangeble in R, but if you want to know the reason: if packages are like books, libraries are where the books are stored - we use the same name as the package to load a library. One of many examples of R being unnecessarily confusing with its language!\n\n[^2]: Installing R can be tricky on work machines if your organisation isn't familiar with it. R needs to access the internet to install libraries, for instance, and this can sometimes hit firewall issues. If you end up having this problem, I suggest trying the online posit.cloud route for now.\n",
5+
"markdown": "---\ntitle: \"Getting started with using R and RStudio (in the cloud or on your own machine)\"\nauthor: \"Dan Olner\"\ndate: \"2025-05-16\"\ncategories: [training,code]\n---\n\n\n\n## Using R and RStudio: (1) on your own computer or (2) posit.cloud in the browser\n\nI'm running an \"R + regional economic data\" taster session in June. It won't be necessary to use R during the session to follow along - **but if you want to have a go at running the code I'll be talking through and don't yet have R/RStudio, here's how to get quickly set up**, either online or on your own computer[^2].\n\nTo do this, you'll need to do **one** of the following:\n\n1. **Use RStudio in your browser with a [posit.cloud account](https://posit.cloud)**. The **free version** is limited (very small memory, for instance) but **it's a very quick and easy option to have a play with R** and will be fine for the taster session. **The next section below talks through setting up in posit.cloud.**\n\n2. **Use R and RStudio on your own computer**. If you have a machine where you're able to install your own software [then go here](https://cran.rstudio.com/) to download/install the right version of R for your operating system, and [here to download/install RStudio](https://posit.co/download/rstudio-desktop/) (again, pick the correct one for your OS). (Though see bullet point 2 below if using a work machine.)\n\n* The next chunk will talk through **setting up a posit.cloud project.**\n* The chunk after that talks through getting started with an RStudio project, and will **be nearly the same** whether you're using RStudio online or on your machine (with just one tweak, explained in the breakout box).\n\nAny questions/issues, let me know at d dot older at sheffield dot ac dot uk or [message me on LinkedIn](https://www.linkedin.com/in/danolner/) and I'll try to answer.\n\n## If using RStudio online: set up posit.cloud account and create your RStudio project\n\nHere's the steps to get up and running through a browser using posit.cloud.\n\n* [Create an account at posit.cloud](https://login.posit.cloud/login) using the 'sign up' box, and then log in. That'll take you to your online workspace.\n* Click the **new project** button, top right\n* Select 'new project from template' and then \"Data Analysis in R with the tidyverse\" (if not already selected). This comes pre-installed with the tidyverse package, which we'll be using. Select then click OK down at the bottom. **This will open your RStudio project where we'll do the coding.** \n\n## Make a new R script and add a library\n\nNow you should **either be in RStudio online through posit.cloud** or **you've opened RStudio on your own machine.** From here...\n\n* **Create a new R script** by going to 'file > new file > new R script' (or using the **CTRL+SHIFT+N** shortcut). A new script will appear, currently just called *'Untitled1'* until it's saved for the first time. \n* **At this point, it should look something like this:**\n\n![](rstudio_online.png)\n\nLet's stop for a moment and look at the separate windows in RStudio.\n\n* **Bottom left is the console**. Commands run here. You can test it by clicking in the console and trying a random command or two like those below (press enter to run a command in the console).\n\n(Note that all code blocks in this post have a **little 'copy to clipboard' icon in the top right** when you hover, if you want to just copy the code for pasting into RStudio).\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\n2+2\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 4\n```\n\n\n:::\n:::\n\n\n\nOr e.g.\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsqrt(49)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 7\n```\n\n\n:::\n:::\n\n\n\n* Bottom right of the RStudio window has various tabs, including local **files** (all kept inside your project folder so everything is self contained) and a list of available **packages**[^1].\n\n::: {.callout-note}\n## NOTE: IF USING RSTUDIO ON YOUR OWN COMPUTER...\n\nWe will be using the **tidyverse package/library** in the session. If you're using posit.cloud, this package comes pre-installed in the template we selected. However, **if you're using RStudio on your own machine, you will need to install the tidyverse package yourself** before we load it as a library. \n\nTo do this, just **run the following code in the console** (the same place we just did our '2+2' test, in the bottom left panel in RStudio.)\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\ninstall.packages('tidyverse')\n```\n:::\n\n\n\n**You should get a confirmatory message once the package has installed successfully** (though it may take a minute or two).\n\n:::\n\nNow, whether in posit.cloud or on your own computer, you should have the tidyverse package available.\n\n**It now needs to be loaded as a library** before we can use it:\n\n* **Put the following text at the top of the newly opened R script in the top left panel.** \n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(tidyverse)\n```\n:::\n\n\n\nWhen you've put that in, **the script title will go red**, showing it can now be saved (it should look something like the image below).\n\n![](script1.png)\n\n* **Save the script** either with the CTRL + S shortcut, or file > save. Give it whatever name you like, but note that it **saves into your self-contained project folder.**\n\n\n\n## Running code in an R script / loading the tidyverse library\n\nAll code will run in the console - what we do with scripts is just send our written code to the console. We do this in a couple of ways:\n\n1. In your R script, if no code text is highlighted/selected, RStudio will **Run the code line by line** (or chunk by chunk, but we'll come to that).\n2. If a block of text is highlighed, the whole block will run. So e.g. if you select-all in a script and then run it, the entire script will run.\n\nLet's do #1: **Run the code line by line**.\n\n* **To test this, we'll load the tidyverse library with the code we just pasted in**: put the cursor at the end of the `libary(tidyverse)` line in the script (if it's not there already), either with the mouse or keyboard. (Keyboard navigation is mostly the same as any other text editor like Word, but [here's a full shortcut list](https://support.posit.co/hc/en-us/articles/200711853-Keyboard-Shortcuts-in-the-RStudio-IDE) if useful.)\n* Once there, either use the 'run' button, top right of the script window, or (much easier if you're doing this repeatedly) **press CTRL+ENTER to run it.**\n\nYou should see the code get sent to the console, and a message like the one below confirming that R is 'Attaching core tidyverse packages'. **The tidyverse library is now loaded**.\n\n\n\n::: {.cell}\n::: {.cell-output .cell-output-stderr}\n\n```\n── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──\n✔ dplyr 1.1.4 ✔ readr 2.1.5\n✔ forcats 1.0.0 ✔ stringr 1.5.1\n✔ ggplot2 3.5.0 ✔ tibble 3.2.1\n✔ lubridate 1.9.3 ✔ tidyr 1.3.1\n✔ purrr 1.0.2 \n── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──\n✖ purrr::%||%() masks base::%||%()\n✖ dplyr::filter() masks stats::filter()\n✖ dplyr::lag() masks stats::lag()\nℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors\n```\n\n\n:::\n:::\n\n\n\n\n**That's it for now!** That'll be enough to be set up for the session. Any questions/issues, let me know at d dot older at sheffield dot ac dot uk or [message me on LinkedIn](https://www.linkedin.com/in/danolner/).\n\n\n[^1]: You can treat the terms 'package' and 'library' as interchangeble in R, but if you want to know the reason: if packages are like books, libraries are where the books are stored - we use the same name as the package to load a library. One of many examples of R being unnecessarily confusing with its language!\n\n[^2]: Installing R can be tricky on work machines if your organisation isn't familiar with it. R needs to access the internet to install libraries, for instance, and this can sometimes hit firewall issues. If you end up having this problem, I suggest trying the online posit.cloud route for now.",
66
"supporting": [],
77
"filters": [
88
"rmarkdown/pagebreak.lua"

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ <h5 class="quarto-listing-category-title">Categories</h5><div class="quarto-list
214214

215215
<div class="quarto-listing quarto-listing-container-default" id="listing-listing">
216216
<div class="list quarto-listing-default">
217-
<div class="quarto-post image-right" data-index="0" data-categories="training,code" data-listing-date-sort="1747350000000" data-listing-file-modified-sort="1747666497600" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="6" data-listing-word-count-sort="1134">
217+
<div class="quarto-post image-right" data-index="0" data-categories="training,code" data-listing-date-sort="1747350000000" data-listing-file-modified-sort="1747668821204" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="6" data-listing-word-count-sort="1109">
218218
<div class="thumbnail">
219219
<p><a href="./posts/setting_up_w_r_online/index.html" class="no-external"></a></p><a href="./posts/setting_up_w_r_online/index.html" class="no-external">
220220
<p class="card-img-top"><img src="posts/setting_up_w_r_online/rstudio_online.png" class="thumbnail-image card-img"/></p>

0 commit comments

Comments
 (0)