similar to: sparse vectors

Displaying 20 results from an estimated 2000 matches similar to: "sparse vectors"

2010 Jul 30
3
simple table/matrix problem
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 zero bats, and 'z' has 3 bats and so on for each
2010 Nov 10
1
S4 package warning
Hello everyone. R-2.12.0, suse linux 11.3. I am debugging a package that uses S4 methods and R CMD check gives the following warning: > Warning in methods::findMethods(g, env) : > non-generic function 'mdm' given to findMethods() > See the information on DESCRIPTION files in the chapter 'Creating R > packages' of the 'Writing R Extensions' manual. I
2010 Jun 29
3
table() of a factor
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") >
2009 Jun 12
1
bundle deprecation
Hi I read that bundles are to be deprecated in 2.10. The BACCO bundle contains three packages (emulator, calibrator, approximator) which I am happy to unbundle. But the 'BACCO' moniker has some considerable cachet for me in terms of recognizability (eg with grant-giving bodies), as it has become an umbrella term for a whole bunch of related statistical functionality of which the three
2009 Jan 22
1
pdf() and pch problems
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 this? le112:~/scratch/R-2.8.1% R --vanilla --quiet >
2009 Jan 22
1
pdf() and pch problems
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 this? le112:~/scratch/R-2.8.1% R --vanilla --quiet >
2009 Jan 22
1
reshape() problems
Hi I have a data frame with timeseries information like this: year cell Q1 Q2 Q3 Q4 1940 1 1.2 1.4 1.4 1.9 1941 1 2.9 2.1 3.4 2.4 1942 1 2.7 3.2 1.5 2.6 1940 2 1.4 2.1 2.6 2.4 1941 2 2.4 1.4 1.4 3.4 1942 2 1.4 2.4 2.5 4.4 where the Qs mean 'quarter'. I want to extract from
2009 Oct 16
1
generalization of tabulate()
Hi I want a generalization of tabulate() which works on rows of a matrix. Suppose I have an integer matrix 'observation': > observation y1 y2 y3 1 4 0 1 4 0 2 0 3 4 1 0 0 5 0 0 1 4 2 0 3 Each row corresponds to a (multivariate) observation. Note that the first two rows are identical: this means that data "c(1,4,0)" was observed twice. Now suppose I can list the sample
2009 Nov 12
1
S4 objects in the data directory
Hi [R-2.10.0; suse linux] I am having difficulty creating S4 objects in the data directory of a package. I want to create a bunch of simple S4 objects for use in the examples section of the Rd files. It says in R-exts that: " R code should be ?self-sufficient? and not make use of extra functionality provided by the package, so that the data file can also be used without having to load
2009 Feb 19
2
vignette compilation times
Dear All I am preparing a number of vignettes that require a very long time to process with Sweave. The longest one takes 10 hours. I love the weaver package! Is a package that includes such a computationally intensive vignette acceptable on CRAN? Are there any guidelines here? -- Robin K. S. Hankin Uncertainty Analyst University of Cambridge 19 Silver Street Cambridge CB3 9EP
2008 Dec 05
1
array indexing
Hi. I have been pondering array indexing via matrices. > a <- array(1:27,rep(3,3)) > index <- matrix(c(1,1,1,1,2,3),2,3,byrow=TRUE) > a[index] [1] 1 22 as expected and documented. But what was the thinking behind the decision to access the array by rows rather than columns? The 'index' matrix is ordered as [1,1,1,2,1,3] and so the extraction is a[index[c(1,3,5)]]
2009 Oct 23
1
access elements of a named list using a factor
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 errors: >
2010 Jul 30
4
transpose of complex matrices in R
Hello everybody When one is working with complex matrices, "transpose" very nearly always means *Hermitian* transpose, that is, A[i,j] <- Conj(A[j,i]). One often writes A^* for the Hermitian transpose. I have only once seen a "real-life" case where transposition does not occur simultaneously with complex conjugation. And I'm not 100% sure that that wasn't a
2009 Dec 03
1
S4 and head() problems
Hi I am having difficulty defining an S4 method for head() and tail(). I can't quite provide minimal self-contained code because the problem appears to require the whole corpus of my package; and there also appears to be a difference between sourcing the lines directly, and having them installed in a package. The lines in question (I think) are: setClass("mdm",
2010 Jan 26
1
add points to 3D plot using p3d {onion}
Hi, Can anyone guide me as to how I can add points to a p3d() plot from the onion package?? I want to plot points with different colors on the same 3D plot.? Perhaps I can do this without adding points but somehow directing the 'h' parameter to give different color to points based on a factor I assign to them? FYI, I can do this using using scatterplot3d() and points3d(), but these plots
2008 Dec 11
1
Complex integration in R
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 because it's only used with "numeric" arguments Does anyone know some function to approximate complex integrals? Thanks Borja [[alternative HTML version deleted]]
2009 Mar 02
2
Goldbach partitions code
Folks, I put up a brief note describing my naive attempts to compute Goldbach partitions, starting with a brute-force approach and refining progressively. http://jostamon.blogspot.com/2009/02/goldbachs-comet.html I'd welcome your suggestions on improvements, alternatives, other optimisations, esp. to do with space vs time tradeoffs. Is this an example interesting enough for
2009 Oct 13
2
S4 tutorial
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 introductory material? I'm very familiar with OO and C++. If there is some material that suits my background, it will be great. https://stat.ethz.ch/pipermail/r-help/2009-January/184108.html
2010 Jan 06
2
Generating data from Null Distribution
Hello everyone, Can someone tell me exactly how to generate data from a null distribution for the fisher exact test? I know I have to use the hypergrometric but exactly what commands do I use? Jim [[alternative HTML version deleted]]
2008 Nov 19
2
Multidimensional array with R
Hi there I know, I'm sure you discussed this stuff 100 times, but I really have a basic understanding problem, if and how do I create a multidimensional array in R. I'm coming from MATLAB and there it's as easy as you ever could imagine. Ok, so, I want to have an array, where I can fill in data from a Excel spreadsheet. The array should be addressed like this: