R converts "[]" to ".." when reading CSV files

Hi, I need your help.

I try to read csv files, created with Libreoffice Calc, in UTF-8.
They contain scientific values with m in [kg] for example.

When I read the table with

T=read.csv("FILE",sep=",",header=TRUE,encoding="UTF-8")

It is displayed as m.in.kg.

What is the problem here?

Are you referring to column names? If so, R is "cleaning" the column names because R doesn't work well with non-syntactic variable names (e. g. m in [kg]).

You can force read.csv() to let variable names as they are, by setting the check.names argument to FALSE but have in mind that it would make it harder to work with your data.

T=read.csv("FILE",sep=",",header=TRUE,encoding="UTF-8", check.names = FALSE)

I set it, but it stays like that. When copying the csv content to a plain text file, the symbols stay, the separator is "TAB".

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.