[R] Sweave and long strings
Laurent Rhelp
laurentRhelp at free.fr
Mon Mar 6 20:25:55 CET 2006
Roger Bivand a écrit :
>On Sun, 5 Mar 2006, Laurent Rhelp wrote:
>
>
>
>>Dear R-List,
>>
>> I use Sweave (which is wonderful) and I have a problem with the
>>strings when they are too long according to the width of the page. For
>>example when I do in my .Rnw document :
>>
>><<UsingRODBC,echo=TRUE>>=
>>
>>channel <- odbcConnect(dsn="database",uid="root",pwd="password")
>>df1 <- sqlFetch(channel,"table1",rownames=TRUE)
>>df2 <- sqlFetch(channel,"table2",rownames=TRUE)
>>
>>cmd <- "SELECT t1.isoisotope,
>> t1.periode,t1.nbZ,
>> t2.filnomchaineradio,
>> t2.filcodepere,
>> t2.filcodefils,
>> t2.filproba,
>> t2.filtransition from table1 t1,
>> table2 t2
>> WHERE t1.isoisotope = t2.filcodepere"
>>
>>dfQuery <- sqlQuery(channel, cmd )
>>odbcCloseAll()
>>
>>@
>>
>>etc...
>>
>>in the pdf document the command
>>cmd <- "SELECT t1.isoisotope, t1.periode,t1.nbZ,
>>t2.filnomchaineradio, t2.filcodepere, t2.filcodefils,
>>is written truncated only on one line not as it is written in the chunk
>>above.
>>
>>I read in the R-archives we have to use the options command but even
>>using options(width=30) in the chunk it doesn't work.
>>
>>
>
>This is because it is a single string. Could you also say:
>
>cmd <- paste("SELECT t1.isoisotope,",
> "t1.periode,t1.nbZ,",
> "t2.filnomchaineradio,",
> "t2.filcodepere,",
> "t2.filcodefils,",
> "t2.filproba,",
> "t2.filtransition from table1 t1,",
> "table2 t2",
> "WHERE t1.isoisotope = t2.filcodepere")
>
>or an equivalent with the included white space and line breaks? It will be
>parsed anyway inside Sweave, so at least using paste() should prevent it
>overrunning the right margin.
>
>
>
>>May you help me ?
>>
>>Thanks
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>
>>
>
>
>
It is less readable but it is a very good idea !
thank you very much
More information about the R-help
mailing list