[R] pattern
Schmitt, Corinna
Corinna.Schmitt at igb.fraunhofer.de
Thu Apr 12 15:59:51 CEST 2007
Dear R-experts,
I have the following function:
userInput <- function() {
ANSWER <- readline("saving place of the data (example
Z:/Software/test.mat)? ")
x = c(".mat")
endingTest = x %in% ANSWER
print (endingTest)
if (endingTest == "??")
cat ("saving place not accepted\n")
else
cat("Thank you! The current workspace will be stored in:
",ANSWER,"\n\n")
print(ANSWER )
}
filename = userInput()
Before I enter the if loop I must test if the text stored in ANSWER has
the pattern ".mat". If yes than endingTest = TRUE else endingTest =
FALSE.
Another problem is the last codeline. Later on in my program I need the
userinput to ad it to another variable. How can I manage this. I get the
following error message:
saving place of the data (example Z:/Software/test.mat)? Z:/data.mat
[1] FALSE
Thank you! The current workspace will be stored in: Z:/data.mat
[1] "Z:/data.mat"
Error in as.vector(x, mode) : cannot change into vector
Thanks, Corinna
More information about the R-help
mailing list