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

Jim Lemon jim at bitwrit.com.au
Wed Sep 19 11:50:41 CEST 2012


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




More information about the R-help mailing list