how do you check if the value is null and replace it by NA in R -


i need write web service call returns data json:

{"application":"web","host":"prodwebserver01","datacenter":"nevada","pod":"1"} 

sometimes data can this:

{"application":"null","host":"prodwebserver01","datacenter":"nevada","pod":"1"} or {"application":"web","host":"prodwebserver01","datacenter":"nevada","pod":"null"} 

sometimes, values application:"null"

or datacenter:"null" , when this:

zlinux<-data.frame(cbind(tolower(d$guestid),tolower(d$host),d$application,d$pod,tolower(d$datacenter))) 

keys have null values not show on zlinux data frame. if value null, replace n_a , have 4 columns in data frame.

the following code:

suppressmessages(library(rcurl)) suppressmessages(library(rvest))  guests<-c("web01", "web02", "web03")  url<-c("https://example.com/inventory/guest/")  zlinuxcmdb<-data.frame(guest=character(),host=character(),app=character(),pod=character(),dc=character()) (i in guests) {    url<-paste0(url,i)     trycatch({             q<-geturl(url,ssl.verifypeer = false)                 trycatch({                         d<-fromjson(q)                         zlinux<-data.frame(cbind(tolower(d$guestid),tolower(d$host),d$application,d$pod,tolower(d$datacenter))) 

when of keys null, dont see them in zlinux data frame. if values null, how replace them na , keep zlinux data frame?


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -