1KG_1_14106394` [...">

R-coding ASCII-backtick

I have the following feedback in the names of my lists. Previous listings did not have this backtick.

$`1KG_1_14106394` [1] "PRDM2" $`1KG_20_16729654` [1] "OTOR" 

I found out that this is an β€œASCII serious accent” and read the R page on coding types. However, what to do about it? I do not understand whether this will affect some functions (for example, matching names in a list), or is it normal to leave it as it is?

Encoding Help Page: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Encoding.html

Thanks!

+2
source share
1 answer

My understanding (and I could be wrong) is that the reverse steps are just a way to avoid a list name that would otherwise not have been possible if it hadn't been saved. One example of using backreferences to reference a list name is a name that contains spaces:

 lst <- list(1, 2, 3) names(lst) <- c("one", "after one", "two") 

If you want to refer to a list item containing number two, you can do this using:

 lst[["after one"]] 

But if you want to use dollar sign notation, you'll need backlinks:

 lst$`after one` 

Update:

I just bumped into SO and found this post discussing a similar question like yours. Reverse labels in variable names are needed when the variable name is denied otherwise. Spaces are one example, but the reserved keyword is also used as the variable name.

 if <- 3 # forbidden because if is a keyword `if` <- 3 # allowed, because we use backticks 

In your case:

Your list has an element whose name begins with a number. The rules for variable names in R are pretty weak, but they cannot start with a number, therefore:

 1KG_1_14106394 <- 3 # fails, variable name starts with a number KG_1_14106394 <- 3 # allowed, starts with a letter `1KG_1_14106394` <- 3 # also allowed, since escaped in backticks 
+2
source

Source: https://habr.com/ru/post/1258534/


All Articles