Chỉ cần tự hỏi, liệu có cách nào để thay đổi mã hóa ký tự của đối tượng danh sách R không? Tôi có cảm giác rằng tôi sẽ phải thực hiện nhiều bước nhưng tôi không chắc chắn. Tôi đã googled về chủ đề này nhưng tôi không nhận được sự giúp đỡ từ internet.R: cách thay đổi mã hóa ký tự của đối tượng danh sách
ví dụ, hãy xem xét những điều sau đây:
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)
lệnh
followers.object<-lookupUsers(start$getFollowerIDs(), includeNA=TRUE)
ném các lỗi sau:
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()).
Làm thế nào tôi có thể cho phép R để bảo vệ các nhân vật đặc biệt khi làm việc với twitter? hy vọng tôi sửa nó độc đáo ... cho tôi biết nếu bạn muốn tôi để chỉnh sửa nó một lần nữa
cảm ơn bạn,
Bạn có thể giải thích thêm một chút câu hỏi của mình bằng cách cung cấp [ví dụ tái sản xuất] (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) và hiển thị những gì bạn mong đợi? –
Không. Bạn cần đưa ra một ví dụ tốt hơn cho thấy * cách * bạn lấy dữ liệu vào R ở vị trí đầu tiên, vì R sẽ mặc định chuyển đổi các ký tự không phải ascii thành UTF-8 (hoặc có lẽ là "Không xác định")). Ví dụ, kiểm tra 'Encoding (" £ ")', cung cấp cho '[1]" UTF-8 "'. –
có tốt không? Tôi thực sự không thể thêm dữ liệu thực vì dữ liệu thô của tôi nằm trong tệp .csv –