1

I have this dataframe:

Id         weight sex 
Blank row
1            150   F
2            120   M
3            140   M
4            100   F
5            90    F

So, I used this command to delete the blank row:

new.dt <- dt[is.na(dt$Id) | dt$Id != "",]

But, when I will do the statistical the blank row still considered, for example:

str(new.dt$sex)


 Factor w/ 3 levels "","F","M"

How I delete this blank information from my analysis?

Curious G.
  • 838
  • 8
  • 23

1 Answers1

2

We can use droplevels to drop any unused factor levels in any of the columns

new.dt <- droplevels(new.dt) 
akrun
  • 874,273
  • 37
  • 540
  • 662