Dear R-list members, I have a matrix with non-numeric variables in it and I have to optimize the variables of the matrix in a formula using optim routine of the stats4 package. I know the matrix can only take numeric data and so I would like to know how to store non-numeric variables inside a matrix. Say for example: The 3X3 matrix is 0.05V1+V2 0.31V1 0.05V1 0.31V1 0.3V1+V2 0.5V1 0.05V1 0.5V1 0.1V1+V2 The matrix is only for an example and the real matrix that I want to use is a 15X15 matrix ,here I would like to optimize the values of V1 and V2 using a formula. Could you please help me how to go about to represent the matrix in R. Thanks in advance! B.Nataraj
Optimizing variables represented in a matrix
4 messages · nataraj at orchidpharma.com, David Winsemius, Kjetil Halvorsen +1 more
On May 31, 2012, at 7:37 AM, <nataraj at orchidpharma.com> <nataraj at orchidpharma.com
> wrote:
Dear R-list members, I have a matrix with non-numeric variables in it and I have to optimize the variables of the matrix in a formula using optim routine of the stats4 package. I know the matrix can only take numeric data
Some of the things you think you know, are not so:
> exvec <- c('0.05V1+V2', '0.31V1', '0.05V1', '0.31V1', '0.3V1+V2',
'0.5V1', '0.05V1', '0.5V1', '0.1V1+V2')
> matrix(exvec, 3,3)
[,1] [,2] [,3]
[1,] "0.05V1+V2" "0.31V1" "0.05V1"
[2,] "0.31V1" "0.3V1+V2" "0.5V1"
[3,] "0.05V1" "0.5V1" "0.1V1+V2"
and so I would like to know how to store non-numeric variables inside a matrix. Say for example: The 3X3 matrix is 0.05V1+V2 0.31V1 0.05V1 0.31V1 0.3V1+V2 0.5V1 0.05V1 0.5V1 0.1V1+V2 The matrix is only for an example and the real matrix that I want to use is a 15X15 matrix ,here I would like to optimize the values of V1 and V2 using a formula.
Whether that plan makes sense seems problematic, but that wasn't your question.
Could you please help me how to go about to represent the matrix in R.
I'm guessing you have thoughts of evaluating these expressions. They are not valid R expressions, however. You have some further study to do.
David Winsemius, MD West Hartford, CT
If you want an helpful answer, you must describe your real problem MUCH better! This is way too confused. Kjetil
On Thu, May 31, 2012 at 7:37 AM, <nataraj at orchidpharma.com> wrote:
Dear R-list members, I have a matrix with non-numeric variables in it and I have to optimize the variables of the matrix in a formula using optim routine of the stats4 package. I know the matrix can only take numeric data and so I would like to ?know how to store non-numeric variables inside a matrix. Say for example: The 3X3 matrix is ? ? 0.05V1+V2 ? ?0.31V1 ? ? ? ?0.05V1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.31V1 ? ? ? 0.3V1+V2 ? ? ?0.5V1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.05V1 ? ? ? 0.5V1 ? ? ? ? 0.1V1+V2 The matrix is only for an example and the real matrix that I want to use is a 15X15 matrix ,here I would like to optimize the values of V1 and V2 using a formula. Could you please help me how to go about to represent the matrix in R. Thanks in advance! B.Nataraj
______________________________________________ R-help at 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.
Inline ... On Thu, May 31, 2012 at 9:09 AM, Kjetil Halvorsen
<kjetilbrinchmannhalvorsen at gmail.com> wrote:
If you want an helpful answer, you must describe your real problem MUCH ? ?better! This is way too confused.
Absolutely! -- But we certainly can say:
Kjetil On Thu, May 31, 2012 at 7:37 AM, ?<nataraj at orchidpharma.com> wrote:
Dear R-list members, I have a matrix with non-numeric variables in it and I have to optimize the variables of the matrix in a formula using optim routine of the stats4 package. I know the matrix can only take numeric data
-- This statement is false. A matrix can contain data of only one type -- no mixing -- but the type can be non-numeric, character for instance. However, as Kjetil said, your post is basically incoherent, so it is unlikely that you'll get any help here unless you post something that makes some sense. -- Bert -- Bert and so I would like to ?know how to store non-numeric variables inside a matrix.
Say for example: The 3X3 matrix is ? ? 0.05V1+V2 ? ?0.31V1 ? ? ? ?0.05V1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.31V1 ? ? ? 0.3V1+V2 ? ? ?0.5V1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.05V1 ? ? ? 0.5V1 ? ? ? ? 0.1V1+V2 The matrix is only for an example and the real matrix that I want to use is a 15X15 matrix ,here I would like to optimize the values of V1 and V2 using a formula. Could you please help me how to go about to represent the matrix in R. Thanks in advance! B.Nataraj
______________________________________________ R-help at 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 at 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.
Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm