Skip to content
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

Complete the themes sections of the data-visualization-exercises.Rmd file.

Learn More

Themes Resources

Data Visualization: A Practical Introduction has a section on themes in Chapter 8. R for Data Science covers them in Chapter 28.

If you’re looking for packages that give you extra themes, in addition to ggthemes and hrbrthemes, check out bbcplot, which lets you make plots in the style of the BBC, firatheme, and a fun one called ggpomological, which lets you make plots that look like this:

Note that theme packages often include code that changes to overall look and feel as well as palettes that you can apply to the color and fill scales.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Oindrila Bhattacharyya

Oindrila Bhattacharyya

March 25, 2021

After installing hrbrthemes through devtools, when I add theme_ipsum, it shows me these series of error messages: font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database

What should I do?

David Keyes

David Keyes

March 25, 2021

Oh man, custom fonts are the bane of my existence. For now, check out this article by Andrew Heiss, which has some ideas. There are also some attempts to make this whole process much simpler, which should help. We'll talk about both of these in a future R in 3 Months session!

Jody Oconnor

Jody Oconnor

April 13, 2021

I got the same repeated 'font family not found in Windows font database' error. But the new plot still appeared under the messages with a new theme. Before that I got these error messages upon loading hrbrthemes:

Error: package or namespace load failed for ‘devtools’ in loadNamespace(j = 2.4.0 is required

package �hrbrthemes� was built under R version 4.0.4Registering Windows fonts with R NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes. Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow

I'm assuming I don't need to do anything for now, since I still got my new plot with a new theme... looking forward to learning more about this in class. I do wonder if I need to learn to replace old versions of things like "namespace ‘cli’ 2.3.1 is already loaded", with newer versions when I'm told "but >= 2.4.0 is required" (updating all my packages didn't make the message change and I'm not sure how else to update parts of packages...)

David Keyes

David Keyes

April 14, 2021

Yup, we'll discuss more on Thursday for sure!

On the updating packages issue, if everything is working, I wouldn't worry about it. Just chalk it up as an R quirk (there are many!).

Catherine Roller White

Catherine Roller White

April 10, 2021

When I ran devtools::install_github("hrbrmstr/hrbrthemes") I received the following message:

package ‘vctrs’ successfully unpacked and MD5 sums checked Error: Failed to install 'hrbrthemes' from GitHub: (converted from warning) cannot remove prior installation of package ‘vctrs’

I looked for something called "vctrs" but couldn't find it. Any ideas for how I might resolve this issue? Thank you!

David Keyes

David Keyes

April 12, 2021

Hmm, that's very odd. Can you try installing hrbrthemes by just using install.packages("hrbrthemes") and let me know if it works any better?

Catherine Roller White

Catherine Roller White

April 12, 2021

Thank you. I tried that and got this message:

package �hrbrthemes� was built under R version 4.0.5Error: package or namespace load failed for ‘hrbrthemes’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘vctrs’

I tried re-running the other lines of code in case that would help:

devtools::install_github("hrbrmstr/hrbrthemes") library(hrbrthemes)

Everything looked like it was installing pretty well, but when I knit my document with theme_ipsum() I received the effort message "font family not found in Windows font database" repeated about 18 times.

Catherine Roller White

Catherine Roller White

April 12, 2021

I guess you could call it an "effort message," but it was actually an error message. :) Please excuse the typo.

David Keyes

David Keyes

April 12, 2021

Hmm, on your first issue, seems like the vctrs package didn't get installed. Can you try installing it manually using install.packages("vctrs", repos = " https://packagemanager.rstudio.com/cran/latest").

On the second issue, it's just an issue with how custom fonts work. I'll explain in our live session on Thursday.

Lisa Janz

Lisa Janz

May 11, 2021

Can you explain how to load additional fonts on this forum so that we can complete the exercises for the course?

David Keyes

David Keyes

May 11, 2021

Using custom fonts has changed a lot in recent months! Check out this video, which should help you. Let me know if you still have questions.

Lisa Janz

Lisa Janz

May 11, 2021

I have tried multiple things but am still having problems. I did try a fix that came up when I reloaded some stuff, including a message about how to upload hrbrthemes fonts into my Windows library. Found a great fix: extrafont::loadfonts(device="win"), which does something, but themes_ipsum is still not loading the right fonts... perhaps because I just haven't been able to load the right packages yet. I am going to keep trying to figure this out, but if other people continue to have problems they are not alone.

Another thing I am wondering about is that I keep getting this error message when I load and update libraries: Warning message: package ‘hrbrthemes’ was built under R version 4.0.5 I updated my copy of R-Studio a couple months ago and have updated my packages, so not sure what is going on there and if it is part of my problem.

Lisa Janz

Lisa Janz

May 11, 2021

