similar to: Lists and outer() like functionality?

Displaying 20 results from an estimated 9000 matches similar to: "Lists and outer() like functionality?"

2008 Dec 07
5
How to force aggregate to exclude NA ?
The aggregate function does "almost" all that I need to summarize a datasets, except that I can't specify exclusion of NAs without a little bit of hassle. > set.seed(143) > m <- data.frame(A=sample(LETTERS[1:5], 20, T), B=sample(LETTERS[1:10], 20, T), C=sample(c(NA, 1:4), 20, T), D=sample(c(NA,1:4), 20, T)) > m A B C D 1 E I 1 NA 2 A C NA NA 3 D I NA 3 4 C I
2009 Jul 14
2
How to provide list as an argument for the data.frame()
Hi R -users, i've a table as describe below. I'm reading the numeric value presented in this table to populate a list. #table #============ #X    A    B    C #x1    2    3    4 #x2    5    7    10 #x4    2    3    5 #============ rawData <- read.table("raw_data.txt",header=T, sep="\t") myList=list() counter=0 for (i in c(1:length(rawData$X))) {     print (i)    
2009 Oct 25
3
NULL elements in lists ... a nightmare
I can define a list containing NULL elements: > myList <- list("aaa",NULL,TRUE) > names(myList) <- c("first","second","third") > myList $first [1] "aaa" $second NULL $third [1] TRUE > length(myList) [1] 3 However, if I assign NULL to any of the list element then such element is deleted from the list: > myList$second <-
2011 Apr 03
1
Help in splitting ists into sub-lists
Dear List, Let's say I have a list whose components are 2 matrices (as exemplified in the "mylist" object below). I'd like to create a list with components being 4 matrices based on an logical index vector. is there a way to simplify what I'm doing to obtain the results in "mylist2"? I'd like something that would work on an arbitrary number of elements in
2006 Dec 05
1
problem with lists...
Hi guys, I am new to R, so sorry if my problem seems trivial. Sometimes I encounter some lists, which I cannot index their components with [ . ] For instance the prcomp() function returns a 'prcomp' object whose components are some 'lists'. the second component is a list that comtains the following: > mylist <- churn[2] > class(mylist) [1] "list" >
2003 Oct 15
1
RODBC on Mac OSX pointers?
Hi, I'm trying to get to grips with accessing my postgresql tables in R using RODBC. I have Mac OS 10.2.8 (Darwin 6.8) installed and R 1.8.0 installed from source and I have updated RODBC to 1.0-4. On the ODBC manager end, I am using OpenLink software's iODBC Administrator and I've set up a User DSN called "PostGRES" - odbctest suggests that this is functioning: >
2003 May 15
1
Compile R-1.7.0 on Mac OS 10.2.6
Hi, I can't get R-1.7.0 to compile on my Mac. Can someone give me some pointers? The machine is an 800MHz iBook running OS 10.2.6. I have installed the December 2002 Developers Tools and have installed g77, f2c and dlcompat via fink. I've checked the versions of g77 and gcc and they're both based on gcc version 3.1. I've got Apple's X11 (Beta 3). I've added /sw/bin
2005 Sep 19
3
Lists and data frames (PR#8143)
Full_Name: Frank Wagner Version: R 2.1.1 OS: Windows Submission from: (NULL) (193.174.73.34) Hi, The pdf file R-intro descripe on page 27 that lists can be extended by adding numbers. Unfortunately, it's not working ## example : # if i did not declare the variable an error occurs : object not found mylist <- list() mylist[1] <- list(value1=3, value2=5) ## Error Can you please help
2015 May 04
2
Define replacement functions
Hello I tried to define replacement functions for the class "mylist". When I test them in an active R session, they work -- however, when I put them into a package, they don't. Why and how to fix? make_my_list <- function( x, y ) { return(structure(list(x, y, class="mylist"))) } mylist <- make_my_list(1:4, letters[3:7]) mylist mylist[['x']] <- 4:6
2012 Jun 26
2
flatten lists
I am looking for a function to flatten a list to a list of only 1 level deep. Very similar to unlist, however I don't want to turn it into a vector because then everything will be casted to character vectors: x <- list(name="Jeroen", age=27, married=FALSE, home=list(country="Netherlands", city="Utrecht")) unlist(x) This function sort of does it: flatlist
2007 Oct 20
1
Getting at what a named object represents in a function...
Hi, I'm pretty new to R. I have an object (say a list) and I I have a function that I call on various columns in that list (excuse terminology if it's wrong/ambiguous). Imagine its like this (actual values are unimportant) and called mylist: >mylist A B 1 5 2 5 3 6 4 8 5 0 I have a function: foo = function(param){ #modify list A or B values depending on
2011 Apr 05
1
Help in splitting a list
Dear R users, Let's say I have a list with components being 'm' matrices (as exemplified in the "mylist" object below). Now, I'd like to subset this list based on an index vector, which will partition each matrix 'm' in 2 sub-matrices. My questions are: 1. Is there an elegant way to have the results shown in mylist2 for an arbitrary number of matrices in mylist?
2017 Jun 15
4
is.null(mylist[1]) and is.null(mylist$a) returns different values
Hi I have a list : mylist <- list( a = NULL, b = 1, c = 2 ) > mylist[1] $a NULL > is.null(mylist[1]) [1] FALSE > is.null(mylist$a) [1] TRUE why? I need to use mylist[1]
2005 Jan 30
3
trellis graphics in loops
I have this awkward problem with trellis (lattice). I am trying to generate some plots through loops but the .eps file is empty. When I generate them in a list and print them outside the loop all is fine. this is an example below:( nothing shows up in foo.eps, but all show up in foo1.eps) R vesion 2.0.1, lattice version 0.10-16, on a debian 2.6.8-1 kernel. X <- data.frame(x=rnorm(10000),
2001 Oct 18
2
Parsing for list components
How do I parse an identifier of a list component, e.g. mylist$mycomponent or mylist[[1]] ? Parse does not do the job, e.g. parse(text="mylist$mycomponent") returns an expression with just one term, instead of "mylist", "$", "mycomponent". What I need is a way to extract the list name (e.g. "mylist"), given an identifier of a component.
2010 Sep 04
4
Please explain "do.call" in this context, or critique to "stack this list faster"
I've been doing some consulting with students who seem to come to R from SAS. They are usually pre-occupied with do loops and it is tough to persuade them to trust R lists rather than keeping 100s of named matrices floating around. Often it happens that there is a list with lots of matrices or data frames in it and we need to "stack those together". I thought it would be a simple
2010 Oct 28
1
Merging nested lists
Hello All, I have multiple "list of lists" in the form of Mylist1[[N]][[K]]$Name_i, with N=1..6, K=1..3, and i=1..7. Each Name_i is a matrix. I have 30 of these objects Mylist1, Mylist2, ... I would like to merge these lists by each Name_i using rbind, but I couldn't figure out how to do it. What I want at the end is a single "list of lists", again in the form of
1999 May 09
1
subscripting in list() (PR#187)
Sorry My previous report is not detailed. In R, you will get this: > mylist <- list() > mylist[[1]] Error in mylist[[1]] : subscript out of bounds > mylist[[1]] <- c(1) Error: (list) object cannot be coerced to vector type 14 > mylist[[1]] <- c(1,2) > mylist[[1]] <- c(1) > mylist [[1]] [1] 1 I was trying to assigning c(1) to (mylist[[1]] <- c(1)) -- it seems
2010 Mar 18
1
Substitute NAs in a data frame
Excuse me for what I'm sure is a stupid beginner's question, but I've given up trying to find the answer to this question from the help, RSiteSearch, or any of the usual places. I have a list that looks like this: >myList $first [1] "--" "18" "8" "32" $second [1] "--" "--" "40" "54" I want a
2007 Aug 07
1
Naming Lists
Hi Im pretty new to R and I have run in to a problem. How do I name all the levels in this list. Lev1 <- c("A1","A2") Lev2 <- c("B1","B2") Lev3 <- c("C1","C2") MyList <- lapply(Lev1,function(x){ lapply(Lev2,function(y){ lapply(Lev3,function(z){ paste(unlist(x),unlist(y),unlist(z)) })})}) I would like to name the different