[R] Why this statement does not print anything in an if-statement that includes 'q()'?
Peng Yu
pengyu.ut at gmail.com
Mon Sep 7 03:13:49 CEST 2009
Hi,
I run the following script. I don't understand why the second
'length(args)' does not show anything but the first one shows '0'. Is
it because the command 'q()' affects anything in the if-statement.
However, if I change the second 'length(args)' to
'print(length(args))', the script will print the length of 'args'. Can
somebody let me know what is the difference between the 'print(x)'
statement and the 'x' statement where 'x' is a variable?
Regards,
Peng
$ Rscript not_print_in_if_block.R
> args=commandArgs(T)
> length(args)
[1] 0
>
> if(length(args)!=3){
+ length(args)
+ q()
+ }
More information about the R-help
mailing list