[R] interactive session

jim holtman jholtman at gmail.com
Thu Sep 30 22:41:01 CEST 2010


You might want to use the tcltk package so you can bring up a window
in which to input your data.  This is better than trying to read from
the console especially when 'sourcing' in some files or when
cutting/pasting.

On Thu, Sep 30, 2010 at 2:55 AM, Pam <fkiraz11 at yahoo.com> wrote:
> Hi guys,
>
> My concern is to create an automated process from the beginning to the end. I
> want to copy all my code together in one piece and paste it to R console and sit
> back and relax :) except one moment in which the program should ask me to enter
> a number.. and only then (only after getting a valid number from me) it should
> continue to read and process the rest of the code. I tried lots of things
> (readline, readLines, scan, interactive, ask, switch,...) and read manuals and
> searched help forums.. I found several similar questions but never a satisfying
> answer.. so now it became a challenge.. any idea how to overcome this problem (R
> 2.11.1 for Windows)? (an example code is below)
>
> Best,
> Fatih
>
>
>
> library(gtools)
> library(YaleToolkit)
> library(xts)
>
> ### start of my wrong function!
> f<-function(w){
>  w<-readline("which data? ")
>  w<-as.numeric(w)
>  ifelse(is.numeric(w)=="TRUE", w, f())
>  }
> f()
> ##### end of my wrong function
>
> v<- ## and output of my function should be a "v" for example which I can use it
> in the next line (v<-w  or something like that??)
>
> ##the rest works fine
> p<-paste("t", v, ".txt", sep = "")
> t<-read.table(p, header=FALSE, sep="\t", dec=",",
> blank.lines.skip=FALSE)
> rownames(t)<-as.Date(t[,1],"%d.%m.%Y")
> colnames(t)<-c("date","start","high","low","end","w.average","lot",
> "volume")
> x<-as.xts(t)
> whatis(x)
> .
> .
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list