similar to: how to search a list that contains multiple dissimilar vectors?

Displaying 20 results from an estimated 2000 matches similar to: "how to search a list that contains multiple dissimilar vectors?"

2011 Nov 08
1
passing dataframe col name through cbind()
Hi all --- I note that the column name of the first column in a dataframe does not necessarily get passed on when using cbind (example below)? I'm looking for help in clarifying why this behavior occurs, and how I can get all col names, including the first, passed on to the result?while I suspect it's obvious and documented to the cognoscenti, it's puzzling me? Many thanks for any
2012 Jan 10
2
short-hand to avoid use of length() in subsetting vectors?
Hi-- I suspect this is a frequently considered (and possibly asked) question, but I haven't thus far found an answer: For slicing a vector with x[?], is there a symbol for length(x)? I'm seeking a short-hand for referring to the length of vector one is trying to index. E.g., for a data.frame, say, > test.frame <-data.frame(matrix(c(1:100),ncol=10,nrow=10,byrow=T)) >
2008 Aug 21
1
pnmath compilation failure; dylib issue?
(1) ...need to speed up a monte-carlo sampling...any suggestions about how I can get R to use all 8 cores of a mac pro would be most useful and very appreciated... (2) spent the last few hours trying to get pnmath to compile under os- x 10.5.4... using gcc version 4.2.1 (Apple Inc. build 5553) as downloaded from CRAN, xcode 3.0... ...xcode 3.1 installed over top of above after
2004 Jan 15
3
Extracting multiple elements from a list
For a long time I've wanted a way to conveniently extract multiple elements from a list, which [[ doesn't allow. Can anyone suggest an efficient function to do this? Wouldn't it be a sensible addition to R? For example, alist <- list() alist[[1]] <- list() alist[[1]]$name <- "first" alist[[1]]$vec <- 1:4 alist[[2]] <- list() alist[[2]]$name <-
2003 Nov 13
1
Can't get Sweave syntax highlighting with Emacs
I can't get Emacs to automatically do syntax highlighting of Sweave files. I have followed Friedrich's suggestion for code to insert into my .emacs file. The complete section from my .emacs file is given below. When I load a *.Snw file, font is white until I press M-x, then the first code and document chunks get highlighted, but not the rest of the file. Latex and Noweb menus are
2009 Dec 30
1
What am I doing wrong in my loops?
Dear kind list people: I have the following code: >hours [1] "0" "1" "2" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" [16] "16" "17" "18" "19" "20" "21" "22"
2008 Oct 01
2
Bug or feature with finding a list element?
This seems odd. When I try to look up a list element which has a space in the name using just the first word (i.e. no spaces), it will sometimes return the element with a space in the name and sometimes it will return NULL. Try this: alist <- list( 'hello'=10, bye=20, 'hello world'=30, 'goodbye world'=40, 'hi world'=50, 'goodbye foo'=60, 'goodbye
2006 Nov 06
5
alist()
In trying to get NULL members into a list, I found out about alist(). x<-alist() x$one<-1 x$two<-NULL but x$two doesn't exist. It seems, though, that an alist is just a list. How can one put NULL members into a list?
2009 Nov 19
4
Is there an variant of apply() that does not return anything?
There are a few version of apply() (e.g., lapply(), sapply()). I'm wondering if there is one that does not return anything but just silently apply a function to the list argument. For example, the plot function is applied to each element in 'alist'. It is redundant to return anything from apply. apply(alist,function(x){ plot each element of alist})
2009 Oct 01
1
inverse currying
Dear list, I have the following function, sugar = function(fun, id = "id"){ ff <- formals(fun) if( id %in% names(ff)) stop("id is part of args(fun)") formals(fun) <- c(unlist(ff), alist(id=)) fun } which one may use on a function foo, foo = function(x){ x } sugar(foo) # results in the extended closure, function (x, id) { x } Its limitation (other
2001 Oct 16
4
Assignment of structures on a given environment
Hi, In order to avoid deep copies by passing large arguments to functions or returning values, I'm trying to do the assignment of variables in a given environment. The problem is when I try to assign a structure: a list for example. If I have: ind <- c("a","b") my idea is doing something like l <- alist() l[ind] <- as.list(c(20,40)) in a given
2002 Feb 27
1
rsync error: error in rsync protocol data stream (code 12) at io.c(140)
Hello, I am getting the following error: | rsync: open connection using rsh conn /usr/bin/rsync --server --sender -v . "/home/andrewm/test-rsync/tree/*" | large_file2 | write failed on large_file2 : Success:06 | rsync error: error in file IO (code 11) at receiver.c(271) | rsync: connection unexpectedly closed (201 bytes read so far) | rsync error: error in rsync protocol data stream
2005 Feb 28
2
Changing function arguments to NULL
I'm trying to build a recursive set of functions that take a set of arguments, change some of the arguments and recursively call the same (or different) function. For example here's a stupid recursive counting function that prints back all integers from x to 0 (and ignores arguments y and z) cnt <- function(x, y, z) { stopifnot(is.numeric(x)) print (x) recursionFUN <-
2006 Mar 14
3
rails on emacs - need a working .emacs sample
I would like to hear from some one who has ecb, multiple modes with ruby mode + html mode, rails mode all working together and playing well. I had ecb working with Ruby syntax highlighting. That was a no-brainer since I just had to apt-get them on my Debian Sarge box. It got a bit more comlex after I got most of the .el files in the articles http://www.emacswiki.org/cgi-bin/emacs/RubyOnRails
2010 Feb 24
1
Optimise huge data.frame construction
I have data for different items (ID) in a database. For each ID I have to get: - Timestamp of the observation (timestamp); - numerical value (val) that will be my response variable in some kind of model; - a variable number of variables in a know set (if value for a specific variable is not present in DB it is 0). To get to the above mentioned values I have to cycle
2009 Mar 22
2
Following progress in a lapply() function
Dear all, I am processing a very long and complicated list using lapply through a custom function and I would like to generate some sort of progress report. For instance, print a dot on the screen every time 1000 item have been process. Or even better, reporting the percent of the list that have been process every 10%. However, I can't seem to figure out a way to achieve that. For instance,
2004 Feb 26
2
Sweave and Xemacs on Windows2000?
Hallo! Trying to configure Xemacs to work with .snw files on windows 2000. Tried to do it how it is described in the FAQ for Sweaves. When starting xemacs with and Snw file *ESS* buffer contains hundrets of lines and the few last ones. (ess-loop-timeout . 500000) (inferior-ess-primary-prompt . ^) (inferior-ess-secondary-prompt . ^) (comint-use-prompt-regexp-instead-of-fields . t)
2007 Oct 16
2
How to speed up multiple for loop over list of data frames
Hi there, I have a multiple for loop over a list of data frames for ( i in 1:(N-1) ) { for ( j in (i+1):N ) { for ( p in 1:M ) { v_i[p] = alist[[p]][i,"v"] v_j[p] = alist[[p]][j,"v"] } rho_s = cor(v_i, v_j, method = "spearman") rho_p = cor(v_i, v_j, method = "pearson"
1999 Mar 29
3
problems with formals and get (PR#151)
With 0.63.3, try test <- function(){ fn <- function(a) print("hello") print(is.function(fn)) print(names(formals("fn")))} test() if fn is not quoted in the last line of test, it works properly. test <- function(){ fn <- function() print("hello") formals(fn) <- alist(a=,b=) return(fn)} formals(test()) now try with line 3 of test changed to
2012 Oct 04
2
How to build a list with missing values? What is missing, anyway?
This is tangentially related to Hadley's question. Suppose I'm building a function programmatically; I have assembled an expression for the body and I know the names of the arguments it wants to take. Suppose I have some convenience function such that writing make_function(alist(a=, b=), quote(a+b), environment()) is equivalent to writing function(a,b) a+b So how do I make the