开发者

Using read.csv, empty fields have NA added to data.frame

开发者 https://www.devze.com 2023-01-17 09:56 出处:网络
I am using read.csv to import a file that contains some columns with empty cells. I need these cells to remain empty and not contain any values.

I am using read.csv to import a file that contains some columns with empty cells. I need these cells to remain empty and not contain any values.

However, an NA is getting added everytime I import开发者_如何学Python. I have tried variations of na.strings (like na.strings="NULL" or na.strings="") to no avail.

Is there a simple way to force the observations to remain empty?

Any advice is appreciated.


After the import, try this:

x[is.na(x)] <- c("") ## Refills NA with blank character.

This converts the column to character but if you already have mixed strings I imagine it already is.

0

精彩评论

暂无评论...
验证码 换一张
取 消