[R] Arguments for functions
Spencer Graves
spencer.graves at pdf.com
Mon Sep 27 15:49:11 CEST 2004
If I understood the question correctly, you may also want to include
"scan" in the function, e.g.:
> read2 <- function(){
+ cat("Step1 input=")
+ a <- scan()
+ cat("Step2 input=")
+ b <- scan()
+ list(Step1.input=a, Step2.input=b)
+ }
> read2()
Step1 input=1: 2
2: 3
3:
Read 2 items
Step2 input=1: "a"
1: "b"
Error in scan() : "scan" expected a real, got ""a""
> read2()
Step1 input=1: 1
2: 2
3: 3
4:
Read 3 items
Step2 input=1: 2
2: 3
3: 4
4:
Read 3 items
$Step1.input
[1] 1 2 3
$Step2.input
[1] 2 3 4
hope this helps. spencer graves
Adaikalavan Ramasamy wrote:
>See "Writing your own functions" (section 10 or page 47) or the
>"Introduction to R" (http://cran.r-project.org/doc/manuals/R-intro.pdf).
>
>On Mon, 2004-09-27 at 12:44, Cornec Matthieu wrote:
>
>
>>hello,
>>
>>Could you help me to find out how to give arguments to a function step by
>>step?
>>In others words, if the output depends on inputs given by the user step by
>>step, how R can handle this?
>>Thanks in advance,
>>
>>Matthieu Cornec
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>
>>
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
--
Spencer Graves, PhD, Senior Development Engineer
O: (408)938-4420; mobile: (408)655-4567
More information about the R-help
mailing list