How do we replace NA values with zeros in R?

Answer

> m <- matrix(sample(c(NA,1:10),100, replace =TRUE),10)> d <- as.data.frame(m)
   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
143NA376610652989510NA2172311636NA14164NA4NA7102NA4185124NA2626746NA3NANA10211084744910989410NA858321459479391019910533104225NA97255> d[is.na(d)]<-0> d
   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
143037661065298951002172311636014164040710204185124026267460300102110847449109894100858321459479391019910533104225097255

There's no need to apply apply. =)

All r Questions

Ask your interview questions on r

Write Your comment or Questions if you want the answers on r from r Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---