A quick question regarding Tcl/Tk and R. Below I have a slice of code that corresponds with a Tk button that executes the ToDo<-function(){...}
.
My presumption is that both summary.myData()
and ggplot()
commands will execute. With this said, my question is whether or not I have correctly coded each command to reference the correct selected variable (the tk widget controlling this is working just fine, thus not depicted).
Namely if the arguments for each command are valid.
summary.myData<-summarySE(myData, measurevar=paste(tx.choice1), groupvars=paste(tx.choice2),conf.interval=0.95,na.rm=TRUE,.drop=FALSE)
would be read by R as
summary.myData<-summarySE(myData, measurevar=Measure, groupvars=Group,conf.interval=0.95,na.rm=TRUE,.drop=FALSE)
and
ggplot(data=summary.myData,aes(x=paste(tx.choice2),y=paste(tx.choice1)))+
geom_errorbar(aes(ymin=formula(paste(tx.choice1),"-ci"),ymax=formula(paste(tx.choice1),"+ci")), colour="black", width=.5, position=pd)+
geom_point(position=pd, size=3)+
labs(title=paste("Interval Plot of",tx.choice1,"By",tx.choice2))
will be read as
ggplot(data=summary.mydata, aes(x=Group, y=Measure))+
geom_errorbar(aes(ymin=Measure-ci, ymax=Measure+ci), colour="black", width=.5, position=pd)+
geom_point(position=pd, size=3)+
labs(title = "New plot title",x="X",y="y")
The slice for reference:
ToDo<-function(){
tx.choice1<<-vars.name.num[as.integer(tkcurselection(tl1))+1]
tx.choice2<<-vars.name.fac[as.integer(tkcurselection(tl2))+1]
numb.select.num<<-length(tx.choice1)
numb.select.fac<<-length(tx.choice2)
windows()
if (numb.select.num!=0){
if (numb.select.fac==0){
stop(tkmessageBox(message="Please select at least one categorical variable!", icon="error"))
}
else if (numb.select.fac==1) {
if(tclvalue(intervalplot_title)=="" & tclvalue(intervalplot_x)=="" & tclvalue(intervalplot_y)==""){
summary.myData<-summarySE(myData, measurevar=paste(tx.choice1), groupvars=paste(tx.choice2),conf.interval=0.95,na.rm=TRUE,.drop=FALSE)
ggplot(data=summary.myData,aes(x=paste(tx.choice2),y=paste(tx.choice1)))+
geom_errorbar(aes(ymin=formula(paste(tx.choice1),"-ci"),ymax=formula(paste(tx.choice1),"+ci")), colour="black", width=.5, position=pd)+
geom_point(position=pd, size=3)+
labs(title=paste("Interval Plot of",tx.choice1,"By",tx.choice2))
} else {
summary.myData<-summarySE(myData, measurevar=paste(tx.choice1), groupvars=c(paste(tx.choice2)),conf.interval=0.95,na.rm=TRUE,.drop=FALSE)
ggplot(data=summary.myData,aes(x=paste(tx.choice2),y=paste(tx.choice1)))+
geom_errorbar(aes(ymin=paste(tx.choice1)-ci,ymax=paste(tx.choice1)+ci), colour="black", width=.5, position=pd)+
geom_point(position=pd, size=3)+
labs(title=tclvalue(intervalplot_title),x=tclvalue(intervalplot_x),y=tclvalue(intervalplot_y))
}
tkinsert(txt,"end",paste("\nIntervalplot of", tx.choice1,"By",tx.choice2[1],"\n\n"))
}
}
geom_errorbar(aes(ymin=formula(paste(tx.choice1),"-ci"),ymax=formula(paste(tx.choice1),"+ci")), colour="black", width=.5, position=pd)+
that is not correctly fetching the values from the datasetsummary.myData