similar to: vectorial search for elements with certain attributes

Displaying 20 results from an estimated 10000 matches similar to: "vectorial search for elements with certain attributes"

2011 Jul 29
2
special recursive filter
Hi, I have a question about a special recursive filter problem. What I have: - given variables: x: time series with rather randomly occuring '0' and '1' wait: non negative integer - a working but ineffectiv implementation (see below) How the implementation works (what I want): The filter should drill holes of distance 'wait' between the '1' in x, e.g. x =
2010 Jul 29
1
Using 'dimname names' in aperm() and apply()
I think that the "dimname names" of tables and arrays could make aperm() and apply() (and probably some other functions) easier to use. (dimname names are, for example, created by table() ) The use would be something like: -- x <-table( from=sample(3,100,rep=T), to=sample(5,100,rep=T)) trans <- x / apply(x,"from",sum) y <- aperm( trans,
2000 Sep 23
3
bug in apply with median
I have found a problem in R version 1.1.1 when using apply with the median function. The problem can be illustrated with the following data matrix: X1 X2 X3 1 2 3 4 5 6 7 8 NA Enter this data matrix as X and then try apply(X,2,median,na.rm=T) The problem here is that the median function returns a named scalar if the number of observations is odd, but returns an
2005 Aug 22
2
problem building dendrograms to use with heatmap()
Hi, I'm trying to build dendrograms to pass to heatmap(). The dendrograms I build plot properly, but when I pass them to heatmap() I get the error message "row dendrogram ordering gave index of wrong length" (see output log below). I looked in the code of heatmap() and saw that the error was due to a NULL return value from order.dendrogram(), which in turn got a NULL return value
2007 May 23
1
Readline - wait for user input
Hi, I've seen various posts on this question, but still can't get the code right. If I run the following code one line at a time, it works fine. If I run it together as a block, however, it doesn't wait for the input and gives an error. There must be a way to have are pause/wait for an answer, but I can't seem to find it. Thanks! J Code: choosefunction <-
2010 Mar 29
1
xyplot second y-xis and legend
Dear list, I try to set a secondary y-axis in a lattice xyplot. This works. However, I am unable to set a proper legend/key together with the 2nd y-axis under general xyplot procedures. See example below. The combination of the par.settings with simpleTheme and other settings seems to go wrong. I couldn't find a solution from previous topics. Any suggestions? thanks in advance! Robbert
2011 Apr 26
7
Second largest element from each matrix row
Hi, I need to extract the second largest element from each row of a matrix. Below is my solution, but I think there should be a more efficient way to accomplish the same, or not? set.seed(1) a <- matrix(rnorm(9), 3 ,3) sec.large <- as.vector(apply(a, 1, order, decreasing=T)[2,]) ans <- sapply(1:length(sec.large), function(i) a[i, sec.large[i]]) ans Thanks in advance for your
1999 Nov 11
2
dimname'less array breaks apply (PR#318)
<<insert bug report here>> > apply(array(1:20,c(2,2,5)),2:3,function(x) x) Error: length of dimnames must match that of dims > Changing: dimnames = if (is.null(dn.ans)) list(ans.names, NULL) else c(list(ans.names), dn.ans) To: dimnames = if (length(dn)==0) NULL else if (is.null(dn.ans)) list(ans.names, NULL) else c(list(ans.names), dn.ans) seems to fix this. Chuck
2011 Sep 09
4
Very simple question about list components
I have a list 'ans' from the following code: tt <- rnorm(50) rr <- rnorm(50) ans <- lm(rr~tt) ans[1] is "$coefficients", ans[2] is "$residuals", ans[3] is "$effects", ... and so on up to ans[12]. Is there an easy way to display just these names and not the data they contain? I thought I saw my advisor type "ans$" and they were displayed,
2011 Oct 05
4
SPlus to R
I'm trying to convert an S-Plus program to R.  Since I'm a SAS programmer I'm not facile is either S-Plus or R, so I need some help.  All I did was convert the underscores in S-Plus to the assignment operator <-.  Here are the first few lines of the S-Plus file:   sshc _ function(rc, nc, d, method, alpha=0.05, power=0.8,              tol=0.01, tol1=.0001, tol2=.005, cc=c(.1,2),
2008 Apr 15
1
by inconsistently strips class - with fix
summary: The function 'by' inconsistently strips class from the data to which it is applied. quick reason: tapply strips class when simplify is set to TRUE (the default) due to the class stripping behaviour of unlist. quick answer: This can be fixed by invoking tapply with simplify=FALSE, or changing tapply to use do.call(c instead of unlist executable example:
2005 Jun 01
2
A suggestion to improve ifelse behaviour with vector yes/noarguments
> Thomas Lumley wrote: > > On Tue, 31 May 2005, Duncan Murdoch wrote: > > > > > >>M??kinen Jussi wrote: > >> > >>>Dear All, > >>> > >>>I luckily found the following feature (or problem) when tried to > >>>apply > >>>ifelse-function to an ordered data. > >>> > >>> >
2009 Jun 18
1
lattice logaritmic scale (basis "e" ), rewriting labels using xscale.component
Hi there, sorry for troubling everybody once again, I've got a problem rewriting Sarkar's function for rewriting the tick locations in a logaritmic way (s. http://lmdvr.r-forge.r-project.org/code/Chapter08.R): His example works for log 2 but I need log e (natural logarithm). My problem is that if I replace 2 with "e" (using paste()), I get the error message that the location
2012 Sep 01
1
Vectorial analogue of all.equal()?
Greetings All. Once again, I am probably missing something fairly accessible, but since I can't find it I'd welcome advice! I have a dataframe derived from a text file of data in tabular format. For one of the variables, say X, I want to select the subsets which in which X equals a particular value. Such values are given in the text file like: 2.3978953, and each such value will occurr
2008 Jul 07
2
A shorter version of ".Last.value"?
Hi, There is an object, ".Last.value" to which the result of the most recent evaluation is assigned. This is similar to "ans" in Matlab. In Matlab "ans" can be very useful and time-saving, but typing the larger R version is somewhat clunky and takes away from the usefulness. Is it possible to reassign '.Last.value' to something simpler, like
2014 Jun 24
2
using C code to create data frame but always return as list
there is my code,  expect return value  is a data frame but R say it is list: SEXP Julia_R_MD_NA_DataFrame(jl_value_t* Var) {  SEXP ans,names,rownames;  char evalcmd[4096];  int i;  const char* dfname="DataFrameName0tmp";  jl_set_global(jl_main_module, jl_symbol(dfname), (jl_value_t*)Var);  //Get Frame cols   sprintf(evalcmd,"size(%s,2)",dfname);  jl_value_t*
2004 Feb 11
1
.Call setAttrib(ans,R_DimSymbol,dim); Crashes.
Hi! I want to return a matrix. The code does the R interfacing. This version does it fine. SEXP ans,dim; PROTECT(ans = NEW_NUMERIC(count*2)); memcpy(NUMERIC_POINTER(ans),result,count*sizeof(double)); memcpy(&(NUMERIC_POINTER(ans)[count]),occur,count*sizeof(double)); /** PROTECT(dim=NEW_INTEGER(2)); INTEGER_POINTER(dim)[0]=2; INTEGER_POINTER(dim)[1]=count;
2013 Feb 27
1
lattice xyplot point labelling
This is my reproducible example tv.ms<-structure(list(inq = structure(4:17, .Label = c("D4", "D5", "D6a", "D6b", "D6c", "D7", "D8", "F4", "F5a", "F5b", "F6a", "F6b", "F6c", "F6d", "F7a", "F7b", "F8"), class =
2012 Aug 04
1
how to coerce the result of sweep to be an array if result of FUN is a string?
Hi, I would like to use sweep to "sweep out" proportions and confidence intervals for an array, however when I supply a function which returns a string (containing something like "9% (3-18%)") I get back a list instead of an array, here is a simplified example: # example showing that sweep does not return an array with same dimensions as STATS as advertised
2012 Nov 12
1
R lmer & SAS glimmix
Hi, I am trying to fit a model with lmer in R and proc glimmix in SAS. I have simplified my code but I am surprised to see I get different results from the two softwares. My R code is : lmer(y~age_cat + (1|cat),data=fic,family=binomial(link = "logit"), NaGQ=1) My SAS code is : ods output Glimmix.Glimmix.ParameterEstimates=t_estimates; proc glimmix data=tab_psi method=laplace;