[R] Execution of larger blocks of pasted code often fails?

Pascal Oettli kridox at ymail.com
Tue May 28 09:40:24 CEST 2013


Hello,

Yes, I do. I just copy and paste smallest blocks, easiest to debug.

Regards,
Pascal


On 28/05/2013 15:54, Mark Breman wrote:
> Hello List,
>
> When i paste a large block of R code from an editor to the R command line
> the execution of the code will often fail at some point because it is not
> pasted as it was copied.
>
> ===============================================================
> Example:
>
> I copied the following block of code (as part of a larger block):
>
> ....
> s$Price <- quote(prices(St, uc=Adjusted, ent=c(Adjusted[-1], NA),
> xit=c(Adjusted[-1], NA)))
> s$PnL <- quote(pnl(Price, St))
> s$PPnL <- quote(ppnl(Price, St))
> s$RoR <- quote(ror(Price, St, delta=1/Price))
> t = na.omit(trades(rownames(s), s$Price, s$St))
> ....
>
> and when i paste this to the R command-line the following happens:
>
> ....
>> s$Price <- quote(prices(St, uc=Adjusted, ent=c(Adjusted[-1], NA),
> xit=c(Adjusted[-1], NA)))
>> s$PnL <- quote(pnl(Price,
> +
> + s$RoR <- quote(ror(Pr
> + t = na.omit(trade
> Error: unexpected symbol in:
> "s$RoR <- quote(ror(Pr
> t"
> ....
> =================================================================
>
> As you can see from the example it looks like the code was not pasted
> correctly.
> If i execute the same block of code with the source() command it runs just
> fine!
>
> Here is the output of my sessionInfo():
>
>> sessionInfo()
> R version 2.15.3 (2013-03-01)
> Platform: i486-pc-linux-gnu (32-bit)
>
> locale:
>   [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
> LC_TIME=nl_NL.UTF-8        LC_COLLATE=en_US.UTF-8
> LC_MONETARY=nl_NL.UTF-8
>   [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=C                 LC_NAME=C
>             LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
>   [1] DEoptim_2.2-1              IBrokers_0.9-10            stringr_0.6.2
>             timeDate_2160.97           PerformanceAnalytics_1.1.0
>   [6] tradesys_0.1               RUnit_0.4.26               quantmod_0.4-0
>            TTR_0.22-0                 xts_0.9-3
> [11] zoo_1.7-9                  Defaults_1.1-1
>
> loaded via a namespace (and not attached):
> [1] grid_2.15.3     lattice_0.20-15 tcltk_2.15.3    tools_2.15.3
>
>
> Is there anyone who experiences the same problem?
>
> Kind regards,
>
> -Mark-
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list