Importing csv file into R - numeric values read as characters

前端 未结 6 864
逝去的感伤
逝去的感伤 2020-12-01 01:26

I am aware that there are similar questions on this site, however, none of them seem to answer my question sufficiently.

This is what I have done so far:

I

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 02:16

    In read.table (and its relatives) it is the na.strings argument which specifies which strings are to be interpreted as missing values NA. The default value is na.strings = "NA"

    If missing values in an otherwise numeric variable column are coded as something else than "NA", e.g. "." or "N/A", these rows will be interpreted as character, and then the whole column is converted to character.

    Thus, if your missing values are some else than "NA", you need to specify them in na.strings.

提交回复
热议问题