[R] problem with parameters
Joshua Wiley
jwiley.psych at gmail.com
Wed Nov 24 15:54:34 CET 2010
Well since you said that it cannot recognize the value of 'p', this
suggests that you have not defined that object. Here is an example of
what you might be trying to do (you can just copy and paste the code
into R):
########################################
## create x matrix of 0s
x <- matrix(0, nrow = 21, ncol = 21)
## define 'p'
p <- runif(1)
## assign 'p' to row 1 column 1
x[1, 1] <- p
## assign '1 - p' to row 10, column 10
x[10, 10] <- 1 - p
## print matrix
x
########################################
Josh
On Wed, Nov 24, 2010 at 1:51 AM, alkalinetrio <andrymazzanti at hotmail.com> wrote:
>
> Ok, I try to explain better...
>
> I have to create a 21x21 matrix with numbers and a parameter (for example I
> have to put "p" and "1-p" somewhere in the matrix).
>
> I know how to write a matrix with all numbers, but if I put the parameter
> inside, it says that it can't recognize the value p.
>
> What should I do?
> Thank you
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/problem-with-parameters-tp3055682p3056983.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list