I have a dataframe "c1" with one column as "region".
sum(is.na(c1$region))
[1] 2
class(c1$region)
[1] "factor"
However, when I use paste()
f1<-paste("c1","$","region",sep="")
> f1
[1] "c1$region"
> sum(is.na(f1))
[1] 0
I tried as.name(f1) and as.symbol(f1). Both convert f1 to the "name" class. noquote(f1) converts the char[1] element to the "noquote" class.
> f2<-as.name(f1)
> f2
`c1$region`
> sum(is.na(f2))
[1] 0
Warning message:
In is.na(f2) : is.na() applied to non-(list or vector) of type 'symbol'
> class(f2)
[1] "name"
I want to retain the class of c1$region while being able to use it in queries such as sum(is.na(f2)). Please help.