【问题标题】:How to insert variables in R twitteR updates?如何在 R 推特更新中插入变量?
【发布时间】:2011-02-09 18:26:32
【问题描述】:

我正在使用 R 中的 twitteR 包来使用分析结果更新我的 Twitter 状态。静态推文功能有效:

library(twitteR)

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

tweet = tweet('I am a tweet', sess)

但是,当我添加一个变量来显示某些特定结果时,我得到了一个错误。

library(twitteR)

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

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

tweet = tweet(msg, sess)

结果:

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

感谢任何建议。

【问题讨论】:

    标签: r twitter


    【解决方案1】:

    这是我在运行您的代码时得到的结果:

    > 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
    

    问题在于cat 将字符串打印到标准输出,而不是将它们作为字符串返回。你想要的是:

    > 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?"
    

    【讨论】:

      猜你喜欢
      • 2022-12-21
      • 1970-01-01
      • 1970-01-01
      • 2019-10-03
      • 1970-01-01
      • 1970-01-01
      • 2016-05-02
      • 2015-11-08
      • 1970-01-01
      相关资源
      最近更新 更多