Displaying 20 results from an estimated 500 matches similar to: "Extrcat selected rows from a list"
2010 Feb 26
3
Preserving lists in a function
Dear R users,
A co-worker and I are writing a function to facilitate graph plotting in R. The function makes use of a lot of lists in its defaults.
However, we discovered that 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
2011 Apr 12
2
Merge matrix
I have two matrices A and B
> dim (A)
[1] 30380 104
> dim(Bt)
[1] 30380 63
I want to combine both A and B to matrix C where
>dim(C)
[1] 30380 167
How do I do that ?
Regards,
Pankaj Barah
Department of Biology,
Norwegian University of Science & Technology (NTNU)
Realfagbygget, N-7491
[[alternative HTML version deleted]]
2011 Apr 13
1
Extracting selected rows from a matrix to a submatix
I have a matrix M
> dim(M)
[1] 30380 561
I have another list L contains , that contains some row names of matrix M
str (L)
chr [1:21037]
Now I want to extract the submatrix subM (21037 , 561) from the matrix M by matching the rownames (M) to the 21037 rownames o f L
How do I do that ?
Thanks and regards,
Pankaj Barah
Pankaj Barah Department of Biology
Norwegian University
2004 Jun 02
1
How to iterate through two objects of class "list" fast?
Hi!
I have 2 list objects
One list contains the data (list1) the second list2 contains the e.g linear model for each element of list 1.
list2 <- lapply(list1,mylm,response) I obtain list 2 by something like this.
now I have a function myfunc which takes an element from list1 and the coresponding element from list2 does something and ....
list3[[x]] <- myfunc(list1[[x]],list2[[x]])
Until
2005 Jul 21
1
again, a question between R and C++
Dear R Users,
I want to make a call from R into C++. My inputs are List1, List2, List3,
IntegerID. The amount of elements of the lists and their type depend on
IntegerID. Typical elements of a given list can be vectors, doubles, and
even other lists. I want to return also a list (whose nature will depend
also, possibly, on IntegerID).
What I want to do is to call these 4 inputs from C++ and then
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
2002 Oct 14
1
Question: concatenating lists
Dear R users,
I have the following problem. I have a number of lists with identical
structure. Each component is a vector, matrix or array, but components of
different lists may be of different size. How do I combine the lists to get
a new list such that each component of this list contains the components of
the individual lists?
An example may explain most clearly what I need.
Suppose I have
2009 Oct 12
1
Creating object referant from argument name
Hi all. I'd like to define an object within a function based on an argument
to that function.
Specifically, I've got:
do.something<-function(input){
id<-substring(input,3,3)
j<-list1
if(id==2)j<-list2
if(id==3)j<-list3
if(id==4)j<-list4
...}
Instead of all these if() arguments, I was hoping to use something like:
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
2010 Nov 29
1
Extracting selected rows from a matrix
Hi,
I have matrix of 104 columns and 30000 rows (Each Row has rowname).
I have 13 different list of selected rownames (character) say 1000 each. Now I want to extract the all the columns according to the rownames in each the list.
How can I do that in R ?
1 ) For a single list
2) For all the 13 list at a time
Regards,
Pankaj Barah
Department of Biology,
Norwegian University of
2013 Sep 21
1
Psedocode in R
I have never written my own function, psedocode, in R. Can anyone show me
how to write a psedocode if I want to return, say, like mode or class...?
Thanks
[[alternative HTML version deleted]]
2007 May 16
2
substitute "x" for "pattern" in a list, while preservign list "structure". lapply, gsub, list...?
I am experimenting with some of the common r functions.
I had a question re:using "gsub" (or some similar functions) on the contents of a list.
I want to design a function that looks at "everything" contained din a list, and anytime it finds the text string "pattern" replace it with "x". I also wish to preserve the "structure" of the original
2006 Mar 03
13
Listing help
Hi,
I''ve created a Rails application and am having a problem listing by a
particular category in an associated table. I followed the instructions
found at the O''Reilly tutorial
(http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) but have
not had success. Can anyone please outline a better set of instructions
than in the "Showing Recipes in a
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)
2012 Oct 10
7
multiple t-tests across similar variable names
Hi everyone-
I have a dataset with multiple "pre" and "post" variables I want to compare. The variables are named "apple_pre" or "pre_banana" with the corresponding post variables named "apple_post" or "post_banana". The variables are in no particular order.
apple_pre orange_pre orange_post pre_banana apple_post post_banana
person_1
2011 Dec 28
3
transparency using plot+points with sp classes
How can I make one point graphics with transparency
These are all sp classes:
plot(polygons_area,axes=TRUE,asp=1.5,main="Title",xlab="Latitude",
ylab="Longitude")
points(observations2000,type = "p",pch=21,col="green")
points(observation1999,type = "p",pch=21,col="blue")
points(reference.points,type =
2012 Aug 01
4
apply function over same column of all objects in a list
Hello. Please forgive me if this problem has already been posted (and solved)
by someone else ... I can't find it anywhere though it seems so very basic.
Here it is:
I have a list comprised of several matrices, each of which has two columns.
> list
[[1]]
[,1] [,2]
[1,] 1 3
[2,] 2 4
[[2]]
[,1] [,2]
[1,] 5 7
[2,] 6 8
[[3]]
[,1] [,2]
2004 Feb 04
5
Date Time Conversion problems...
At one time (version 1.7), the code below used to work for converting and
extracting based on the Date Time. In version 1.8.1, something changed I
know, but I cannot for the life of me figure out what...
Data:
UserName,RequestDate,PO,OrderDate,ExpDelivDate,Vendor,Total
"Woody, Jim",12/19/2002,AP15063,1/7/2003,2/10/2003,Ames ,8570
"Harrold,
2014 Mar 06
1
Create dataframe in C from table and return to R
Hi ,
I am trying to create a dataframe in C and sebd it back to R. Can anyone
point me to the part of the source code where it is doing , let me explain
the problem I am having .
--------------------------------------------------------------------
My simple implementation is like this
SEXP formDF() {
SEXP dfm ,df , dfint , dfStr,lsnm;
char *ab[3] =
2009 Apr 15
6
Intersection of two sets of intervals
Hi,
Algorithm question: I have two sets of "intervals", where an interval is
an ordered pair [a,b] 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