に感謝:
eventsDescriptions <- c("come out and enjoy %s at the park", "its a great day to play %s at the park", "perfect day for a game of %s at the park")
> df <- data.frame(title = c("basketball","soccer","football","rugby","tennis"))
> df
title
1 basketball
2 soccer
3 football
4 rugby
5 tennis
> df$description <- sprintf(sample(events,size=nrow(df), replace = TRUE), df$title)
> df
title description
1 basketball come out and enjoy basketball at the park
2 soccer its a great day to play soccer at the park
3 football its a great day to play football at the park
4 rugby come out and enjoy rugby at the park
5 tennis come out and enjoy tennis at the park
あなたはそれがコメントの一つに言及したの当時のように、無作為に選んだイベントの説明をしたくない場合は:
df$description <- sprintf("come out and enjoy %s at the park", df$title)
'?paste'、'?sprintf'を探していますか? - sprintfのように( "出て公園で%sを楽しんでください!"、C( "サッカー"、 "バスケットボール")) –
本当にありがとう! –
また、[ここ](http://stackoverflow.com/questions/10341114/alternative-function-to-paste)および[ここ](http://stackoverflow.com/questions/7201341/how-can- 2-strings-concatenated-in-r) –