I have the following data frame:
> ddf = data.frame(name=c('a','b'), value=c(10,20)) > ddf name value 1 a 10 2 b 20
I am trying to get xx from ddf using the following command:
> xx = ddf[ddf$name=='a','value'] > xx [1] 10 > xx = ddf[ddf$name=='c','value'] > xx numeric(0)
How can I check if xx is a real number and not 'numeric (0)'. I tried the following:
> is.numeric(xx) [1] TRUE > is.na(xx) logical(0) > is.null(xx) [1] FALSE > is.logical(xx) [1] FALSE
I have to ask xx = ddf[ddf$name=='a', 'value'] from different ddf data. Sometimes ddf does not contain 'a' and therefore the value is not returned. I want to discover this.
source share