I defined a R function, and want this function to return 2 dataframes, so I can use this dataframe outside the R function. However, if fails to return the two data frames, but it can print out the data frame in R.
Here are my code,
useDataFrame <- function(tab1,tab2){
d6 <- read.table(paste0("/Users/limin/Desktop/cnr_cns/", tab1) , header = T)
seg <- read.table(paste0("/Users/limin/Desktop/cnr_cns/", tab2) , header = T)
return(d6)
return(seg)
}
useDataFrame("A01.cnr","A02.cns")
df1 <- d6
df2 <- seg
Could anyone suggests what part of my code went wrong? How do I modify the code, so I can use the dataframe returned by R function?
Your helps are greatly appriciated.
Best,