Get the App
SLTechnology News&Howtos  ›  Development  › 

How to deal with NA data in R language

Shulou Source: shulou.com Published: 2022-06-01 07:26:07 10月03日 Update

This article introduces the knowledge of "how to deal with NA data in R language". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Handle, replace or delete NA cases that exist in the data

Processing data with NA values

Dat sample1 sample2 sample2.1A 1 5 8B 2 NA NAC NA 7 10D 4 9 1

Replace all null values with zeros

> for (I in 1:ncol (dat)) {+ dat [is.na (dat [, I]), I] = 0 +} > dat sample1 sample2 sample2.1A 158B 200C 0 7 10D 4 9 1

Delete all NA data

> for (I in 1:ncol (dat)) {+ dat=dat [! is.na (dat [, I]),] +} > dat sample1 sample2 sample2.1A 158D 491 "how to process NA data in R language" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Data processing language content situation more knowledge practicality achievement and then dilemma practice articles cases editing websites industries processes high quality learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL Microsoft OPPO Reno macOS