[R] [R-pkgs] new package on CRAN: multivator

2012-02-15 Thread robin hankin
. URL http://www.jstatsoft.org/v46/i08/ best wishes Robin -- Robin Hankin Uncertainty Analyst hankin.ro...@gmail.com ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages

Re: [R] Trouble installing gsl wrapper

2010-10-30 Thread robin hankin
of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/ University of Oxford,             Tel:  +44 1865 272861 (self) 1 South Parks Road,                     +44 1865 272866 (PA) Oxford OX1 3TG, UK                Fax:  +44 1865 272595 -- Robin Hankin Uncertainty Analyst hankin.ro...@gmail.com

Re: [R] boundary check

2010-09-24 Thread Robin Hankin
Hello convex hulls in large numbers of dimensions are hard. For your problem, though, one can tell whether a given point is inside or outside by using linear programming: X - matrix(rnorm(50), 10, 5) x_i - matrix(rnorm(5), 1, 5) isin.chull function(candidate,p,plot=FALSE,give.answers=FALSE,

Re: [R] boundary check

2010-09-24 Thread Robin Hankin
pm, Robin Hankin rk...@cam.ac.uk wrote: Hello convex hulls in large numbers of dimensions are hard. For your problem, though, one can tell whether a given point is inside or outside by using linear programming: X - matrix(rnorm(50), 10, 5) x_i - matrix(rnorm(5), 1, 5) isin.chull

[R] simple table/matrix problem

2010-07-30 Thread Robin Hankin
Hi Given three vectors x - c(fish=3, dogs=5, bats=2) y - c(dogs=1, hogs=3) z - c(bats=3, dogs=5) How do I create a multi-way table like the following? out x y z bats 2 0 3 dogs 5 1 5 fish 3 0 0 hogs 0 3 0 ('out' is a matrix). See how the first line shows 'x' has 2 bats, 'y' has

Re: [R] Function to compute the multinomial beta function?

2010-07-06 Thread Robin Hankin
It's usually better to build vectorization in to functions: beta3- function (n1, n2, n3) exp(lgamma(n1)+lgamma(n2)+lgamma(n3)-lgamma(n1+n2+n3)) f - function(x){exp(sum(lgamma(x))-lgamma(sum(x)))} beta3(5,3,8) [1] 1.850002e-07 f(c(5,3,8)) [1] 1.850002e-07 rksh On 07/06/2010 01:54 AM,

Re: [R] Apply a shift which is a function of the array.

2010-07-02 Thread Robin Hankin
Hello Jim you can use ashift() from the same library which does (I think) what you want. HTH, Robin On 07/02/2010 12:05 PM, Jim Hargreaves wrote: Dear List, I have a 2,000x10,000 array of time domain data which when plotted draws a distinct pulse. The matrix is 10,000 pulses of

Re: [R] Apply a shift which is a function of the array.

2010-07-02 Thread Robin Hankin
Hello again Jim It seems that ashift() from the same package *doesn't* do what you want. But you can use shift() as follows: myshift - function(x){shift(x,1-which.max(x))} a - matrix(runif(30),5,6) a [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.268955362

[R] table() of a factor

2010-06-29 Thread Robin Hankin
Hi suppose I have a factor 'x': x - as.factor(c(rep(a,3),b,d)) table(x) x a b d 3 1 1 But this is not what I want because I need to include the fact that the count of c is zero. I can't just change the levels of x: levels(x) - c(a,b,c,d) table(x) x a b c d 3 1 1 0 because this

Re: [R] table() of a factor

2010-06-29 Thread Robin Hankin
thanks everyone. I think the motto should be always specify the levels of a factor when you create it if you possibly can. best wishes Robin On 06/29/2010 12:39 PM, Felix Andrews wrote: Just use factor(), not levels(); you can pass a factor to factor() too. x-

Re: [R] add points to 3D plot using p3d {onion}

2010-01-27 Thread Robin Hankin
Hello Bradley I don't think there's an easy way to do what you want because the viewing angles are internal to p3d(). Frankly p3d() tries to be all things to all men (the arguments are a mess) and inevitably isn't as flexible as one might wish. I take it you want to do this: data(bunny)

Re: [R] Generating data from Null Distribution

2010-01-06 Thread Robin Hankin
Jim the 2x2 case is reasonably straightforward because the support is quite a small set. With the aylmer package you could do this: a - matrix(c(1,5,7,8),2,2) sample(seq_along(allprobs(a)),100,replace=TRUE,prob=allprobs(a)) [1] 3 2 4 1 3 4 4 4 4 3 3 4 4 2 3 4 5 4 3 3 4 4 2 1 4 3 3 3 4 2 3

Re: [R] expand.grid game

2009-12-21 Thread Robin Hankin
Hi library(partitions) jj - blockparts(rep(9,8),17) dim(jj) gives 318648 HTH rksh baptiste auguie wrote: Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code this in C. The game is the following: how many 8-digit numbers have the sum of their

Re: [R] expand.grid game

2009-12-21 Thread Robin Hankin
system elapsed 0.160 0.068 0.228 In some ways I think this is close to Hadley's suggestion, though I didn't know how to implement it. Thanks a lot to everybody who participated, I have learned interesting things from a seemingly innocuous question. Best regards, baptiste 2009/12/21 Robin

Re: [R] expand.grid game

2009-12-21 Thread Robin Hankin
) } Or am I missing something?! Ted. On 21-Dec-09 07:57:32, Robin Hankin wrote: Hi library(partitions) jj - blockparts(rep(9,8),17) dim(jj) gives 318648 HTH rksh baptiste auguie wrote: Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code

