开发者

How to insert variables in R twitteR updates?

I am using the twitteR package in R to update my twitter status with results from analysis. The static tweet function works:

library(twitteR)

sess = initSession('username','password')
开发者_如何学JAVA
tweet = tweet('I am a tweet', sess)

However, when I add a variable to display some specific results I get an error.

library(twitteR)

sess = initSession('username','password')

res = c(3,5,8)
msg = cat('Results are: ', res, ', that is nice right?')

tweet = tweet(msg, sess)

Results in:

Error in twFromJSON(rawToChar(out)) : 
  Error: Client must provide a 'status' parameter with a value.

Any suggestions are appreciated.


Here's what I get when I run bits of your code:

> res = c(3,5,8)
> msg = cat('Results are: ', res, ', that is nice right?')
Results are:  3 5 8 , that is nice right?> 
> msg
NULL

The problem is that cat prints strings to stdout, rather than returning them as a string. What you want is:

> res = c(3,5,8)
> msg = paste('Results are: ', toString(res), ', that is nice right?', sep='')
> msg
[1] "Results are: 3, 5, 8, that is nice right?"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