Say, I have data frame which I need to save with different suffix, given a value for the suffix variable or not. The suffix here is keyvalue
which is of type character and I assigned a value to it.
keyvalue ="_TRP-1"
outdir= "/user/path/results"
sample= "ADAS"
And I need to write my output
to the outdir using an if loop
with the condition if keyvalue
is not equal to na
or else
This is what I tried,
if (!is.na(keyvalue)){
write.table(output, paste(outdir, sample, keyvalue,"_scores.tsv", sep=""), sep="\t", row.names=F, quote=F)
}else{
write.table(formatted_res_table_non_new, paste(outdir, sample_id,"_scores.tsv", sep=""), sep="\t", row.names=F, quote=F)
}
In the end, I want to have a data table/ file named, ADAS_TRP-1_scores.tsv
given a keyvalue
otherwise a file named, ADAS_scores.tsv
. However, the above lines are not generating any tables as well as error messages, any suggestions are appreciated. Thanks
Aucun commentaire:
Enregistrer un commentaire