Re: [R] looping through 3D array

2014-01-10 Thread apadr007
It seems like emdist does not like to compare matrices with all 0 values. I
ended up removing those from my 3D array and have ~8000 matrices instead of
13000.

I am using res2 <- unlist(mclapply(seq_len(ncol(indx)),function(i) {x1 <-
indx[,i]; emd2d(results[x1[1],,],results[x1[2],,]) }) )

But even with mclapply it is taking extremely long. Any way to speed this
up?

On Jan 9, 2014 4:10 PM, "arun kirshna [via R]" <
ml-node+s789695n4683362...@n4.nabble.com> wrote:
>
> Hi,
> No problem.
> You can use ?lower.tri() or ?upper.tri()
>
> res[lower.tri(res)]
> res[lower.tri(res,diag=TRUE)]
> #Other way would be to use:
> ?combn
> indx <- combn(dim(results)[1],m=2)
>
>
> res2 <- sapply(seq_len(ncol(indx)),function(i) {x1 <- indx[,i];
emd2d(results[x1[1],,],results[x1[2],,]) })
>  identical(res[lower.tri(res)], res2)
> #[1] TRUE
> A.K.
>
>
>
>
> On Thursday, January 9, 2014 4:03 PM, alex padron <[hidden email]> wrote:
>
> Thanks. This works. I just noticed that half of the matrix repeats. For
example res[1,2] is the same as res[2,1]. any way to get half of the matrix
output (notice the diagonal 0 across the output matrix)?
>
>
>
> -Alex
>
>
> On Thu, Jan 9, 2014 at 12:57 PM, arun <[hidden email]> wrote:
>
> #or
>
> >you can use ?expand.grid() and then loop over:
> >indx <- expand.grid(rep(list(seq(dim(results)[1])),2))
> >res1 <- matrix(sapply(seq_len(nrow(indx)),function(i) {x1 <- indx[i,];
emd2d(results[x1[,1],,],results[x1[,2],,]) }),ncol=10)
> >identical(res,res1)
> >#[1] TRUE
> >
> >
> >
> >
> >
> >On Thursday, January 9, 2014 3:46 PM, arun <[hidden email]> wrote:
> >Hi,
> >Try:
> >library(emdist)
> >
> >set.seed(435)
> >results<- array(sample(1:400,120,replace=TRUE),dim=c(10,3,4))
> >res <- sapply(seq(dim(results)[1]),function(i) {x1 <- results[i,,]; x2
<- results; sapply(seq(dim(x2)[1]),function(i) emd2d(x1,x2[i,,]))})
> >dim(res)
> >#[1] 10 10
> >A.K.
> >
> >
> >
> >
> >
> >
> >
> >On Thursday, January 9, 2014 3:25 PM, alex padron <[hidden email]>
wrote:
> >
> >I'll try to be clearer. in your example we have: results<-
array(1:120,dim=c(10,3,4))
> >
> >I want to do the following: compare results[1,,] with every matrix
inside results. I then want to jump to results[2,,] and compare it to all
of the other 10 matrices inside results and so on. so emd2d from
the emdist package outputs a single value when comparing matrices and since
your example has 10 matrices who are all being compared, the output should
be 100 values.
> >
> >Does that make sense?
> >
> >
> >-Alex
> >
>
> __
> [hidden email] 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.
>
>
> 
> If you reply to this email, your message will be added to the discussion
below:
>
http://r.789695.n4.nabble.com/looping-through-3D-array-tp4683350p4683362.html
> To unsubscribe from looping through 3D array, click here.
> NAML




--
View this message in context: 
http://r.789695.n4.nabble.com/looping-through-3D-array-tp4683350p4683403.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@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.


[R] ggplot2 boxplot help

2012-08-04 Thread apadr007
Hello, 

I have a data set that looks like this: 

   name  G-ID test_id g-id g
1 00077464 C_068131 C_068131 OC_068131-
2 00051728 C_044461 C_044461 OC_044461-
3 00058738 C_050343 C_050343 OC_050343-
4 00059239 C_050649 C_050649 OC_050649-
5 1761 C_000909 C_000909 OC_000909-
6 5119 C_002752 C_002752 OC_002752-
 locssample_1 sample_2 value_1  value_2
1 37316550-37317847   N  C   1.9268400 36.77590
2 27058468-27060176   N  C   0.1817890  5.58835
3 4761739-4763268N  C0.2309000 
7.54035
4  14565311-14567393   N C  0.0294559 
1.50886
5  38670994-38675694   N  C 0.4678610
14.75560
6   48362804-48380794   N C 10.7258000
92.13150



In this dataset, sample_1 corresponds to value_1 and sample_2 corresponds to
value_2. How can I graph this in ggplot2's boxplot function? I am not quite
sure how to tell R that sample_1 and sample_2 columns correspond to value_1
and value_2 using ggplot2. 

Can anyone shed some light on this?

Thanks. 



--
View this message in context: 
http://r.789695.n4.nabble.com/ggplot2-boxplot-help-tp4639187.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.