How to add degree symbol using roxygen2 for R documentation?
°C works in pdf, but it html, it is shown as °C.
Here is the session info.
R version 3.4.0 (2017-04-21)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 LC_MONETARY=English_India.1252
[4] LC_NUMERIC=C LC_TIME=English_India.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0
To add any non-ASCII characters in R documentation using roxygen2, the encoding must be declared using the tag #encoding.
So when °C is used in the roxygen code, adding the tag #encoding UTF-8 will render it correctly for html as well as pdf.
This can be checked with
path <- "path to Rd file"
tools::checkRd(path)
Related
As the title says, I normally use ctrl + shift + c to comment out multiple lines of code in Rstudio. It no longer works (nothing happens when I use the above shortcut).
I am using Rstudio version:
2022.02.3 Build 492
"Prairie Trillium" Release (1db809b8, 2022-05-20) for Windows
Session info:
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C
[5] LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1
I have had look in "Global options" but cannot see any setting relating to multiline commenting and in the "keyboard shortcuts help" section it still lists ctrl + shift + c as the correct shortcut. Anyone know what my issue could be?
To avoid problems when using R and RStudio, can R be configured to work with utf-8 by default? My system is windows 10 64 bit, R scripts are saved as ANSI, however when opening those same files with RStudio there are problems with the Latin characters, ñ, tildes, euro symbol €. I have to convert the files to change the character encoding, so that I can use them with RStudio.
From the R console:
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.5
In RStudio go to Tools bar, then click Global options (at the bottom):
See picture below: Click Code, then Saving -> you can set default text encoding
I am trying to insert some Unicode string to Microsoft SQL Server 2008 R2 from R Studio, but it does not work.
For example, "綫" , "Араб" , "❤" ...
And, here is my code:
library("RODBC")
sdb <- odbcConnect("R_SQLServ", uid="uid", pwd="pwd")
sqlQuery(sdb,"insert into test(someWord) VALUES(N'❤')")
odbcClose(sdb)
However, the value displayed on SQL database table is :
someWord
<U+2764>
Settings, background, or something I have tried and tested are as below:
sessionInfo() R version 3.4.3 (2017-11-30) Platform:
x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build
7601) Service Pack 1
Matrix products: default
locale: [1] LC_COLLATE=Chinese (Traditional)_Hong Kong S.A.R..950
LC_CTYPE=Chinese (Traditional)_Hong Kong S.A.R..950 [3]
LC_MONETARY=Chinese (Traditional)_Hong Kong S.A.R..950 LC_NUMERIC=C
[5] LC_TIME=Chinese (Traditional)_Hong Kong S.A.R..950
attached base packages: [1] stats graphics grDevices utils
datasets methods base
other attached packages: [1] RODBC_1.3-15 tmcn_0.2-12
loaded via a namespace (and not attached): [1] compiler_3.4.3
tools_3.4.3 yaml_2.1.14
The data type of the column was set to nvarchar(MAX).
In the R console, all of the characters are displayed correctly, but on the right side of R Studio panel with all my variables at the Environment tab, the variable that stored "❤" is displayed as "<U+2764>"
It works when I execute the SQL command INSERT INTO test (someWord) VALUES (N'❤') in SQL Server Management Studio.
I have tried resetting the locale setting on R Studio as different languages, either the same as my system language or not.
I have a big problem
I update R to the latest version.
After updating, every time i try to plot something with whatsoever kind of graphic function( even with the basic plot) i get this error
Error: Graphics API version mismatch
these are my session info
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Italian_Italy.1252
[2] LC_CTYPE=Italian_Italy.1252
[3] LC_MONETARY=Italian_Italy.1252
[4] LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_3.3.2 tools_3.3.2
Note: no visible binding for global variable 'x'
Note: no visible binding for global variable 'envir'
All packages installed are updated to the latest version available
I am reading input text file line by line with the following function:
lines_reader<-function(filename){
conn<-file(filename,open="r")
linn<-readLines(conn,encoding="UCS-2LE")
close(conn)
return(linn)
}
If I try to plot these lines in the R enviroment, letters with accent marks are treated not adequately appearing like "Ã" or "è" instead of "à" or "è".
How to cope with this? What encoding I should choose?
Here they are my session and local system info:
> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252
[3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.2.0
> Sys.getlocale()
[1] "LC_COLLATE=Italian_Italy.1252;LC_CTYPE=Italian_Italy.1252;LC_MONETARY=Italian_Italy.1252;LC_NUMERIC=C;LC_TIME=Italian_Italy.1252"
How about changing the encoding that you are using:
lines_reader<-function(filename){
conn<-file(filename,open="r")
linn<-readLines(conn,encoding="UTF-8")
close(conn)
return(linn)
}