I've been dealing with user input for various graphs. My main aim was to ask the user for an input and then parse this to a plotting function. I managed to do this for scatterplot, but not boxplot and barplot. This is my working example:
n<- function(){
readline(prompt="enter x value to plot: ")
}
m<- function(){
readline(prompt="enter y value to plot: ")
}
plotfun <- function(dat) {
colx <- n()
coly <- m()
plot(dat[,colx], dat[,coly], main="Scatterplot", pch=20,xlab=[,colx] )
}
But when I try something similar with boxplot for example:
plot2<-function(infile){
a<-readline(prompt="which variable")
barplot(table(infile$a))
}
or
a<-readline(prompt="enter...")
Boxplot( ~ a, data=infile, id.method="y")
It doesn't work
Errors were something like: can't find the object, argument "infile" is missing, with no default.
Boxplotfunction come from?