[R] Remove columns

2009-08-18 Thread Alberto Lora M
Hi Everbody Could somebody help me.? I need to remove the columns where the sum of it components is equal to zero. For example > a<-matrix(c(0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0), ncol=4) > a [,1] [,2] [,3] [,4] [1,]0001 [2,]0101 [3,]00

[R] Lists

2009-07-24 Thread Alberto Lora M
Hi Everybody I have the following problem suppose that we a<-c("uno","dos","tres") I am working with a while cycle and the idea is in each iteration adding an item to a list In the first iteration the resultshould be: [[1]] [1] "uno" In the second [[1]] [1] "uno" [[2]] [1] "dos" And the fina

[R] Help

2009-07-23 Thread Alberto Lora M
Dear R project group I have the following problem Let suppose the following data: b<-c("0","1","1","1","0","1","0","0","1","0","1","1","1","0","1","1","0","1","1","0") bm<-matrix(b,ncol=4) colnames(bm)<-c("F1", "F2", "F3", "F4") d<-c("F1","F4") For the matrix bm i need to create a fifth colum

[R] I need to obtain all the rows in m1 in which m2 the elements of m2 are present

2009-07-20 Thread Alberto Lora M
Hi could you yelp me please with this Suppose that we have the following matrix m1<-matrix(c("a","7","a","i","o","u","i","1","2","3","4","5","6","7"), ncol=2) m1 [,1] [,2] [1,] "a" "1" [2,] "7" "2" [3,] "a" "3" [4,] "i" "4" [5,] "o" "5" [6,] "u" "6" [7,] "i" "7" m2<-c("a","7") I need

[R] Rows for a list of values

2009-07-20 Thread Alberto Lora M
Hi could yelp me with this Suppose that we have the following matrix m1<-matrix(c("a","e","a","i","o","u","i","1","2","3","4","5","6","7"), ncol=2) m2<-c("a","i") m1 [,1] [,2] [1,] "a" "1" [2,] "e" "2" [3,] "a" "3" [4,] "i" "4" [5,] "o" "5" [6,] "u" "6" [7,] "i" "7" I want to obt

[R] Arules questions. I need some help please

2009-07-17 Thread Alberto Lora M
Question 2a) I am also working with arules package and I have the following problem let suppose the matrix b like: b<-matrix(c(1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1),nrow=6) rownames(b)=c("T1", "T2", "T3", "T4", "T5", "T6") colnames(b)=c("It1", "It2", "It3", "It4") bt<-as(b, "transactions

Re: [R] Extract pairs (rowname, columname) from a matrix where value is 0

2009-07-16 Thread Alberto Lora M
Dear sir, I have 2 questions: Question 1: suppose that we have the following: a<-matrix(c(0,2,0,4,0,6,5,8,0),nrow=3) colnames(a)<-c("F1","F2","F3") rownames(a)<-c("A1","A2","A3") a ind <- which(a == 0, arr = TRUE) mapply("[", dimnames(a), as.data.frame(ind)) I want to add a column to the resu

Re: [R] Extract pairs (rowname, columname) from a matrix where value is 0

2009-07-16 Thread Alberto Lora M
paste(rn[x[1]],",", cn[x[2]], sep ="") > > ) > >) > > > > # res > > # 1 A1,F1 > > # 2 A3,F1 > > # 3 A2,F2 > > # 4 A3,F3 > > > > See ?which, ?apply and ?paste fo

[R] Extract pairs (rowname, columname) from a matrix where value is 0

2009-07-15 Thread Alberto Lora M
Dear sir, I have a matrix like a<-matrix(c(0,2,0,4,0,6,5,8,0),nrow=3) colnames(a)<-c("F1","F2","F3") rownames(a)<-c("A1","A2","A3") a F1 F2 F3 A1 0 4 5 A2 2 0 8 A3 0 6 0 I want to extract all pairs (rownames, columnames) from which the value in the matrix is 0 The result should be