Re: [R] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-07 Thread greg holly
Hi Jim, Rui and William; I do appreciate for your explanations and help. These are very helpful. Regards, Hayrettin On Tue, Dec 6, 2016 at 4:06 PM, Jim Lemon wrote: > Hi Greg, > What is happening is easy to see: > > ph<-matrix(sample(1:100,40),ncol=4) >

Re: [R] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-06 Thread Jim Lemon
Hi Greg, What is happening is easy to see: ph<-matrix(sample(1:100,40),ncol=4) colnames(ph)<-c("M1","X1","X2","X3") ph[sample(1:10,3),1]<-NA ph M1 X1 X2 X3 [1,] 34 98 3 35 [2,] 13 66 74 68 [3,] NA 22 99 79 [4,] 94 6 80 36 [5,] 18 9 16 65 [6,] NA 29 56 90 [7,] 41 23 7

Re: [R] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-06 Thread William Dunlap via R-help
R is interactive so you can print the intermediate results: > ph <- data.frame(M1=c(1,NA,3,4,5), X1=1:5, X2=c(1,2,NA,4,5), X3=1:5, Y=c(11,12,13,14,NA), row.names=paste0("R",1:5)) > ph M1 X1 X2 X3 Y R1 1 1 1 1 11 R2 NA 2 2 2 12 R3 3 3 NA 3 13 R4 4 4 4 4 14 R5 5 5 5 5 NA > miss

Re: [R] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-06 Thread Rui Barradas
Hello, The first command line produces a logical vector with TRUE if at least one row element of ph is NA and FALSE otherwise. The second creates a vector of zeros with length equal to nrow(ph). Now the third command line. ! negates miss, so TRUE becomes FALSE and vice-versa. sum(!miss)

[R] CONFUSSING WITH select[!miss] <- 1:sum(!miss)

2016-12-06 Thread greg holly
Dear All; I am very new in R and try to understand the logic for a program has been run sucessfully. Here select[!miss] <- 1:sum(!miss) par is confussing me. I need to understandand the logic behind this commend line. Thanks in advance for your help, Greg miss <-