Using ` vs ' in code

I’ve noticed that when completing missions that your platform wont accept my solution when using ', but instead wants us to use `. It’s a frequent reason why my code wont be accepted on a first attempt. I would think that those who are legit new to R and programming would struggle to see this difference. Is there a way for the code editor to accept either/or, or look at the solution itself to ensure that it matches what’s expected?

Hi @dshipley21. I’ll look into this. Can you provide me with an example of a screen where you have experienced this? Thanks!

1 Like

Hi @dshipley21,

It is always best to share the mission screen link and the code you have used (+ any additional details) when you create your question. This way, we would be able to help you faster. Luckily, yesterday a student asked me a similar question.

In R, we can use single quotes (’) or double quotes (") to create a string (character). And we use back-tick (`) character to use variable names that contain space characters. We teach this in the following screen:

Have a look at the sat_results data frame using the head() function to return the first ten rows.

Note that each variable name is surrounded in tick marks ( `` ). This is because the titles contain spaces, which are not valid in R variable names. When you work with tidyverse functions, surrounding invalid R variable names with tick marks will allow R to interpret them properly.

For example, In screen 5 of this mission:

We have to surround PROGRAM TYPE using backticks( `` ) because it is a column (variable) name with a space character.

class_size <- filter(class_size, GRADE == "09-12" & `PROGRAM TYPE` == "GEN ED")

Hope this helps :slightly_smiling_face:


1 Like

“backtick” is under the tilde at upper left of keyboard. I’m sure you already found it, but this might help someone else! Not clear in the course (Data Cleaning in R).

1 Like