我創建了這個函式來打開一個檔案R:
openfasta<-function(DNAseq){
DNASeq <- readline(prompt = "Enter the .fasta file name:")
readLines(DNASeq)
現在,如果在作業目錄中找不到該檔案,則腳本必須輸出警告訊息并重復詢問檔案名,直到找到該檔案。
我試過這個,但沒有用:
if (DNASeq) {
return()
}
else {
cat(DNASeq <- readline(prompt = "Enter the .fasta file name:"))
}
}
我認為 For 回圈是否也是一個合理的解決方案。
uj5u.com熱心網友回復:
您可以使用while回圈來檢查檔案是否存在。如果未找到,請使用print陳述句顯示警告并再次提示。
openfasta <- function(DNAseq){
while(!file.exists(DNAseq)){
print("The file you requested was not found.")
DNASeq <- readline(prompt = "Enter the .fasta file name:")
}
readLines(DNASeq)
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/318454.html
