[R] how to type long string

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sat Jul 14 21:42:42 CEST 2001


Guoqiang Wang <guo52717 at yahoo.com> writes:

> Hi, All:
> 
> I try to type some long string in R console, whenever
> I like to change to a new line, I get error message.
> 
> The following is my simple code
> --------------------------------------
> h3 <- sqlQuery(myConnect, "select * from console where
> 
> Error: syntax error
> byday = 'dd1'group by by hour") 
> Error: syntax error
> 
> ---------------------------------------
> 
> Any Hints?

You just can't do that... If SQL allows newlines in expressions, you
could do

h3 <- sqlQuery(myConnect, "select * from console where \
 byday = 'dd1' group by hour")

(Since 
> x <- "a\    
+ n"
> x
[1] "a\nn"
)

Otherwise you need an explicit paste(), as in

querystr <- paste("select * from console where",
                  "byday = 'dd1' group by hour")
h3 <- sqlQuery(myConnect, querystr)


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list