Re: [R] loop and sapply problem, help need

2011-04-09 Thread jim holtman
try this: > x <- read.table(textConnection(" + mark lcd1 lcd2 lcd3 PR1 PR2 PR3 PR4 + 1 11 22 12 1 2 3 1 + 2 33 44 34 1 2 3 1 + 3 22 44 24 3 1 2 1 + 4 11 33 13 2 2 1 3 + 5 22 11 12 3 2 2 1 "), header = TRUE) > closeAllConnections() > x # before mark lcd1 lcd2 lcd3 PR1 PR2 PR3 PR4 11 11

Re: [R] loop and sapply problem, help need

2011-04-09 Thread Ram H. Sharma
Hi Phil and R users Let me clear my problem. The generating sample is not prime issue here. I am simulating a situation, for which I need to sample. But once I have sampling done, I need to do a conditional decoding. Let me clear it with more clear data example: x <- read.table(textConnection(" m

Re: [R] loop and sapply problem, help need

2011-04-09 Thread Phil Spector
Ram - I think you'll have to explain what you're trying to do. First, you're creating a 10x10 matrix newd, which could be done a bit more efficiently by using newd = matrix(sample(c(1,2,3,3,),10*length(pvec),replace=TRUE),ncol=10) Notice that calling sapply on a matrix applies the f

[R] loop and sapply problem, help need

2011-04-09 Thread Ram H. Sharma
Dear R experts Sorry for this question M1 <- 1:10 lcd1 <- c(11, 22, 33, 44, 11, 22, 33, 33, 22, 11) lcd2 <- c(22, 11, 44, 11, 33, 11, 22, 22, 11, 22) lcd3 <- c(12, 12, 34, 14, 13, 12, 23, 23, 12, 12) #generating variables through sampling pvec <- c("PR1", "PR2", "PR3", "PR4", "PR5", "PR6", "PR7