[R] raw input prompt

David Winsemius dwinsemius at comcast.net
Sat Jun 2 16:59:39 CEST 2012


On Jun 1, 2012, at 2:01 PM, meatloafthefrog wrote:

> 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?

?assign
>

assign(filename, read.table(file=filename, header = TRUE,  
stringsAsFactors =
  FALSE, sep = ","))

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list