只是想知道,有没有改变R列表对象的字符编码?我有一种感觉,我将不得不采取一些步骤,但我不确定.我已经搜索了这个主题,但我并没有从互联网上获得帮助.
例如,请考虑以下事项:
library(twitteR)
library(RJSONIO)
#Authorize with Twitter's API
reqURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "http://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey = "myconsumerkey"
consumerSecret = "myconsumersecret"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
twitCred$handshake()
B<-read.csv("BCorp RAW.csv")
handles<-B$Twitter.handle
handles<-na.omit(handles)
start <- getUser(handles[12])
library(rjson)
friends.object<- lookupUsers(start$getFriendIDs(), includeNA=TRUE)
followers.object<-lookupUsers(start$getFollowerIDs(), includeNA=TRUE)
Run Code Online (Sandbox Code Playgroud)
命令
followers.object<-lookupUsers(start$getFollowerIDs(), includeNA=TRUE)
Run Code Online (Sandbox Code Playgroud)
抛出以下错误:
Error in twFromJSON(out) :
Error: Malformed response from server, was not JSON.
The most likely cause of this error is Twitter returning a character which
can't be properly parsed by R. Generally the only remedy is to wait long
enough for the offending character to disappear from searches (e.g. if
using searchTwitter()).
Run Code Online (Sandbox Code Playgroud)
在使用twitter时,如何允许R保留特殊字符?希望我编辑得很好......如果你想让我再次编辑,请告诉我
谢谢,
有一个Encoding<-函数可以让您指定字符向量的编码。同一列表中的列表元素可能具有不同的编码,但字符向量中的所有元素都将具有相同的编码。此外,还有“fileEncoding”和“encoding”参数及其read.table类似read.*参数,允许您以默认值以外的方式读取字符数据。
?Encoding
?read.table
Run Code Online (Sandbox Code Playgroud)
Rhelp 档案中也有很多编码问题的解答。