[R] Readline

Jim Lemon
Mon, 18 Jun 2007 11:43:23 -0000

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