Hang's Blog
Observations and thinkings about economy, society and life.
Pages
Thursday, 20 March 2014
Codes for Replacing Special Values in R
grep {base} Pattern Matching and Replacement.
E.g., sub(“”, 0 ,dat)
dat[dat==“”] = 0 # replace empty cell in dat as 0
replace(x, list, values)
E.g., dat <- replace(dat, is.na(dat), 0)
na.strings=c("","NA") # replace empty cell as NA when importing data
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment