sql server - How to fix locale errors in RODBC (WAS: R CMD BATCH: "$ operator is invalid for atomic vectors" but not in Rstudio) -
maybe related: stack overflow: windoes not support utf-8
i have script can source rstudio
, when try source rgui.exe
or try batch cmd
run, following error in rout
file:
error in easy_clean$sv_karakter: $ operator invalid atomic vectors
the reason database table quering have latin charachter 'ø' in name (se third line below). result of query (as per str(easy)):
"";"x" "1";"42000 102 [microsoft][odbc sql server driver][sql server]incorrect syntax near '¸'." "2";"[rodbc] error: not sqlexecdirect 'select * prøvedeltager left outer join aftaler b on b.cpr = a.cpr left outer join godk c on c.godk_id = b.godk_id a.slut >= '20140808' , a.slut <='20140818' , a.branche = 'vvs' , a.saleid not null , a.cpr in (select x.cprnr statistik x) order sv_karakter'"
in rstudio query works.
sys.getlocale('lc_ctype')
returns danish_denmark.1252
in both r.gui , rstudio - don't know how fix this.
i did find this link developer.r-project discus windows locales (quite old though).
for have created database view without 'ø' - view can call without problems r.
from sessioninfo
can that:
rstudio r 64 bit, , r.exe 32 bit.
other that, difference this, rstudio:
loaded via namespace (and not attached): 1 tools_3.1.0
since can't write database credentials, can't create reproducible example. here script. http://pastebin.com/xwdzphl7
two ways can imagine yield error code: 1 if results in single column:
easy[!is.na(easy$sv_karakter),]
in case, result vector because of default action of "[" function create atomic vectors single column results. attempts extract column fail error. other case of failure (but perhaps not error) when there no 'sv_karakter' column in 'easy' dataframe.
better efforts @ documentation offering str(easy)
or dput(head(easy))
needed.
your query returned error message , in form of r vector. explains particular error. need figure out how db connection getting messed up, andreas saying.
Comments
Post a Comment