Re: [R] Fishers exact test at 2.2e-16

2009-12-17 Thread Robin Hankin
The aylmer package has some functionality in this regard which you may find useful. In particular, you can use good() to get a feel for the number of tableaux that are consistent with the specified marginal totals: good(dat2) [1] 42285210 good(dat3) [1] 2.756286e+12 HTH rksh Søren

Re: [R] how to creat a matrix

2009-12-11 Thread Robin Hankin
Hi try R library(magic) R ashift(diag(5),1) HTH rksh enrique Dallazuanna wrote: Try this: N - 5 diag(1, N)[c(N, 1:(N - 1)),] On Fri, Dec 11, 2009 at 1:47 PM, Moohwan Kim kmhl...@gmail.com wrote: Dear R family I am attempting to create a matrix. e.g., 0 0 0 0 1 1 0 0 0 0 0 1 0 0

[R] access elements of a named list using a factor

2009-10-23 Thread Robin Hankin
Hi I have a factor 'f' and a named list 'jj'. I want names(jj) to match up with levels(f). How do I use levels(f) to access elements of jj? f - factor(c(pigs,pigs,slugs)) f [1] pigs pigs slugs Levels: pigs slugs jj - list(pigs=1:10,slugs=1:3) My attempts to produce jj$pigs all give

Re: [R] access elements of a named list using a factor

2009-10-23 Thread Robin Hankin
(pigs = 1:10, slugs = 1:3) jj[levels(f)[1]] jj[[levels(f)[1]]] Best, Dimitris Robin Hankin wrote: Hi I have a factor 'f' and a named list 'jj'. I want names(jj) to match up with levels(f). How do I use levels(f) to access elements of jj? f - factor(c(pigs,pigs,slugs)) f [1] pigs pigs

Re: [R] reference on fisher.test()

