作者:认知天下微博 | 来源:互联网 | 2023-08-19 14:57
IamusingRODBCtoconnectmysqlwithRlikebelow:我正在使用RODBC将mysql与R连接如下:library(RODBC)channel
I am using RODBC
to connect mysql
with R like below:
我正在使用RODBC将mysql与R连接如下:
library(RODBC)
channel=odbcConnect("MySQL_ODBC_AIRFORECASTSYSTEM",uid="root",pwd = "3896123ray")
sql="select * from region_station"
ttt=sqlQuery(channel,query = sql)`
Ss you can see I've put the result into a data.frame, "ttt", and I can use View(ttt)
to show the contain, and the Chinese shows properly.
你可以看到我把结果放到data.frame,“ttt”,我可以使用View(ttt)显示包含,中文显示正确。
However, when I use ttt[,2]
trying to show the second column in console, it became like this:
但是,当我使用ttt [,2]试图在控制台中显示第二列时,它变成了这样:
Any help would be greatly appreciated.
任何帮助将不胜感激。
The first column is the Chinese, the second column is outcome of mysql's hex(), and the third column is the result in Rstudio's console.
第一列是中文,第二列是mysql的hex()的结果,第三列是Rstudio控制台的结果。
二林站 E4BA8CE69E97E7AB99 鈭\x9e\xab\x99
二林站E4BA8CE69E97E7AB99鈭\x9e\ xab \ x99
南投站 E58D97E68A95E7AB99 \xe5\x8d\x8a\xab\x99
南投站E58D97E68A95E7AB99 \ xe5 \x8d\x8a\ xab \ x99
埔里站 E59F94E9878CE7AB99 \xe5\x9f\x87\xab\x99
埔里站E59F94E9878CE7AB99 \ xe5 \x9f\x87\ xab \ x99
大里站 E5A4A7E9878CE7AB99 憭折\x87\xab\x99
大里站E5A4A7E9878CE7AB99憭折\x87\ xab \ x99
彰化站 E5BDB0E58C96E7AB99 敶啣\x8c\xab\x99
彰化站E5BDB0E58C96E7AB99敶衔\x8c\ xab \ x99
忠明站 E5BFA0E6988EE7AB99 敹\x98\xab\x99
忠明站E5BFA0E6988EE7AB99敹\x98\ xab \ x99
1 个解决方案