Skip to content
R for the Rest of Us Logo

Mapping with R

34 lessons

Necessary HTML for Labelling leaflet Maps (03_03)

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window


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

Open project 03_03.

Use the your-turn.R script in 03_03 to add this popup to each state.

  • Format the state name in bold

  • Use a <br> to add a line break

  • Use scales::number() to format the population

Learn More

Unfortunately, it is necessary to learn a little bit of HTML to get the most out of your interactive maps. HTML is a very different language to R, it’s a “markup language” instead of a “scripting language”. In principle, HTML is a little bit easier to learn than R as you use tags to “markup content” and that’s about it.

I quite like the free HTML training materials available here.

CSS is the other side of HTMl and this is how styles are defined for each HTML tag. The CSS language can be more complex than HTML but you can achieve everything in this course without learning any CSS.

As I mentioned in the first video, the {leaflet} package is actually using the leaflet JavaScript package. It is absolutely unnecessary to learn JavaScript for the vast majority of maps you’ll want to make. My advice if you do discover you need JavaScript is to find examples of existing code that are close to what you want to build and move forwards from there.

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

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

Bohdanna Kinasevych

Bohdanna Kinasevych

April 18, 2022

Hi again! Here's a random question. How do you get your tibbles to wrap around and display the first five rows for ALL columns? Mine only shows what fits across the screen followed by "# ... with 1 more variable: var 1 " I end up using glimpse(), print() or view() a lot but I'd prefer to get the full display without any extra commands.