Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gsub error message when addressing column in dataframe in RStudio

Tags:

r

rstudio

Since a couple of days I get the following error message in RStudio from time to time and can't figure out what is causing it.

When I write in the console window to address a data.frame followed by $ to address a specific column in the data.frame (for example df$SomeVariable), the following message is shown in the console window and is printed over an over with every letter I type

Error in gsub(reStrip, "", completions, perl = TRUE) :
 input string 38 is invalid UTF-8

The error message doesn't have any real effect. Everything works just fine except the automatic completion of the variable name. I'm using R version 3.4.4 and RStudio Version 1.0.143 on a Windows computer. In the R script I am currently working on I don't use gsub or any other "string" or regular expression function for that matter. The issue appeared with various data.frames and various types of variables in the data.frames (numeric, integer, date, factor, etc.). It also happens with various packages. Currently, I am using combinations of the packages readr, dplyr, plm, lfe, readstata13, infuser, and RPostgres. The issue disappears for a while after closing RStudio and opening it again but re-appears after working for a while.

Does anyone have an idea what may cause this and how to fix it?

like image 394
Michael Avatar asked Dec 18 '22 23:12

Michael


1 Answers

I used to have the same problem a few days ago. I made some research and i found that when you import the dataset, you can change the encoding. Change the encoding to "latin1" and maybe that could fix your problem. Sorry for my poor english, im from Southamerica. Hope it works.

like image 178
Emiliano Barone Avatar answered Jan 17 '23 17:01

Emiliano Barone