Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ARawles committed Jun 1, 2024
1 parent b6a540d commit c5e75fe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions data_types.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ This is something to bear in mind, converting a non-integer into an integer **wi
## Character

Sometimes called characters, or character strings, or just strings, characters store text. If you assign a value within quotation marks, regardless of what's inside the quotation marks, it will be stored as character. For example,
`"5"` stores a character string with the text "5", not the number 5. This is particularly important when you want to start combining variables. For example, ```{r, error = TRUE} "5" + 5``` doesn't work, because you're trying to add text to a number, which doesn't make sense.
`"5"` stores a character string with the text "5", not the number 5. This is particularly important when you want to start combining variables. For example, ```"5" + 5``` doesn't work, because you're trying to add text to a number, which doesn't make sense.

To check whether something is stored as a character, use the `is.character()` function:

Expand Down Expand Up @@ -164,7 +164,7 @@ as.factor(c("Some", "All"))

Notice the difference in the output of those three lines. The first allows us to specify the levels (i.e. the values that were possible). The second does the same but we also specify the ordering of the levels, and the third just converts the provided values and generates the levels based on that data.

*Note: An important change in R version 4.0.0 is that R will no longer automatically convert strings (characters) to factors when you import data using `data.frame()` or `read.table()`. Prior to 4.0.0, it would automatically convert strings to characters unless otherwise specified.*
*Note: An important change in R version 4.0.0 is that R will no longer automatically convert strings (characters) to factors when you import data using `data.frame()` or `read.table()`. Prior to 4.0.0, it would automatically convert strings to factors unless otherwise specified.*

### Converting from factors

Expand Down
6 changes: 3 additions & 3 deletions intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ RStudio is a massive part of how you interact with R however. For example, with

In the [previous section](#using-r), we talked very briefly of the R console and scripts. RStudio helps with this workflow. It makes it easier to create scripts, providing extra tools to help write code quicker, and then acts as a window to R when you want to execute the script.

RStudio is provided by a company called Posit. Previously, Posit was also called 'RStudio', which led to some confusion between the product and the company, hence the name change to Posit. But you may occasionally see the company still referred to as 'RStudio', so just bear in mind that it's different to the IDE we're describing here.

### What is an IDE?

At its simplest definition, an IDE helps you get work done in your programming language of choice. It can help you save blocks of code, organise projects, save plots and everything in between. R comes with a basic user interface when you install it, but RStudio provides lot more functionality to help you interact with the R console.
Expand Down Expand Up @@ -95,8 +97,6 @@ Some great examples of R packages are:
* [ggplot2](https://ggplot2.tidyverse.org/) for creating plots
* [dplyr](https://dplyr.tidyverse.org/) for data manipulation
* [shiny](https://shiny.rstudio.com/) for creating web apps
* [BMRSr](http://bmrsr.arawles.co.uk) for extracting energy data
+ Truth be told, this isn't a *great* example of a package, it's just the one I've made so that's why it's here.

The thing to remember is that R has a fantastic open source community and if you need to do something in R, somebody has probably written a package to help you out.

Expand All @@ -107,7 +107,7 @@ You can think of installing a package as a bit like installing a program on your
Installing packages is really easy; you just use the `install.packages()` function:

```{r, eval = FALSE}
install.packages("BMRSr")
install.packages("ggplot2")
```

You can choose where the package installs by supplying a path to the `lib` parameter (e.g. `lib = "C:/me/desktop"`), but by default it will install it into your default library folder. You can find the path to this default library folder with the `.libPaths()` function.
Expand Down
2 changes: 1 addition & 1 deletion operators.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To compare whether two things are equal, we use two equal signs (`==`) in R:
1 == 1 # equal
```

Why two I hear you say? Well, a bit later on we'll see that we use a single equals sign for something else.
"Why two '='?", I hear you say? Well, a bit later on we'll see that we use a single equals sign for something else.

To compare whether two things are different (not equal), we use `!=`:

Expand Down

0 comments on commit c5e75fe

Please sign in to comment.