JoZ
JoZ

Reputation: 191

R console doesn't display unicode in a correct form

Our teacher asked us to use kable() function when finishing our data analysis problem. However, when I run the sample code the teacher provided, the unicode seems doesn't display correctly:

The sample code is the following:

n <- 100
x <- rnorm(n)
y <- 2*x + rnorm(n)
out <- lm(y ~ x)
library(knitr)
kable(summary(out)$coef,digits=2)

And the R console returns me the following graph:

|            | Estimate| Std. Error| t value| Pr(>&#124;t&#124;)|
|:-----------|--------:|----------:|-------:|------------------:|
|(Intercept) |    -0.07|       0.09|   -0.79|               0.43|
|x           |     2.05|       0.09|   22.81|               0.00|

The correct form of the last column should be Pr(>|t|) instead.

However, if change my code to:

kable(summary(out)$coef, format="latex",digits=2)

The returned result is:

\begin{tabular}{l|r|r|r|r}
\hline
  & Estimate & Std. Error & t value & Pr(>|t|)\\
\hline
(Intercept) & -0.07 & 0.09 & -0.79 & 0.43\\
\hline
x & 2.05 & 0.09 & 22.81 & 0.00\\
\hline
\end{tabular}

I suspect the problem is with the markdown system on my computer. Do anyone know how to fix this problem?

Upvotes: 1

Views: 203

Answers (1)

as26
as26

Reputation: 81

I pasted the result from kable(summary(out)$coef, format="latex",digits=2) into a latex compiler and then ran it with the following change Pr(\ge \mid t\mid). It worked. Sometimes R-Markdown doesn't do the job.

Upvotes: 1

Related Questions