search for: list2

Displaying 20 results from an estimated 101 matches for "list2".

Did you mean: list
2012 Nov 20
1
tcl/tk problem with tklistbox,the " " character and Rcmdr.
I everyone, i have a little problem with tklistbox,the " " character and Rcmdr. Please look at this code require(tcltk) tt<-tktoplevel() levels.list2 <-tklistbox(tt,selectmode="multiple",exportselection="FALSE", height=4, yscrollcommand=function(...)tkset(levels.list2.scroll,...)) levels.list2.scroll<-tkscrollbar(tt,repeatinterval=5,command=function(...)tkyview(levels.list2,...)) tkgrid(levels.list2,levels.list2.scroll...
2010 Feb 26
3
Preserving lists in a function
...t R does not necessarily preserve the defaults if we were to input them in the form of list() when initializing the function. For example, if you feed the function codes below into R: myfunction=function( list1=list (variable1=1, variable2=2, variable3=3), list2=list (variable1="variable1", variable2="variable2", variable3="variable3"), list3=list (variable1="character", variable2=24, variable3=c(0.1,0.1,0.1,0.1), variable4=TRUE))...
2006 Feb 03
9
Because I''m very slow - trying to use console
I can''t see how to use variables so I am using console to test things out... clients table - a column named first_name My very brief console session... >> clients = Client.find_by_sql("select * from clients where first_name = FN") ActiveRecord::StatementInvalid: RuntimeError: ERROR C42703 Mcolumn "fn" does not exist Fparse_expr.c L1034
2010 Mar 15
1
rbind, data.frame, classes
Hi, This has bugged me for a bit. First question is how to keep classes with rbind, and second question is how to properly return vecotrs instead of lists after turning an rbind of lists into a data.frame list1=list(a=2, b=as.Date("20090102", format="%Y%m%d")) list2=list(a=2, b=as.Date("20090102", format="%Y%m%d")) rbind(list1, list2) #this loses the posixct class. My first question is is there a way to do this without losing the classes? data.frame(rbind(list1, list2)) data.frame(rbind(list1, list2))$a #this returns a list output and no...
2011 May 05
1
lapply, if statement and concatenating to a list
Hi R users I was wondering on how to use lapply & co when the applied function has a conditional statement and the output is a 'growing' object. See example below: list1 <- list('A','B','C') list2 <- c() myfun <- function(x,list2) { one_elem <- x cat('one_elem= ', one_elem, '\n') random <- sample(1:2,1) show(random) if(random==2) { list2 <- c(list2,one_elem) }else{ list2 } } lapply(list1,myfun,list2) Is there a way to get rid of the &...
2004 Oct 25
1
usage and behavior of 'setIs'
...t;getClass("List1")" states an explicit coerce also for these classes. I'm working with R 2.0.0 Patched (2004-10-06) on windows 2000. Thanks for your advice, Matthias # example setClass(Class = "List1", representation(List = "list")) setClass(Class = "List2", contains = "list") setIs(class1 = "List1", class2 = "List2", coerce = function(obj){ new("List2", obj at List) }, replace = function(obj, value){ obj at List <- value }) getClass("List1") # states explicit coerce for...
2011 Jan 08
3
Question on list objects
...,3)   Now I want to replicate this entire matrix 3 times and put entire result in a list object. Means, if "res" is the resulting list then I should have:   res[[1]]=dat, res[[2]]=dat, res[[3]]=dat   How can I do that in the easilest manner?   2. Suppose I have 2 list objects: list1 <- list2 <- vector("list", length=2) for(i in 1:2) {   list1[[i]] <- matrix(rnorm(15), 3)   list2[[i]] <- matrix(rnorm(15), 3)  } How can I add these 2 list objects? I have tried with just list1+list2, however it is generating some error.   Would be grateful for any help.   Thanks, [[...
2009 Apr 15
6
Intersection of two sets of intervals
...of two numbers. Is there an efficient way in R to generate the intersection of two lists of same? For concreteness: I'm representing a set of intervals with a data.frame: > list1 = as.data.frame(list(open=c(1,5), close=c(2,10))) > list1 open close 1 1 2 2 5 10 > list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10))) > list2 open close 1 1.5 2.5 2 3.0 10.0 How do I get the intersection which would be something like: open close 1 1.5 2.0 2 5.0 10.0 I wonder if there's some ready-built functionality that might help me out. I'm ne...
2011 Nov 21
1
Creating a list from all combinations of two lists
R-helpers: Say I have two lists of arbitrary elements, e.g.: list1=list(c(1:3),"R is fun!",c(3:6)) list2=list(c(10:5),c(5:3),c(13,5),"I am so confused") I would like to produce a single new list that is composed of all combinations of the "top level" of list1 and list2, e.g.: listcombo=list(list(list1[[1]],list2[[1]]),list(list1[[1]],list2[[2]] ),...,list(list1[[length(list1)]],...
2012 Apr 19
1
question about lists
I am new to R, and I have been running into the following situation when I mistype a variable name in some code: > list1 <- list( a=1, b=2 ) > list2 <- list( a=1 ) > list2$b <- list1$c > list2 $a [1] 1 I would think at the point where I am trying to reference a field called "c" -- that does not exist -- in list1, there would be an error flagged. Instead, list1$c returns value NULL, and the assignment "list2$b <-...
2011 Feb 06
1
Applying 'cbind/rbind' among different list object
Hi, I am wondering whether we can apply 'cbind/rbind' on many **equivalent** list objects. For example please consider following: > list1 <- list2 <- vector("list", length=2); names(list1) <- names(list2) <- c("a", "b") > list1[[1]] <- matrix(1:25, 5) > list1[[2]] <- matrix(2:26, 5) > list2[[1]] <- 10:14 > list2[[2]] <- 11:15 > list1 $a [,1] [,2] [,3] [,4] [,5] [1,] 1...
2012 Jul 05
2
vector entry in matix
hi, i'm trying to figure out if there's any possibility to write a whole vector into a matrix or data.frame or something like that. i don't mean transormation. Here an example: [,1] [,2] [1,] "a" "d" [2,] "b" "e" [3,] "c" "f" where e.g. a is a<-c(0,1) vector of length 2, b a vector of length 4,... (i know that
2006 Jun 26
0
sortables and accept question
i did some searching through the archives and didn''t really find an answer to my question, so i''m going to just ask it. i have a situation where there are 3 sortable lists. list1, list2, and list3 i need list2 to accept divs from all 3 lists, but list1 and list3 to only accept divs from the list1 and list3 i''ve added two classes to the divs in my sortables: .rail for list1 and list3, and .center for list2. i then added the appropriate accept options to my sortables co...
2007 Oct 15
1
The "condition has length > 1" issue for lists
I have the following code: list1 <- list() for (i in list.files(pattern="filename1")){ x <- read.table(i) list1[[i]] <- x } list2 <- list() for (i in list.files(pattern="filename2*")){ x <- read.table(i) list2[[i]] <- x } anslist <- vector('list', length(list1)) for(i in 1:length(list1)) if (list1[[i]] & list2[[i]] >1) anslist[[i]] <- list1[[i]] - list2[[i]] That, if at least o...
2009 Sep 29
1
Comparing vectors from lists
...did not solve my problem properly! I have to compare the values of two lists of 250 numbers as a result of using the ?by function! List1 of 250  $ 0   : num [1:28] 22 11 31...  $ 1   : num [1:15] 12 14 9 ... .. .. ..  - attr(*, "dim")= int 250  - attr(*, "dimnames")=List of 1 List2 of 250  $ 0   : num [1:24] 20 12 22...  $ 1   : num [1:17] 11 12 19 ... .. .. ..  - attr(*, "dim")= int 250  - attr(*, "dimnames")=List of 1 So I want to compare each vector of 250 from list1 with all other 250 vectors in list2! Is this doable (list1$0 with list2$0, list2$1 ASO...
2011 Feb 08
2
Extrcat selected rows from a list
Hi, I have two lists 1) List1- 30,000 rows and 104 columns 2) List2- a list of 14000 selected rownames  from List 1 Now, I want to extract all the 104 columns of List1  matching with the 14000 selected rownames from List2.  Psedocode will be something like this: match rownames(List2) with rownames(List1) extract selected matched 104 coloumns from (List1) strore...
2006 Feb 02
12
basic ''find'' question
I am struggling to understand the methodology here... I have a find.rhtml <%= start_form_tag :action => ''list2'', :first_name = client %> <%# render :partial => ''form'' %> <p><label for="client_first_name">First name</label><br/> <%= text_field ''client'', ''first_name'' %></p> <%=...
2004 Jun 23
5
assigning from multiple return values
I know that if I have a function that returns multiple values, I should do return(list(foo, bar)). But what do I do on the recieving end? fn <- function(x) { return(list(foo, bar)) } I know that at this point I could say values.list <- fn(x) and then access values.list[1] values.list[2] But that's hideous. I'd rather be able to say something like list(local_foo, local_bar)
2010 Jan 28
2
Data frame of different sized lists in a function call
I'm hoping to get some "best practice" feedback for constructing a function call which takes an undefined set of DIFFERENT length vectors -- e.g. say we have two lists: list1=c(1:10) list2=c(2:4) lists = data.frame(list1,list2) coerces those two to be the same length (recycling list2 to fill in the missing rows) -- what is a quick way of having each of those lists retain their original lengths? my function ultimately should look like: myfunction = function(lists) { ... } I&...
2006 Feb 03
4
contoller code mysteries
In my controller...this code works def list2 first_name = params[:client][:first_name] @myclients = Client.find(:all, :conditions => ["first_name = :first_name", {:first_name => first_name}]) end this code doesn''t... def list2 first_name = params[:client][:first_name] if first_name s...