I have been stuck on this for quite a while. I am trying to build a sql query to write to file, but I keep writing the text 'c("...")' as part of the output file, as if the concatenate function in R was being interpreted very literally.
I have eliminated the write() function itself, toString(), and the paste0() used as part of building the final output string. The first occurrence of the 'c' appears in the output of sQuote. When I try doing a call to sQuote() in interactive mode, I don't get the same behaviour:
Browse[2]> sQuote(sqlTableColumnValues)
[1] "‘c(\"0\", \"XXX0\", \"XXX056\", \"XXX139\", \"XXX143\", \"XXX144\", \"XXX159\", \"XXX171\", \"XXX185\", \"XXX188\", \"XXX192\", \"XXX202\", \"XXX239\", \"XXX240\", \"XXX245\", \"XXX256\", \"XXX271\", \"XXX303\", \"XXX319\", \"XXX326\", \"XXX334\", \"XXX357\", \"XXX363\", \"XXX368\", \"XXX390\", \"XXX391\", \"XXX417\", \"XXX426\", \"XXX431\", \"XXX439\", \"XXX447\", \"XXX456\", \"XXX461\", \"XXX466\", \"XXX475\", \"XXX483\", \"XXX488\", \"XXX491\", \"XXX521\", \"XXX531\", \n\"XXX538\", \"XXX541\", \"XXX548\", \"XXX550\", \"XXX581\")’"
Browse[2]> str(sQuote(sqlTableColumnValues))
chr "‘c(\"0\", \"XXX0\", \"XXX056\", \"XXX139\", \"XXX143\", \"XXX144\", \"XXX159\", \"XXX171\", \"XXX185\","| __truncated__
Browse[2]> tst <- c("foo","bar") #my own interactive test
Browse[2]> tst
[1] "foo" "bar"
Browse[2]> sQuote(tst) #does not show the 'c' character in the result
[1] "‘foo’" "‘bar’"
Browse[2]>
What is causing this discrepancy and how can I stop the 'c(...)' being written to my output file?
Update: dput output as requested:
Browse[2]> dput(sqlTableColumnValues)
structure(list(`1` = c("0", "XXX0", "XXX056", "XXX139",
"XXX143", "XXX144", "XXX159", "XXX171", "XXX185", ... #etc, I've truncated.
I don't yet understand what that means / what to do with this info. :-/