Kunal Shetty wrote:
Dear R- User
I created two random number sets using rnorm function and calcuted their respective means. However now I would like to randomly replace some values with NA. Thus create my own test data. Any help or suggestions on this ?
Use ?sample: n <- 100 x <- rnorm(n) x[sample(n, 4)] <- NA sum(is.na(x)) # [1] 4
Also wanted to confirm when multiplying two random number vectors x am y by matrix..is this how i do it.
A is the matrix
z <- c(x,y) # x and y the two set of vectors
w <- A%*%Z # each element in each vector multipled by the matrix .
(Be careful: R is case sensitive (z != Z).)
I'm not really clear what you want here. "%*%" is matrix multiplication and "*" is elementwise multiplication. Also using "c" makes a vector or length "n = length(x) + length(y)". This implies that "A" above "p x n" (i.e. p rows, n columns) and the result "w" would be "p x 1". Please provide an example of what you expect to see by the multiplication.
--sundar
regards Kunal
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
