Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to type tilde (~) in R?

Tags:

r

I need to write often down the tilde symbol in R, but I did not find anything useful browsing on the internet. I am using an Italian keyboard on a Linux OS.

Does some of you have any ideas?

Any hint or advises would be appreciated.

like image 559
Quantopik Avatar asked Dec 10 '22 22:12

Quantopik


2 Answers

According to this link over at Superuser:

https://superuser.com/questions/667622/italian-keyboard-entering-the-tilde-and-backtick-characters-without-cha

AltGr + ^ will give you a tilde ~~~~ on a Linux system with an Italian keyboard, which is what you said you were using in the comments.

like image 76
thelatemail Avatar answered Dec 13 '22 12:12

thelatemail


(tilde <- rawToChar(as.raw(126)))
# [1] "~"

You could use this variable when you need tilde in text.

summary(lm(paste0("Sepal.Length", tilde, "Sepal.Width"), data=iris))
# Call:
# lm(formula = paste0("Sepal.Length", tilde, "Sepal.Width"), data = iris)
# 
# Residuals:
#     Min      1Q  Median      3Q     Max 
# -1.5561 -0.6333 -0.1120  0.5579  2.2226 
# 
# Coefficients:
#            Estimate Std. Error t value Pr(>|t|)    
# (Intercept)   6.5262     0.4789   13.63   <2e-16 ***
# Sepal.Width  -0.2234     0.1551   -1.44    0.152    
# ---
# Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 
# Residual standard error: 0.8251 on 148 degrees of freedom
# Multiple R-squared:  0.01382, Adjusted R-squared:  0.007159 
# F-statistic: 2.074 on 1 and 148 DF,  p-value: 0.1519

Alternately, you could just type tilde and copy and paste the character.

like image 35
josliber Avatar answered Dec 13 '22 11:12

josliber