[R] Vector of Numbers Not Output to Screen

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Thu Jul 17 18:31:21 CEST 2014


This question is related to FAQ 7.16, which you should look up.

In general, whenever you just type a variable or function directly at the 
command line, R prints the result for you. Inside code blocks of any kind, 
it does not do that, so you need to use the print function yourself.

On Thu, 17 Jul 2014, Dario Strbenac wrote:

> Hello,
>
> I have a block of code that has two head calls at the end, but only the second is shown on screen. If I manually execute the statement which is not showing, it works. I thought that if statements are not functions. It is behaving as one.
>
>> if(1 < 2)
> + {
> +   x<-rnorm(100)
> +   y <- rpois(10, 5)
> +   head(x)
> +   head(y)
> + }
> [1] 4 4 5 4 8 3
>>
>> head(x)
> [1] -1.89083874  0.42442102  0.96114276  0.48004716  1.94358108 -0.02654324
>
>> sessionInfo()
> R version 3.1.1 (2014-07-10)
> Platform: i386-w64-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> --------------------------------------
> Dario Strbenac
> PhD Student
> University of Sydney
> Camperdown NSW 2050
> Australia
> ______________________________________________
> 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.
>

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k



More information about the R-help mailing list