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()
+ }

______________________________________________
R-help@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.

Reply via email to