Displaying 20 results from an estimated 5000 matches similar to: "Question about managing searching path"
2004 Nov 01
5
make apply() return a list
Hi,
I have a dataframe (say myData) and want to get a list (say myList) that
contains a matrix for each row of the dataframe myData. These matrices are
calculated based on the corresponding row of myData. Using a for()-loop to do
this is very slow. Thus, I tried to use apply(). However, afaik apply() does
only return a list if the matrices have different dimensions, while my
matrices have
2018 Apr 15
4
Adding a new conditional column to a list of dataframes
Hi all ..,
I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes.
When I extract one dataframe and apply my code it works very well as follows :-
First suppose this is my first dataframe in the list
> OneDF <- Mylist[[1]]
> OneDF
ID Pdate
2018 Apr 15
0
Adding a new conditional column to a list of dataframes
> On Apr 15, 2018, at 4:08 AM, Allaisone 1 <Allaisone1 at hotmail.com> wrote:
>
>
> Hi all ..,
>
>
> I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes.
>
>
> When I extract one dataframe and apply my code it works very well as
2006 Sep 21
1
How to generating diagnal blocks ?
Hi,
I am trying to creat a matrix with diagnal blocks, say, I have a matrix X of any dimension (nxm) ,and would like to have:
X
X
X
2005 Nov 29
1
Indexing variables within lapply?
Hello
I am using R 2.2.0 with Windows XP.
I've got a five element list object, each element containing two
dataframes of equivalent size.
> str(mylist)
List of 1
$ data1:List of 2
..$ data1a :`data.frame': 77 obs. of 63 variables:
.. ..$ var1 : num [1:77] 0.41375 0.00056 1.43040 1.43528 0.61730 ...
.. ..$ var2 : num [1:77] 1.154 1.686 0.673 0.800 0.760 ...
..
2007 Jan 14
1
Questions about paste and assign
Hi,
I would like to assign a value to a member b of the list a in position 3, by calling:
assign( target, 2.34, 3)
My question is what the "target" should be. I tried target <- paste("a", $, "b") and something else,
but haven't got the right answer yet.
BTW, if I attached a list named
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
2009 Nov 02
3
partial matching with grep()
dear all,
This is a probably a silly question.
If I type
> grep("x",c("a.x" ,"b.x","a.xx"),value=TRUE)
[1] "a.x" "b.x" "a.xx"
Instead, I would like to obtain only
"a.x" "b.x"
How is it possible to get this result with grep()?
many thanks for your attention,
best,
vito
--
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 <-
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
2008 Jun 30
2
difference between MASS::polr() and Design::lrm()
Dear all,
It appears that MASS::polr() and Design::lrm() return the same point
estimates but different st.errs when fitting proportional odds models,
grade<-c(4,4,2,4,3,2,3,1,3,3,2,2,3,3,2,4,2,4,5,2,1,4,1,2,5,3,4,2,2,1)
score<-c(525,533,545,582,581,576,572,609,559,543,576,525,574,582,574,471,595,
557,557,584,599,517,649,584,463,591,488,563,553,549)
library(MASS)
library(Design)
2004 May 10
2
Lists and outer() like functionality?
Hi,
I'm have a list of integer vectors and I want to perform an outer()
like operation on the list. As an example, take the following list:
mylist <- list(1:5,3:9,8:12)
A simple example of the kind of thing I want to do is to find the sum
of the shared numbers between each vector to give a result like:
result <- array(c(15,12,0,12,42,17,0,17,50), dim=c(3,3))
Two for() loops is the
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
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
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