Yes. I'm just for killing time in the rainy weekend. Now I'm using readLines() to read the file and then output the data as a list.
google.read.list <- function(filename){ temp <- readLines(filename) out <- NULL tt <- NULL for(i in 1:length(temp)){ strin <- as.numeric(strsplit(temp[i]," ")[[1]]) if(length(strin)==3){ tt <- rbind(tt,strin) }else{ if(!is.null(tt)){ out <- c(out,list(tt)) } tt <- NULL } } return(out) } On Sat, Nov 29, 2008 at 8:13 PM, David Winsemius <[EMAIL PROTECTED]> wrote: > Have you looked at the documentation and help files for R Import/Export; > > http://cran.r-project.org/doc/manuals/R-data.pdf > > and the read functions > > ?read.table > ?readLines > ?count.fields > > This is pretty basic stuff. After an extremely cursory look at that problem > I was guessing that it is more like linear programming than statistics. > > -- > David Winsemius > > > On Nov 29, 2008, at 6:51 PM, Hesen Peng wrote: > >> Dear R buddies, >> >> This weekend I became interested in solving Google Code Jam problems >> using R. I guess R may work very well in this kind of contests but the >> input of file has been a problem for me. Take this case for example >> >> (http://code.google.com/codejam/contest/dashboard?c=agdjb2RlamFtchALEghjb250ZXN0cxjRzBQM), >> the files are usually of the form: >> >> A(number of lines for group 1) >> a11 a12 a13 >> a21 a22 a23 >> ... >> B(number of lines for group 2) >> b11 b12 b13 >> b21 b22 b23 >> ... >> >> I guess SAS may work pretty well in this kind of situation with data >> step. But I don't know how to handle them using R. Any suggestions? >> Thanks a lot. >> >> Best wishes, >> -- >> 彭河森 Hesen Peng >> http://hesen.peng.googlepages.com/ >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > -- 彭河森 Hesen Peng http://hesen.peng.googlepages.com/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.