You need to use the tclvalue
function to get an R character string representation of a Tcl variable. Modify your function as follows:
readCsv <- function(){
myval <- tclvalue(tkgetOpenFile()) # add `tclvalue` here
mydata <- read.csv(myval) # then `myval` is a character string
assign("myData", mydata, envir = .GlobalEnv)
}