similar to: access elements of a named list using a factor

Displaying 20 results from an estimated 5000 matches similar to: "access elements of a named list using a factor"

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
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 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 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
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",
2009 Sep 08
5
sparse vectors
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 have two such objects, 'a' and 'b': > a $index [1] 20 30 100000000
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
2004 Nov 16
1
lme, two random effects, poisson distribution
Hello, I have a dataset concerning slugs. For each slug, the number of pumps per one time slot was counted. The number of pumps follows Bi(30, p) where p is very small, thus could be approximated by Poisson dist. (# of pumps is very often = 0) The slugs were observed during 12 time slots which are correlated in time as AR(1). The time slots are divided into two categories: Resting time
2010 Sep 22
2
How to fix error: 'x' and 'y' lengths differ
Hi, im a student so still very new to R. Hope someone could help me out here =) They are 3 slug control products, bustaslug, product X and Y. Im ask to explore the data by plot() and tapply(). But when i try to plot or use the tapply command, it tells me that the x and y lengths differ. so im thinking its because the data is unbalanced? Is there a simple command that i could use to fix this?
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 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
2010 Oct 26
1
S4 methods for rbind()
Hello. I am trying to write an S4 method for rbind(). I have a class of objects called 'mdm', and I want to be able to rbind() them to one another. I do not want the method for rbind() to coerce anything to an mdm object. I want rbind(x1,x2,x1,x2) to work as expected [ie rbind() should take any number of arguments]. This is what I have so far: setGeneric(".rbind_pair",
2008 May 14
3
New blog application post slugs
Hello. I''m creating my own RESTful blog app. I am wondering about creating post slugs. I think Wordpress creates a slug at post creation time and stores the string in the database, then uses that for URLs. I read about the acts_as_sluggable strategy (http:// agilewebdevelopment.com/plugins/acts_as_sluggable) but I don''t like having a number (the ID) in the URL. Any
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
2010 Sep 24
3
boundary check
Dear R, I have a covariates matrix with 10 observations, e.g. > X <- matrix(rnorm(50), 10, 5) > X [,1] [,2] [,3] [,4] [,5] [1,] 0.24857135 0.30880745 -1.44118657 1.10229027 1.0526010 [2,] 1.24316806 0.36275370 -0.40096866 -0.24387888 -1.5324384 [3,] -0.33504014 0.42996246 0.03902479 -0.84778875 -2.4754644 [4,] 0.06710229 1.01950917
2011 Apr 22
1
indexing list elements with lapply?
Dear colleagues, I have a list that looks like what the code below produces. I need a function to go through each list element and work on the second column of each list element (the first column is irrelevant to me...if the proposed function works on the first column as a consequence of a writing something simple, that's fine). I need to index the second column of each list element to the