[R] interactive session

Steven McKinney smckinney at bccrc.ca
Fri Oct 1 06:21:28 CEST 2010


For those that want it all...

> {cat("?"); a<-readLines(n=1)
+ print("hey")
+ print(b<-paste("t",a,sep=""))}
?ada
[1] "hey"
[1] "tada"
> b
[1] "tada"
> 


Steven McKinney


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Peter Dalgaard
> Sent: September-30-10 1:23 PM
> To: Pam
> Cc: r-help at r-project.org
> Subject: Re: [R] interactive session
> 
> On 09/30/2010 03:33 PM, Pam wrote:
> > Thanks Niels but it won't do.. please copy and paste the 2 lines below together
> > to your console in order to see what I mean:
> >
> > cat("?"); a<-readLines(n=1)
> > b<-paste("t",a,sep="")
> >
> > anyone / any idea to overcome this problem?
> >
> > Best,
> > Fatih
> >
> 
> You might want to source() a file with those lines rather than pasting
> them to the console. There's just no way you can retroactively insert
> text between two already submitted lines.
> 
> You can do things like this, though
> 
> {cat("?"); a<-readLines(n=1)
> "hey"
>  b<-paste("t",a,sep="")}
> 
> However, there's a catch
> 
> > {cat("?"); a<-readLines(n=1)
> + "hey"
> +  b<-paste("t",a,sep="")}
> ?ada
> > b
> [1] "tada"
> 
> Notice that the "hey" doesn't print.
> 
> --
> Peter Dalgaard
> Center for Statistics, Copenhagen Business School
> Phone: (+45)38153501
> Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com
> 
> ______________________________________________
> 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.



More information about the R-help mailing list