[R] Vector of Numbers Not Output to Screen

Rui Barradas ruipbarradas at sapo.pt
Thu Jul 17 18:27:56 CEST 2014


Hello,

Also, unlike what the op says, if statements are functions, explaining 
the behavior he got.

Hope this helps,

Rui Barradas

Em 17-07-2014 16:53, Sarah Goslee escreveu:
> Hi,
>
> You can get the behaviour you want using the print() command:
>
> if(1 < 2)
> {
>    x<-rnorm(100)
>    y <- rpois(10, 5)
>    print(head(x))
>    print(head(y))
> }
>
>
> Sarah
>
> On Thu, Jul 17, 2014 at 2:00 AM, Dario Strbenac
> <dstr7320 at uni.sydney.edu.au> 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
>>
>



More information about the R-help mailing list