Re: [R] constrained optimization -which package?
On Tue, Sep 28, 2010 at 9:47 PM, Leonardo Monasterio leonardo.monaste...@gmail.com wrote: In the function bellow I want to find the maximum value of v, subject to the constrain that the sum of x is equal to 1. I want to maximize: v-t(x)%*%distance%*%x Subject to: sum(x)=1 Where: x is a vector n X 1 distance is a matrix n*n and it is given. (In practice, the number of n can go up to hundreds.) I have a bit of experience using R but not much on optimization techniques or on R optimization packages. I have taken a look at optim and nlminb, but I am quite confused. Do you have any suggestion on how to do it? Your optimization problem corresponds to a quadratic programming problem. So, you can use, e.g., the package quadprog. Hope this helps you, Paul __ 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.
Re: [R] efficient equivalent to read.csv / write.csv
On Tue, Sep 28, 2010 at 5:02 PM, statquant2 statqu...@gmail.com wrote: Hello all, the test I provided was just to pinpoint that for loading once a big csv A file that can be read in under 2 seconds is not big. file with read.csv was quicker than read.csv.sql... I have already optimized my calls to read.csv for my particular problem, but is a simple call to read.csv was quicker than read.csv.sql I doubt that specifying args would invert the reult a lot... May be I should outline my problem : I am working on a powerful machine with 32Go or 64Go of RAM, so loading file and keeping them in memory is not really an issue. Those files (let's say 100) are shared by many and are flat csv files (this to say that modify them is out of question). Those files have lots of rows and between 10 and 20 colums, string and numeric... I basically need to be able to load these files to quicker possible and then I will keep those data frame in memory... So : Should I write my own C++ function and call it from R ? Or is there a R way of improving drastically read.csv ? Thanks a lot So you have a bunch of small files and want to read them fast. Are they always the same or are they changing or a combination of the two? If they are the same or if many of them are the same then read those once, save() them as RData files and load() them when you want them. The load will be very fast. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] repeat a function
I have R randomly sampling my array made up of 2 columns of data. Here is my code randomly sampling 5 different rows from my dataset to create a new dataset of 8 rows of data: testdat-growth[sample(5,8,replace=T),] Now I want to tell R to repeat this function 50 times and give me the output. I have been searching the internet and have been unable to figure this out. Any advice would be greatly appreciated. Mike [[alternative HTML version deleted]] __ 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.
Re: [R] repeat a function
Hi Michael testdat - replicate( 50, growth[ sample(nrow(growth), 8, rep=TRUE) ] ) testdat will then be a matrix of 8 x 50 = 400 rows where each lot of 8 is a sample. Alternatively you can do... testdat - replicate( 50, growth[ sample(nrow(growth), 8, rep=TRUE) ], simplify=FALSE ) Now testdat will be a list of 50 elements, each of which is a sample matrix Michael On 29 September 2010 13:49, Michael Larkin mlar...@rsmas.miami.edu wrote: I have R randomly sampling my array made up of 2 columns of data. Here is my code randomly sampling 5 different rows from my dataset to create a new dataset of 8 rows of data: testdat-growth[sample(5,8,replace=T),] Now I want to tell R to repeat this function 50 times and give me the output. I have been searching the internet and have been unable to figure this out. Any advice would be greatly appreciated. Mike [[alternative HTML version deleted]] __ 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.
Re: [R] break function execution
I'm on windows xp. I use R 2.11.1 GUI - Original Message - From: Greg Snow greg.s...@imail.org To: raje...@cse.iitm.ac.in, r-help r-help@r-project.org Sent: Wed, 29 Sep 2010 00:48:51 +0530 (IST) Subject: RE: [R] break function execution Ctrl-C works on some platforms, it would help us to help you if we knew which OS you are using, which version of R you are using, and in some cases whether you are using the GUI or Terminal version of R. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of raje...@cse.iitm.ac.in Sent: Tuesday, September 28, 2010 2:13 AM To: r-help Subject: [R] break function execution Hi, I have an R function that executes for a little over a minute. When the function starts running, the R interface freezes and doesnt change until the function exits cleanly. Is there someway I can force the function to exit without messing up the interface?(An equivalent of Ctrl-C) Additionally, can I run the function in background and get a notification when it completes? [[alternative HTML version deleted]] __ 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. [[alternative HTML version deleted]] __ 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] boxplot
Hello, does somebody know in a boxplot, what does each element in the boxplot represent? 1. lines at the extremes of the dotted lines? 2. Extremes of the boxes 3. Black line in the middle of the box? 4. notches? Thank you Felipe Parra [[alternative HTML version deleted]] __ 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] String split and concatenation
Hi R users, I desire to transform the following vector consisting of repeated characters x - rep(letters, 3) into this exact format (i.e a single string containing each characters in quotation mark separated by comma between each; al ). (a, b, c, d, a, b, c, d, ..., a, b, c, d, .z) Any advice would be much appreciated. -- Steven [[alternative HTML version deleted]] __ 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.
Re: [R] String split and concatenation
Hi Steven, This should do it: paste('', unlist(strsplit(x, split=)), c(rep(',', length(x)-1), ), sep=) -Ista On Wed, Sep 29, 2010 at 1:11 AM, Steven Kang stochastick...@gmail.com wrote: Hi R users, I desire to transform the following vector consisting of repeated characters x - rep(letters, 3) into this exact format (i.e a single string containing each characters in quotation mark separated by comma between each; al ). (a, b, c, d, a, b, c, d, ..., a, b, c, d, .z) Any advice would be much appreciated. -- Steven [[alternative HTML version deleted]] __ 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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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.
Re: [R] String split and concatenation
dump(x, file = x.R) file.show(x.R) will get you most of the way. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Kang Sent: Wednesday, 29 September 2010 3:11 PM To: r-help@r-project.org Subject: [R] String split and concatenation Hi R users, I desire to transform the following vector consisting of repeated characters x - rep(letters, 3) into this exact format (i.e a single string containing each characters in quotation mark separated by comma between each; al ). (a, b, c, d, a, b, c, d, ..., a, b, c, d, .z) Any advice would be much appreciated. -- Steven [[alternative HTML version deleted]] __ 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.