Re: [R] continuation lines in R script files

From: Mike Meyer <mikem_at_salter-point.com>
Date: Wed 06 Sep 2006 - 20:24:58 GMT

I literally copy/pasted your second version (without the + signs) in a file and the "source"d that file. It loaded without error and the "a" matrix was as I expected.

On 9/6/06, Evan Cooch <cooch17@verizon.net> wrote:
>
> When I have to enter a very large matrix into the R console, I can make
> use of the continuation feature in the console to enter the matrix in
> pieces (e.g., on a row by row basis). So, for example, the console
> would show the "+" sign for continuation lines - something like what
> I've written below:
>
> a=matrix(c(0,20,50,
> + 0.05,0,0,
> + 0,0.1,0),
> + 3,3,byrow=T)
>
> (obviously, for a matrix this small - 3x3 - I could enter it all on a
> single line, this is just to demonstrate)
>
> My question is - how do you accomplish the same thing in an R script
> file? I've tried literally copying the preceding - syntax error at the
> second line. I've also tried
>
>
> a=matrix(c(0,20,50,
> 0.05,0,0,
> 0,0.1,0),
> 3,3,byrow=T)
>
> Again, syntax error, at the second line...
>
> After multiple searches for 'continuation line', with no luck
> (everything I found refers to the R console, no a script file), I'll ask
> here. Basically, I want to know how to get an R script to handle a
> structure entered over multiple lines (e.g., a matrix). This is default
> behaviour in .m files in Matlab, and most other environments I've ever
> worked in (e.g., SAS looks for the ; to indicate end of a line).
>
> Thanks in advance...
>
> ______________________________________________
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.
>
>

-- 

Mike Meyer, Seattle WA

	[[alternative HTML version deleted]]

______________________________________________
R-help@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
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Sep 07 09:48:30 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 07 Sep 2006 - 07:51:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.