Skip to content

Instantly share code, notes, and snippets.

@kevinushey
kevinushey / rstudio-windows-encoding-workarounds.R
Created September 23, 2016 18:24
Some workarounds for mis-encoded environment variables on Windows for users with non-ASCII characters in their username.
# Place this in a file at '~/.Rprofile' to ensure it's sourced on startup
.First <- function() {
# RStudio-specific startup
if (!is.na(Sys.getenv("RSTUDIO", unset = NA)) &&
Sys.info()[["sysname"]] == "Windows")
{
# work around mis-encoded environment variables
USERPROFILE <- Sys.getenv("USERPROFILE")
HOME <- file.path(USERPROFILE, "Documents", fsep = "\\")
R_USER <- HOME