[R] Why x[1] is not getting substituted?

Greg Snow 538280 at gmail.com
Wed Sep 19 18:28:03 CEST 2012


I nominate Jim's answer below for the fortunes package.

On Wed, Sep 19, 2012 at 3:50 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
> Sri krishna Devarayalu Balanagu wrote:
>>
>>
>>  Suppose I want the output as "Trial and a sheet" without quotes
>>  x=c("a", "b", "c")
>>  print("Trial and x[1] sheet")
>>
>>  Getting  "Trial and x[1] sheet"
>>
>>  Can anyone help?
>
>
> And for your sins in not reading the documentation:
>
> cat(paste(rev(c("sheet",x[1],"and","Trial"))),"\n")
>
> "R helps those who help themselves"
>
> Jim
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com




More information about the R-help mailing list