[R] Readline

Jim Lemon jim at bitwrit.com.au
Mon Jun 18 13:43:23 CEST 2007


Antje wrote:
> Hello,
> 
> I also have problems to get to run the following lines. If I run the
> block instead of every single line, it simply does not wait for the input.
> Can anybody help me?
> 
> ------------------------
> pos_name <- readline("Please type: ")
> 
> r <- substr(pos_name, 1,1)
> c <- substr(pos_name, 2,nchar(pos_name))
> 
> ------------------------
> 
Hi Antje,
What you seem to be doing is pasting the lines into the R window. The 
second line looks like the input line that the first line is expecting, 
and if you remove the empty line, you will see that pos_name has been 
assigned the text of the second line.

If you put these lines into a text file and then use "source" to read 
it, it works as I think you expect.

Jim



More information about the R-help mailing list