2009-10-16 Thread Robin Hankin
Hi fexact.c points you to the original ACM paper: /* ALGORITHM 643, COLLECTED ALGORITHMS FROM ACM. THIS WORK PUBLISHED IN TRANSACTIONS ON MATHEMATICAL SOFTWARE, VOL. 19, NO. 4, DECEMBER, 1993, PP. 484-488. - You may find the

Re: [R] S4 tutorial

2009-10-14 Thread Robin Hankin
Peng the Brobdingnag package includes a vignette that gives a step-by-step guide to creating a simple package that uses S4. best wishes Robin Peng Yu wrote: I'm looking for some tutorial on S4. I only find the following one, which is not in English. Can somebody let me know if there is any

[R] sparse vectors

2009-09-08 Thread Robin Hankin
Hi I deal with long vectors almost all of whose elements are zero. Typically, the length will be ~5e7 with ~100 nonzero elements. I want to deal with these objects using a sort of sparse vector. The problem is that I want to be able to 'add' two such vectors. Toy problem follows. Suppose I

Re: [R] Goldbach partitions code

2009-03-03 Thread Robin Hankin
Hi interesting blog! not strictly relevant, but there are various number-theoretic functions implemented in the elliptic package which you might find useful. best wishes Robin murali.me...@fortisinvestments.com wrote: Folks, I put up a brief note describing my naive attempts to compute

[R] reshape() problems

2009-01-22 Thread Robin Hankin
Hi I have a data frame with timeseries information like this: year cell Q1Q2 Q3 Q4 1940 1 1.2 1.4 1.41.9 1941 1 2.9 2.1 3.4 2.4 1942 1 2.7 3.2 1.52.6 1940 2 1.4 2.1 2.62.4 1941 2 2.4 1.4 1.4

[R] pdf() and pch problems

2009-01-22 Thread Robin Hankin
Hi R-2.8.1, Suse 11.1 I'm having problems with pdf(). In the following transcript, file 'f.pdf' does not use the expected symbols for the plot. It uses a 'q' letter instead of the open circle I get when viewing the graphics window. I also get the same under r47678. Does anyone else get

Re: [R] R package tests

2009-01-15 Thread Robin Hankin
I think the OP was asking about test suites that test the software. The R package structure includes a test/ directory which you can use to put tests. For example, in the onion package I check that I have got my signs and multiplication table correctly implemented: stopifnot(Hi*Hj == Hk)

Re: [R] Construct All Possible Strings from 4 Bases (ATCG)

2008-12-17 Thread Robin Hankin
Gundala f - function(n){expand.grid(rep(list(seq_len(4)),n))} HTH Robin Gundala Viswanath wrote: Dear all, Is there an efficient way in R to construct all strings from 4 bases (ATCG). If we want a length L string, there are 4 ^ L possible strings of such. e . g with L = 2 we have

Re: [R] Complex integration in R

2008-12-12 Thread Robin Hankin
Hi Borja library(elliptic) ?myintegrate HTH rksh Borja Soto Varela wrote: Dear R-user I need a function to approximate a complex integration. My function is: aprox2=function(s,x,rate){ dexp(x,rate)*exp(-s*x) } where argument s is a complex number. I can't use the integrate function

Re: [R] for loop query

2008-12-09 Thread Robin Hankin
Hi start simple! Work out *each* row combined with *each* row, to give (in your case) a 26-by-26 matrix. Only after you have got this working, start thinking about making it run faster [eg by only evaluating the upper triangular entries] To do a nested loop, do M - matrix(0,n,n) for(i in

Re: [R] Lexical Permutation Algorithm in R

2008-12-05 Thread Robin Hankin
Rory there are several packages that perform this. I would use permn() of the combinat library, then, if lexicographical order is important, sort it explicitly. HTH rksh [EMAIL PROTECTED] wrote: Hi all Here is a rather naive implementation of the SEPA algorithm for generating lexical

Re: [R] small numbers

2008-12-04 Thread Robin Hankin
Hi use the logarithmic representation for your problem. The Brobdingnag package uses such a form in a (more-or-less) user-transparent manner. HTH rksh Marc Jekel wrote: Dear R Fans, I have a simple probem but cannot find any reference to the soultion. I want to do calculations with small

Re: [R] hypergeometric

2008-12-03 Thread Robin Hankin
The hypergeo package should be able to deal with this, although the function you specify below looks like a degenerate case (if I understand it correctly) so the convergence rate is likely to be slow. Let me know how you get on best wishes Robin (author of hypergeo) Jarle Brinchmann wrote:

Re: [R] Multidimensional array with R

2008-11-20 Thread Robin Hankin
Hello a good place to start is R-and-octave.txt, in the contributed docs section of CRAN. This translates between common matlab and R commands HTH rksh Michael Zak wrote: Hi there I know, I'm sure you discussed this stuff 100 times, but I really have a basic understanding problem, if

Re: [R] Computational problems in R

2008-10-28 Thread Robin Hankin
Hello. The Brobdingnag package uses that identity for a logarithmic representation and also has a hack for negative numbers. HTH rksh A.Noufaily wrote: Many thanks for your suggestions... I am still checking which one is the most useful for my simulations. Concerning using logs, this

Re: [R] weird behavior with the 3rd root....

2008-10-27 Thread Robin Hankin
This comes up from time to time. The problem is that one needs complex numbers to address taking the third root: there are three cube roots for any nonzero number (real or complex). To wit: (-0.084121928394+0i)^(1/3) [1] 0.2190818+0.3794609i (-0.084121928394-0i)^(1/3) [1]

Re: [R] Generalising to n-dimensions

2008-09-26 Thread Robin Hankin
of expand.grid() [but you will have to coerce it to a matrix] HTH rksh Thank you, Laura On Wed, Sep 24, 2008 at 8:27 PM, Laura Bonnett [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Can I ask what a and v are? Thanks, Laura On Sat, Aug 23, 2008 at 11:41 AM, Robin Hankin

Re: [R] Generating a valid covariance matrix

2008-09-26 Thread Robin Hankin
Megh corr.matrix() in the 'emulator' package can calculate P-D variance matrices using any of a very broad class of methods. HTH rksh Megh Dal wrote: I want to generate a valid variance-covariance matrix. One way could be to generate some random sample from multivariate normal

Re: [R] How to draw the graph of f(x,y) = x * y ?

2008-09-24 Thread Robin Hankin
Paul you might find the view() function in the 'elliptic' package useful. This function implements various methods to visualize functions over the complex plane. HTH rksh Paul Smith wrote: Dear All, The function curve() draws the graph of functions from R to R. Is there some homologous

Re: [R] Generalising to n-dimensions

2008-09-23 Thread Robin Hankin
First bit: x - c(3,2,2) expand.grid(sapply(x,seq_len)) Var1 Var2 Var3 1 111 2 211 3 311 4 121 5 221 6 321 7 112 8 212 9 312 10122 11222 12322

Re: [R] Generalising to n-dimensions

2008-09-23 Thread Robin Hankin
Laura Bonnett wrote: crosstable[,,expand[d,1],expand[d,2],expand[d,3],...expand[d,n]] crosstable is just a crosstabulation of an n+2-dimensional dataset and I am trying to pick out those that are in combination 'd' of expand. So for example, for 5-dimensional data using your example: Var1

Re: [R] how to keep up with R?

2008-09-22 Thread Robin Hankin
Adaikalavan Ramasamy wrote: I agree! The best way to learn (and remember for longer) is to teach someone else about it. And there is not reason not to repeat some of the anlysis done on SAS with R. That way you can verify your outputs or compare the presentations. If you consistently find

Re: [R] how to keep up with R?

2008-09-19 Thread Robin Hankin
Hi Wensei. Why not do as I do? Find an interesting area of numerical computation (perhaps not statistical) that has not been implemented in open-source. Then write an R package for it, under GPL-2, then write an article about the new package in R-news or JSS. works for me. Best wishes

Re: [R] give all combinations

2008-09-01 Thread Robin Hankin
Hi Yuan, Lucien, List. try this: f - function (...) { args - list(...) if(length(args)==0){ return(NULL) } if (length(args) == 1) { return(args[[1]]) } if (length(args) 2) { jj - do.call(Recall, c(args[-1])) return(do.call(Recall,

[R] [R-pkgs] new package multipol

2008-04-23 Thread Robin Hankin
-- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages

Re: [R] S4 : package creation

2008-03-25 Thread Robin Hankin
/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help

Re: [R] empty array

2008-03-18 Thread Robin Hankin
-guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@r

Re: [R] Bessel functions of complex argument

2008-03-10 Thread Robin Hankin
://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. -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way

Re: [R] [OT] normal (as in Guassian)

2008-03-04 Thread Robin Hankin
: -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] PDF with computationally expensive normalizing constant

2008-02-11 Thread Robin Hankin
a - CalculateNormalizingConstant(a) and after this, object a would then have the numerically computed NC in place. Is this a Good Idea? Are there any PDFs implemented in R in which this is an issue? -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre

Re: [R] learning S4

2008-02-11 Thread Robin Hankin
__ 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. -- Robin Hankin Uncertainty

Re: [R] Appell Hypergeometric function

2008-02-07 Thread Robin Hankin
-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743

[R] = in functions and matlab (was: Multiplying each row of a big matrix with a vector)

2008-01-30 Thread Robin Hankin
-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. -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre

Re: [R] An R is slow-article

2008-01-09 Thread Robin Hankin
/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. -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK

[R] array addition

2007-12-19 Thread Robin Hankin
] [1,]147 [2,]258 [3,]369 x [,1] [,2] [,3] [,4] [,5] [1,]27 1279 [2,]49 148 10 [3,]36900 Note the zeros at lower-right. Is there a ready-made solution to this? -- Robin Hankin Uncertainty

Re: [R] can R solve these paired equations

2007-12-17 Thread Robin Hankin
]] __ 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. -- Robin Hankin Uncertainty Analyst and Neutral Theorist

Re: [R] Matrix Inversion

2007-12-12 Thread Robin Hankin
-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. -- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre

Re: [R] rowSums() and is.integer()

2007-11-21 Thread Robin Hankin
advantage of coercion is to avoid integer overflow. Indeed, as I told Robin Hankin privately, that was the design reason. Brian Ripley also reminded me that the sum() of integers is an integer, behaviour that I find desirable. The reason for my starting this thread is that sometimes I actually

Re: [R] R det

2007-11-19 Thread Robin Hankin
, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] All nonnegative integer solution

2007-11-19 Thread Robin Hankin
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. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way

Re: [R] creating discretized data

2007-11-16 Thread Robin Hankin
]] __ 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. -- Robin Hankin Uncertainty Analyst

[R] rowSums() and is.integer()

2007-11-09 Thread Robin Hankin
is this? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

Re: [R] flipping vector and matrix

2007-10-23 Thread Robin Hankin
://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R

Re: [R] flipping vector and matrix

2007-10-23 Thread Robin Hankin
-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@r

Re: [R] rearrange data columns

2007-10-11 Thread Robin Hankin
, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] reference for logistic regression

2007-10-11 Thread Robin Hankin
deviation page says. Is this what you meant? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] Multivariate chi-square distribution function

2007-10-10 Thread Robin Hankin
-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. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton

Re: [R] error installing gsl pkg

2007-10-03 Thread Robin Hankin
http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743

[R] Sweave: tables vs matrices

2007-09-14 Thread Robin Hankin
} \caption{snipped caption} \end{table} = jj - matrix(c(2, 3, 4, 1, 0, 5, 7, NA, 3, 7, NA, 4, 2, NA, NA, 2 ),byrow=TRUE,nrow=4) jj - rbind(jj,apply(jj,2,sum,na.rm=TRUE)) jj - cbind(jj,apply(jj,1,sum,na.rm=TRUE)) jj @ -- Robin