[R] User input(unknown name and number of files)

Bansal, Vikas vikas.bansal at kcl.ac.uk
Fri Jul 22 14:27:56 CEST 2011


Dear all,

I need your help as I was not able to find out the solution.

The thing is-
I am having a code which is reading file with this code-

df=read.table("Case2.pileup",fill=T,sep="\t",colClasses="character")
 but as am making a tool so that user can use it and can do analysis on his file.But the name of the file will not be Case2.pileup and I want to use this code so that user can input as many files as he want.My code is like this-

df=read.table("Case2.pileup",fill=T,sep="\t",colClasses="character")
df$V9 <-  apply(df, 1, function(x) gsub("\\:|\\$|\\^|!|\\-|1|2|3|4|5|6|7|8|10", "",x[9]))
df$V10 <- sapply(df$V10, function(a)  
 paste(as.integer(charToRaw(a)), collapse = ' '))
capture.output(print.data.frame(df,row.names=F), file = "end.txt", append = FALSE)

I know it should do it with for loop and an array.I want that if user input 12 files,the dataframe name df should be different for all the 12 files.

Can you please tell me how can I do this.


Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London


More information about the R-help mailing list