Prevent variable name getting mangled by read.csv/read.table?

后端 未结 2 775
暗喜
暗喜 2021-01-25 13:33

My data set testdata has 2 variables named PWGTP and AGEP

The data are in a .csv file.

When I do:

<         


        
2条回答
  •  走了就别回头了
    2021-01-25 14:19

    This is a BOM (Byte Order Mark) UTF-8 issue.

    To prevent this from happening, 2 options:

    1. Save your file as UTF-8 without BOM / signature -- or --
    2. Use fileEncoding = "UTF-8-BOM" when using read.table or read.csv

    Example:

    mydata <- read.table(file = "myfile.txt", fileEncoding = "UTF-8-BOM")

提交回复
热议问题