Further research suggests that the Arial Narrow font is often missing from Windows. Not sure where a safe place is to download it, so I will just let the Ipsum package lie for now. It does seem like the other themes work for me now after uploading all the font packages from the hrbrthemes folder and importing them into R.

David Keyes

David Keyes

May 12, 2021

On Arial Narrow, one option is to just try a different them from that package. There is one called theme_ipsum_ps() which uses IBM Plex Sans. You can download that font using the import_plex_sans() function (see https://hrbrmstr.github.io/hrbrthemes/reference/import_plex_sans.html).

David Keyes

David Keyes

May 12, 2021

On that warning message, it's nothing to worry about. Just means that the person who made the package used a different version of R (not RStudio or any packages, but the core R software) when making it. It shouldn't impact how anything works.

When trying to install the package I got the warning: WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools 4.0 from https://cran.r-project.org/bin/windows/Rtools/. Downloading GitHub repo hrbrmstr/hrbrthemes@HEAD

But when I go to packages in the console and look up rtools, no results.

Now that I've actually read that page, I installed Rtools and could then install hrbrthemes

David Keyes

David Keyes

October 11, 2021

Glad you got it figured out!

David Keyes

David Keyes

October 11, 2021

Good questions!

On the theme question, what you're getting toward is developing your own package. You can see an example of how I've done this with another client here. While developing your own package can be a bit of a challenge (you can also hire R for the Rest of Us to do this :) ), you can see some resources on doing so here. I'll also mention that I'll have a course on package development on the R for the Rest of Us website early next year.

On fonts, yes, you do need to make sure people have them installed. I would typically choose something that you know everyone will have. For the custom package linked above, we used Lato, which is that organization's brand font (and thus they know everyone has it installed). I wouldn't typically have a backup font, but if you do want to be really safe, your best bet might be to use the showtext package. This package can allow you to use Google Fonts, which is helpful because you know everyone can have access to them. Hope that helps!

Acarilia Eduardo

Acarilia Eduardo

May 5, 2022

I've resumed my study today after one week, and now I am getting this message "Error in ggplot(data = sleep_by_gender, mapping = aes(x = gender, y = avg_sleep, : object 'sleep_by_gender' not found"

I understand that the variable "sleep_by_gender" cannot be found even though we/I created it in previous exercises of this course. How come R cannot find it anymore even though I had saved each exercise after running them? What should I do now to be able to move on? (I keep RStudio open on my laptop at all times)

Thank you for your patience in advance.

Charlie Hadley

Charlie Hadley

May 5, 2022

Hello Acarilla,

Unfortunately, keeping RStudio open at all times is not a reliable way to ensure that objects are persistently available in the environment. As you begin to do more things with R you'll also start to use R projects and could potentially have multiple copies of RStudio open - each session being a different project.

This error is because the RStudio environment doesn't contain sleep_by_gender anymore. You'll need to re-assign the variable.

This concept also informs how we write R code. R code should be written from top to bottom so you could theoretically select all the code in a script and click "Run" and all the code would run in turn. In the case of RMarkdown we would use the "Run all code chunks" button.

Let me know if you have questions!

Thanks,

Charlie

Acarilia Eduardo

Acarilia Eduardo

May 8, 2022

Thanks so much for clarifying, Charlie!

Hannah Ridenour LaFrance

Hannah Ridenour LaFrance

October 10, 2022

I installed the ragg and systemfonts packages to attempt to resolve the font issue mentioned by others regarding theme_ipsum. However, it appears to have messed up tidyverse in doing so. I tried to re-install tidyverse but am still getting the following error message with library(tidyverse):

Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace ‘rlang’ 1.0.5 is already loaded, but >= 1.0.6 is required

What should my next step be?

David Keyes

David Keyes

October 10, 2022

It's telling you that you need a newer version of rlang. I'd try to install that on its own using install.packages("rlang"). Then, you should be able to reinstall tidyverse. Let me know if that works!

Hannah Ridenour LaFrance

Hannah Ridenour LaFrance

October 11, 2022

That resolved the tidyverse issue, although I also had to install Rtools in order to get back to square one. After all that, I'm still having the font family issues, but I've resolved to just avoid theme_ipsum in the short term to be able to move forward. Other themes like theme_minimal work fine.

Melissa Mullins

Melissa Mullins

April 19, 2023

I see that a bunch of people in the past got this same error message that I did: Warning: font family not found in Windows font database I wouldn't care about it, except that the resulting plot had the title so large it got cut off (it was fine in the previous default theme). I looked at the two references below, but that's a lot deeper in the weeds than I want to go- I just want the easy button when it comes to fonts/ themes and applying them (if there is such a thing). Look forward to learning more!

David Keyes

David Keyes

April 19, 2023

If you want the easy route, my suggestion is to use theme_minimal() instead.