[R] wrong name of input file and goto like function
Bansal, Vikas
vikas.bansal at kcl.ac.uk
Sun Jul 24 16:05:39 CEST 2011
Dear all,
I have a question and need your help please.
I have the following code which is asking user to enter the name of their file.
define<- function()
{
readline("enter the name of your file: ")
}
df=read.table(define(),fill=T,sep="\t",colClasses = "character")
Now I want if user will input wrong name of file the code should not end and it should show a message-
if()
{
print("wrong name of the file Please enter again ")
}
now I want to ask what should be the condition of if so that if user will input wrong file name it will show this message and then i want to use something like goto so that it should again start with the code which is before if condition-
df=read.table(define(),fill=T,sep="\t",colClasses = "character")
so the code should be-
define<- function(x)
{
readline("enter the name of your file: ")
}
df=read.table(define(),fill=T,sep="\t",colClasses = "character") ##starline
if(## some condition here)
{
print("wrong name of the file Please enter again ")
## some goto function so that it should goto (starline)
}
Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
More information about the R-help
mailing list