Hello, I was wondering if there is a way to make a prompt for the user (exactly like raw_input() in Python), the response to which can then be used as an object. Thanks, Abir -- View this message in context: http://r.789695.n4.nabble.com/raw-input-prompt-tp4631852.html Sent from the R help mailing list archive at Nabble.com.
Perhaps readline()? Best, Michael On Wed, May 30, 2012 at 2:31 PM, meatloafthefrog <meatloafthefrog at gmail.com> wrote:> Hello, > > I was wondering if there is a way to make a prompt for the user (exactly > like raw_input() in Python), the response to which can then be used as an > object. > > Thanks, > > Abir > > -- > View this message in context: http://r.789695.n4.nabble.com/raw-input-prompt-tp4631852.html > Sent from the R help mailing list archive at Nabble.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.
On May 30, 2012, at 4:38 PM, R. Michael Weylandt wrote:> Perhaps readline()?Or possibly ( depending on what exactly the undescribed Python function does) ... x <- scan() # defaults to numeric but can be used for character input with correct parameters> > Best, > Michael > > On Wed, May 30, 2012 at 2:31 PM, meatloafthefrog > <meatloafthefrog at gmail.com> wrote: >> Hello, >> >> I was wondering if there is a way to make a prompt for the user >> (exactly >> like raw_input() in Python), the response to which can then be used >> as an >> object. >> >> Thanks, >> >> Abir >> >> -- >> View this message in context: http://r.789695.n4.nabble.com/raw-input-prompt-tp4631852.html >> Sent from the R help mailing list archive at Nabble.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. > > ______________________________________________ > 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.David Winsemius, MD West Hartford, CT
Ah. I'm very new to this and I definitely wasn't clear enough about what I'm trying to do... sorry. I am extracting information (in this case, DNA sequences to be exported to a fasta file) from just two columns of a table that has a lot of extraneous... stuff. I want a prompt that asks the user for the file name of the table, the response to which will be the name of the table in R. So I did something like: file_name = function() #This function, when called up, prompts the user to enter the file name. { readline("Enter name of csv file: ") } filename = file_name() Table_1 = read.table(print(filename), header = TRUE, stringsAsFactors FALSE, sep = ",") #Reads in the csv table but this just 'hard codes' the name of the table to be "Table_1." Is there a way to use the user input as the name of the table? Thank you -- View this message in context: http://r.789695.n4.nabble.com/raw-input-prompt-tp4631852p4632110.html Sent from the R help mailing list archive at Nabble.com.