Re: [R] Help In Function

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 12 May 2006 - 16:46:45 EST

On Fri, 12 May 2006, SUMANTA BASAK wrote:

> I need a basic help from you. I've built a function like this,
>
> windowlength<-function(x)
> {
> z <- rep(seq(0,331,by=x-1)+1, each=2)
> zz <- z[-c(1,length(z))]
> ind <- as.data.frame(matrix(zz, nr=2))
> j<-lapply(ind, function(x) mat[x[1]:x[2],])
> cat("For",x/4,"month number of windows is = ",length(ind),"\n")
> }
> windowlength(x=12)
>
> I need to know how can i give command in "R" so that instead of giving the last line, i.e "R" will ask the user to give the value of x? I mean to say,
> 1) It will ask user "Give the value of x"
> 2) Then user inputs 12, and R gives the ultimate result.

as.numeric(readline("Give the value of x: "))

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@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
Received on Fri May 12 16:57:08 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 12 May 2006 - 18:10:06 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.