On Tue, May 22, 2012 at 12:40 PM, dcoakley <danielcoakl...@gmail.com> wrote: > Thanks Michael, > > This seems to get me half-way towards a solution. However, I am still having > some difficulty in getting the out.csv exactly as I would like. I should > probably explain the issue a bit further. > > I am reading in a csv file containing a list of 'n' parameters. I have > attached a csv ( http://r.789695.n4.nabble.com/file/n4630928/read.csv > read.csv ) which contains 10 parameters as an example. However, the final > problem may have up to 2000 parameters. Currently, these have string titles > in the first column. However, I can change these to numbers if it causes > problems in R.
It looks like read.csv("http://r.789695.n4.nabble.com/file/n4630928/read.csv") works just fine for me here -- can you provide the code you're using to read things in? It might be that you need header = TRUE if you're using read.table() instead of read.csv() [The only reason I'm having you use write.table() is that write.csv() doesn't append nicely] > > As you said correctly, this will give me a data.frame with mean and sd > values. > > The problem I have is in the creation of the matrix of rnorm values. Using > the for loop specified, I am getting a single column with the rnorm values > for the last parameter specified (see attached > http://r.789695.n4.nabble.com/file/n4630928/out.csv out.csv ). Re-running > the for loop appends another column to the csv file, below the original > column. Ahh, my apologies -- you probably need to transpose your data to a row before writing: e.g., write.table(1:10, "temp.csv", sep = ",", row.names = FALSE, col.names = FALSE) read.csv("temp.csv", header = FALSE) # Gives a single column write.table(t(1:10), "temp.csv", sep = ",", row.names = FALSE, col.names = FALSE) read.csv("temp.csv", header = FALSE) # Gives a single row Best, Michael > > I have attached an example of the output I am looking for ( > http://r.789695.n4.nabble.com/file/n4630928/OutputSample.csv > OutputSample.csv ). I believe, the approach here is correct, I just need to > make a few modifications to the for loop. This also needs to be scalable to > allow for the inclusion of multiple paramters (up to 2000) and samples (up > to 1 million). I will look into the dataConnections process you mentioned to > address this task. > > Also, just in case the above attachments don't work, here is a link to the > shared files on Google Drive: > https://docs.google.com/open?id=0Bwwrh1DeZXteSFBXNVI1NGZfQjg > > Thanks again for the help. Very much appreciated. > > -- > View this message in context: > http://r.789695.n4.nabble.com/RNORM-matrix-based-on-CSV-file-values-for-MEAN-and-SD-tp4630901p4630928.html > Sent from the R help mailing list archive at Nabble.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. ______________________________________________ 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.