R, remove the Na line from the Dataframe

Source: Internet
Author: User

Use Complete.cases and Na.omit in R to remove rows containing NA

Now there is a data.frame datafile as shown below

Date sulfate nitrate ID

1 2015-1-1   NA        NA     1
2 2015-1-2  2          6     1
2015-1-3  NA         3     1
2015-1-4  4          NA     1
2015-1-5  NA         NA    NA
2015-1-6  5          7     1


去掉所有包含NA的行,
Datafile[complete.cases (datafile),]
结果如下:

Date sulfate nitrate ID

2 2015-1-2  2          6     1
2015-1-6  5          7     1
NA filtering for a column
datafile [Complete.cases (datafile[, 3:4]),]
The results are as follows:

Date sulfate nitrate ID

2 2015-1-2  2        6    1
2015-1-3   NA         3     1
2015-1-6   5          7     1
 

R, remove the Na line from the Dataframe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.