Scan to read input with R

Hi all,
I use R but I don’t manage to use correctly the scan function to read the input. It always says “read 0 items”… I think I also tried readline but it was the same.
Can someone help? (even if there are few R-users over there)
I am sure my code is correct except it can’t read the input, so that I have a time limit exceed or a wrong answer…
Thank you!

Hi alexia_fr, scan and readline functions can only be used in interactive mode. Most of the online compilers doesn’t support interactive mode. To read the input in non-interactive mode, you need to use readLines method as follows:
input1 ← readLines(“stdin”, n=1);
where n denotes the number of lines you want to read.

You can read the documentation of readLines() method to understand how you can use it for your use cases. Here is the link: readLines function | R Documentation

1 Like