Hello, I'm using ROCR to plot ROC Curves and I want to automate the saving of plots into PNG files using a custom function.
My data frames are named like test1, test2, test3. Each data frame has three variables: method1, method2, goldstandard. Right now, for each plot I have to run: png('test1_method1.png') plot(performance(prediction(test1$method1, test1$goldstandard), "tpr", "fpr")) dev.off() Here is the function I tried to create but I failed: roc <- function(arg1, arg2){ png(paste(arg1, arg2, "png", sep="_")) plot(performance(prediction(arg1$arg2, arg1$goldstandard), "tpr", "fpr")) dev.off() } I wanted to pass the test name as arg1, and the method name as arg2. Here are my problems: 1) arg1$arg2 causes an error message. How can I use a function argument to address a variable in a dataframe? 2) paste(arg1, arg2, "png", sep=".") doesn't output something like 'test1.method1.png'. How should I deal with that? Thanks in advance. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.