R - remove NA in character data with complete.cases

I want to delete rows containing NA values ​​in any "add" column of a dataframe using

a <- addition[complete.cases(addition), ]

      

and

a <- addition[!is.na(addition)]

      

and

a <- na.omit(addition)

      

but NA remains. I also tried to restrict to a complete.cases

single column containing some neural networks. I found out that they are not identified at all:

   which(is.na(addition))
    integer(0)

      

Adding the padding data looks like this (NA is the 4th column on line 1211):

row.names lemma pos derlemma derpos handannotated
11 akvizice N perform_akvizice V 1
1211 diagnóza N NA V 1
1221 dialýza N dialyzovat V 1
1241 díkuvzdání N perform_díkuvzdání V 1

      

I only remove NS using this:

a <- addition[which(addition$derlemma != "NA"), ]

      

Am I using the complete.cases function or annotated "NA" in the wrong way, or can I mess up something in R Studio's custom options?

Thanks a lot for any support.

Working with RStudio version 0.98.1028, Win 7 Professional 64x.


LATER: Thanks to the answers below, I realized that "NA" in symbolic variables is not interpreted as "not available" but as a string.

I created the entire dataset in R and subsequently added "NA" (no quotes) strings to some cells in the data editor in RStudio. Therefore, I have not indicated for R that "NA" stands for NA.

When I saved the dataframe as .csv and reloaded it using read.table (), I was able to specify na.strings = "NA" and complete.cases (). Thanks again to all the advisors!

+3


source to share





All Articles