r - Repeating tk_choose.files to import multiple .csv files multiple times -


i using sapply(tk_choose.files) produce interactive window can choose .csv files (multiple) import. basic data manipulation mean of 1 particular column can plotted using ggplot.

so far code looks this:

>tfiles <- data.frame(sapply(sapply(tk_choose.files(caption="choose t files (hold ctrl select multiple files)"), read.table, header=true, sep=","), c))  >rfiles <- data.frame(sapply(sapply(tk_choose.files(caption="choose r files  (hold ctrl select multiple files)"), read.table, header=true, sep=","), c)) 

i have calculated mean of particular column both tfiles , rfiles plot 100-tfiles-rfiles.

while working fine 1 set of data, import more sets of data, preferably using sapply(tk_choose.files). need t/rfiles1, t/rfiles2...and repeat data manipulation process after that, plot of multiple sets of data. have no idea how without having copy , paste code!

sorry if stupid question, new r stuck, appreciated!

assuming files in working directory follow:

all.files<-list.files(pattern="\\.csv")  all.files [1] "r01.csv" "r02.csv"  "r03.csv"  "r04.csv" "t01.csv" "t02.csv"  "t03.csv"  "t04.csv" 

and wish call tfiles1 merged data of t01 , t02; tfiles2 merged data of t03 , t04

t <- grep("t", all.files, value=t)  t [1] "t01.csv" "t02.csv"  "t03.csv"  "t04.csv"  t.list <- list(t[1:2], t[3:4])  all.t <- lapply(t.list, function(x)ldply(x, read.csv))  (i in 1:length(all.t)) assign(paste0("tfiles", i), all.t[[i]]) #this produce tfiles1 , tfiles2 in r environment. 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -