Re: [R] "inahull? from package alphahull not working when used with lapply

2014-10-27 Thread Bart Kastermans
On 27/10/14 19:42, Camilo Mora wrote: > Hi Bart, > > Even after putting the variables in the apply function, the results come not > right: > > library (alphahull) > DT=data.frame(x=c(0.25,0.25,0.75,0.75),y=c(0.25,0.75,0.75,0.25)) > Hull <- ahull(DT, alpha = 0.5) > > TEST<- data.frame(x=c(0.25,0

Re: [R] "inahull” from package alphahull not working when used with apply

2014-10-26 Thread Bart Kastermans
On 27/10/14 06:05, Camilo Mora wrote: > Hi everyone, > > I have a two column (x,y) database with say 20 million rows. I want to check > the points that are inside of a hull created with the package alphahull. The > function that does this is call �inahull�, and it runs well when I use it for >

Re: [R] Cluster -- Agnes function

2014-09-24 Thread Bart Kastermans
On 24/09/14 16:13, Sohail Khan wrote: > Dear All, > > I have clustered a patient data set by agnes. > > I want to extract information for each cluster, I.E. all row ids > belonging to each cluster. Fascinating, thank you for sharing. Best, Bart __ R-

Re: [R] knitr and stopifnot replacement.

2014-08-22 Thread Bart Kastermans
On 22 Aug 2014, at 12:39, Duncan Murdoch wrote: > On 22/08/2014, 6:02 AM, Bart Kastermans wrote: >> I have a daily generated report in which I put a check using stopifnot. >> Unfortunately >> I didn’t check the effect very well, turns out that if the condition checked &g

[R] knitr and stopifnot replacement.

2014-08-22 Thread Bart Kastermans
I have a daily generated report in which I put a check using stopifnot. Unfortunately I didn’t check the effect very well, turns out that if the condition checked fails this is not shown in the knitr output (I only get an error much later due to a missing object). So my question is, what is th

Re: [R] ask for help

2014-08-07 Thread Bart Kastermans
Better: b <- c(a[1]-1,a[-length(a)]) On 07 Aug 2014, at 17:28, Bart Kastermans wrote: > For readability I like: > >> b <- c(0,a[-length(a)]) >> which(a != b & a == 0) > [1] 4 12 18 >> which(a != b & a == 1) > [1] 1 6 16 23 > > > On 0

Re: [R] ask for help

2014-08-07 Thread Bart Kastermans
For readability I like: > b <- c(0,a[-length(a)]) > which(a != b & a == 0) [1] 4 12 18 > which(a != b & a == 1) [1] 1 6 16 23 On 07 Aug 2014, at 17:23, William Dunlap wrote: > My solution may be a bit clearer if you define the function isFirstInRun > isFirstInRun <- function(x) { > if (le

Re: [R] bar plot stacked

2014-06-19 Thread Bart Kastermans
On 19 Jun 2014, at 15:42, message wrote: > Readers, > > For data set: > > a, 90, 10 > b, 60, 40 > c, , > d, , 50 > > A plot was attempted: Wonder who attempted this. :-) > > dataset<-as.matrix(read.csv("datafile.csv",header=FALSE)) Look at your dataset; I’d say it is clearly not what you w

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Bart Kastermans
he answer should have the elements of tm.1 with the following indexes > 1,1 1,3 > 2,1 2,3 > 3,1 3,3 In that example: > t(apply(tm.1, 1, function(x) x[x>0])) [,1] [,2] [1,]12 [2,]12 [3,]12 > class(t(apply(tm.1, 1, function(x) x[x>0]))) [1] "m

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Bart Kastermans
s a vector which is useless as I want a matrix. > > > On Thursday, June 19, 2014 2:40 PM, Bart Kastermans > wrote: > > > > tm.1 <- matrix(c(11,22,33,-4), ncol=2) > > which(tm.1 > 0, arr.ind=TRUE) > row col > [1,] 1 1 > [2,] 2 1 > [3,] 1 2 >

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Bart Kastermans
On 19 Jun 2014, at 13:19, carol white wrote: > Hi, > Is there a way to extract a subset of non-contiguous elements of a matrix > elegantly and with 1 or very few scripts? > > Suppose I have a matrix of positive and negative numbers (m) and I want to > retrieve only the positive number. This I

Re: [R] Use of library(X) in the code of library X.

2014-06-08 Thread Bart Kastermans
s" you'll learn more bad habits than good ones if > you examine my packages… > > Max > > On Fri, Jun 6, 2014 at 2:42 PM, Duncan Murdoch > wrote: >> On 06/06/2014 10:26 AM, Bart Kastermans wrote: >>> >>> To improve my R skills I try to understand s

[R] Use of library(X) in the code of library X.

2014-06-06 Thread Bart Kastermans
To improve my R skills I try to understand some R code written by others. Mostly I am looking at the code of packages I use. Today I looked at the code for the caret package http://cran.r-project.org/src/contrib/caret_6.0-30.tar.gz in particular at the file R/adaptive.R This file starts with:

Re: [R] Apriori probabilities in naiveBayes function

2013-08-05 Thread Bart Kastermans
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 8/5/13 1:00 PM, Anindya Sankar Dey wrote: > Hi All, > > I applied the naiveBayes function in e1071 package with the iris > data, and here's the list that was created > > structure(list(apriori = structure(c(50L, 50L, 50L), .Dim = 3L, > .Dimnam