/ / Ako vložiť premenné do aktualizácií R twitteR? - r, twitter

Ako vložiť premenné do aktualizácií R twitteR? - r, twitter

Používam balík twitteR v R na aktualizáciu môjho stavu twitteru výsledkami analýzy. Funkcia statického tweetu funguje:

library(twitteR)

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

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

Keď však pridám premennú na zobrazenie niektorých konkrétnych výsledkov, zobrazí sa chyba.

library(twitteR)

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

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

tweet = tweet(msg, sess)

Výsledky v:

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

Akékoľvek návrhy sú cenené.

odpovede:

3 pre odpoveď č. 1

Dostávam nasledovné, keď spustím bity vášho kódu:

> 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

Problém je, že cat vypíše reťazce na štandardný výstup, a nie ich vracať ako reťazec. To, čo chcete, je:

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