[R] RStudio 1.1.453 - Windows 10 - How to see detailed results of every calculation step
Michael Dewey
||@t@ @end|ng |rom dewey@myzen@co@uk
Fri Jul 27 18:12:30 CEST 2018
Dear Ibrauheem
First try
length(56)
then try
rnorm()
using the value you got in stage 1
Michael
On 27/07/2018 16:07, إبراهيم خطاب Ibrauheem Khat'taub wrote:
> Hi everyone,
>
> I am taking my first R course. This was my first example.
>
> When I executed:
>
> AddLengthNoise <- function(x) {x + rnorm(length(x))}
>
> using 56 as the value of x, I expected the result to be two values,
> something like:
>
> [1] 56.17491697 56.02935105
>
> because I expected rnorm to return two values and then 56 to be added to
> each of them. Instead, I got one value, something like:
>
> [1] 56.17491697
>
> So I wondered how this happened and wanted to see what happens behind the
> scene. Coming from the Excel paradigm, I wondered, "Is there something like
> 'show calculation steps' in R?" So I Googled it, and got nothing related
> but this
> <https://support.rstudio.com/hc/en-us/articles/205612627-Debugging-with-RStudio>.
> So, I tried breaking my code into separate lines and toggling breakpoints
> at all lines, as follows:
>
> 6| AddLengthNoise <- function(x) {
>
> - 7| x +
> - 8| rnorm(
> - 9| length(
> - 10| x)
> - 11| )
> - 12| }
>
> (Where the bullet points above represent the red debugging checkpoints)
>
> Then I tried again:
>
> AddLengthNoise(56)
>
> and as I executed step by step, I could not see what I expected. I couldn't
> see each step's result, and I did not understand what I saw neither in the
> console nor in the "Traceback" window that appeared.
>
> My 2 questions:
>
> 1. Did I do something wrong?
> 2. Is there a way to see, like in Excel's "Show calculation steps", the
> result of each step alone (i.e. length(56)=2 ==> rnorm(2)={0.17491697;
> 0.02935105} ==> 56 + {0.17491697; 0.02935105}= ... and so on)?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
--
Michael
http://www.dewey.myzen.co.uk/home.html
More information about the R-help
mailing list