Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing a list of files to XLConnect
    primarykey
    data
    text
    <p>I've written a script based on a for-loop to read in columns of multiple .xls files, combine them to a single data frame, search for negative values and write a .txt file with these values and the name of the file.<br> The script works basically, but I have several hundred files to process, and it's a bit slow. This version of the script is only a basic framework for later statistical analysis, and I want to parallelize the execution to speed it up.<br> I've tried to avoid the for-loop by applying the function via lapply and the plyr-package, but had problems passing the file list to "readWorkSheetFromFile" (Error in path.expand (filename) : invalid 'path' argument).</p> <p>Here is the working script: </p> <pre><code>require(XLConnect) setwd(choose.dir()) input = list.files(pattern = ".xls$") # creates empty data frame df = data.frame(Name=NULL, PCr=NULL, bATP=NULL, Pi=NULL) for(i in seq(along=input)){ data = data.frame(readWorksheetFromFile(input[i], sheet="Output Data", startRow=2, startCol=c(10, 13, 16), endCol=c(10, 13, 16), header=TRUE)) head(data, n = -1L) colnames(data) = c("PCr", "bATP", "Pi") data$Name = file.path(input[i]) attach(data) df = rbind(data, df) attach(df) rm(data) } # searches for negative values in df and writes to txt file neg_val = subset(df, bATP&lt;0 | Pi&lt;0 | PCr&lt;0) write.table(neg_val, file = "neg_val.txt", sep = "\t", quote=F) </code></pre> <p>Any solutions to this problem, or other suggestions to speed up execution? </p> <p>Thanks, Markus </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload