colours that R knows

Series: IDHTG

I have been working through the ggplot R Advent calendar by Kiirsti Owen with some lovely RLadies friends and we got up to Day 15 where we started controlling colours in ggplot with scale_fill_manual(). Our immediate question was “how to you know what the names of the colours that R knows are?” This is a “I don’t have to google” post about finding the colours that R knows about. trees %>% ggplot(aes(x=type, y=height))+ geom_boxplot(aes(fill=type), colour="black")+ theme_classic()+ scale_fill_manual(values=c("darkgreen", "firebrick2", "mediumseagreen")) You can have R list the names of all the colours it knows (there are 657 of them) using the colours() function, but that is not so useful if you want to see the difference between hotpink1 and hotpink2.

By Jen Richmond

December 14, 2022

how to subset strings

Series: IDHTG

Sometimes you have a column in your data frame that is text, but there is some of it that you don’t need. Lets say your data looks like this… df <- data.frame(animals = c("this is a bear", "this is a lion", "this is a tiger")) df ## animals ## 1 this is a bear ## 2 this is a lion ## 3 this is a tiger And perhaps only want the animal names… you can use sub_str() from the stringr package to strip out the extra characters.

By Jen Richmond

September 29, 2022

git hints

I am getting pretty good at avoiding git merge conflicts by always remembering to pull before I push when using github. But the terminal in RStudio has been giving me this hint for a while and I have been ignoring it. I think this hint is trying to help me but I don’t know what rebase or fast-forward means… to google… This post suggests that I should only use git pull -ff, going as far as setting -ff as a global config setting.

By Jen Richmond

September 28, 2022

analysing smartwatch data

Sometimes trying to replicate what someone is doing in a blogpost you find on twitter is a great way to learn something new. I am half heartedly thinking about trying to learn Python so when I saw this post about analysing smartwatch data on twitter I thought that it looked like interesting data and perhaps if I tried to do what they had done in R, that would be a useful way of starting to translate my R knowledge into python… maybe.

By Jen Richmond

July 13, 2022

using lists in R

One of my goals while on long service leave is to learn some new R things that have been on my radar for a while… the first of these is purrr. The purrr package allows you to iterate a function across different elements in a list or dataframe. I have started to try and learn purr before ( see a list of resources here and I have copied other people’s purrr code a couple of times and used map to read in a LOT of .

By Jen Richmond

June 27, 2022