When trying to use a noquoted character vector as a column of a data frame, I receive an error stating "cannot coerce class ""noquote"" to a data.frame".
To reproduce, try:
data.frame(x = noquote(letters))
## Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
## cannot coerce class ""noquote"" to a data.frame
This is a specific case of the more general problem of trying to include an atomic vector with a class attribute into a data frame.
data.frame(x = structure(1:10, class = "something"))
## Error in as.data.frame.default(x[[i]], optional = TRUE) :
## cannot coerce class ""something"" to a data.frame
Currently the base package has as.data.frame methods for including factors, Dates and POSIXcts, all of which are the same function:
identical(as.data.frame.POSIXct, as.data.frame.Date) #TRUE
identical(as.data.frame.POSIXct, as.data.frame.factor) #TRUE
Thus the simplest workaround is to reuse that function for noquotes.
as.data.frame.noquote <- base::as.data.frame.factor
data.frame(x = noquote(letters)) #now works as expected
I'll add an as.data.frame.noquote method, so this will be fixed. I'll also add a line to the ?as.data.frame help topic explaining how to do this for other vector-like classes.