Jamie Dixon
Jamie Dixon

Reputation: 4302

Using read.csv in R drops rows that have a NA in them?

I am executing this line of code to import a file

flowers <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data")

149 rows come in. The problem is that there are 151 rows in the original dataset. When I look at the unique values for the last column (#5), the 2 rows with a "NA" are getting dropped:

unique(flowers[,5])

What do I have to do to include those 2 rows?

Upvotes: 2

Views: 58

Answers (1)

akrun
akrun

Reputation: 887911

You can use blank.lines.skip=FALSE in the read.csv to get the blank lines as well

flowers <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.dat‌​a",
        blank.lines.skip=FALSE)

Upvotes: 2

Related Questions