Just for the record, following Bill Dunlap's advice, I think this is
the best answer to the question as originally posed is.


myfun <- function(vec, i=stop("'i' must be supplied")){
vec[i]
}

> myfun(1:40,10)
[1] 10
> myfun(1:10)
Error in myfun(1:10) : 'i' must be supplied
>

-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

______________________________________________
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