How do I introduce a tilde (~) in R?

I need to write the tilde character in R a lot, but I haven't found anything useful on the internet. I am using an Italian keyboard on Linux OS.

Do some of you have any ideas?

Any hints or recommendations would be appreciated.

+3


source to share


2 answers


According to this link on Superuser:

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



AltGr + ^

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

+7


source


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

      

You can use this variable when you need a 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

      

Alternatively, you can just type tilde

and copy and paste the character.

+6


source







All Articles