I am trying to add a "≈" to a data frame.
You can add symbols like "+" and "-" to a data frame. You can even add the ≈ symbol to a plot using
text(x,y, expression(""%~~%""))
but this won't work inside a data frame and I cannot find a way to do this. I have tried just pasting a ≈ using paste("≈") and a few other equally feeble things. For example:
x <- "≈"
print(x)
[1] "˜"
Here is a small example. The only difference that I would like to see is those middle two rows become ≈
df<-data.frame(prop=c(0.99, 0.97, 0.5,0.4,0.01, 0.02), symbol=NA)
df$symbol<-ifelse(df$prop>=0.95, "+","")
df$symbol<-ifelse(df$prop<=0.05, "-",df$symbol)
df$symbol<-ifelse(df$prop<=0.95 & df$prop>=0.05, "approximately equal symbol here",df$symbol)
df`
looks like
prop symbol
1 0.99 +
2 0.97 +
3 0.50 approximately equal symbol here
4 0.40 approximately equal symbol here
5 0.01 -
6 0.02 - -
What I would like
prop symbol
1 0.99 +
2 0.97 +
3 0.50 ≈
4 0.40 ≈
5 0.01 -
6 0.02 -
as per the comments
Sys.setlocale(locale='.utf8') or Sys.setlocale(locale='.65001')