Re: [R] help on list comparison

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Wed, 02 Jul 2008 17:38:24 -0400

Dear Ramya,

Try

# Gene list with 3 genes
genelist=list(gene1=rnorm(100),gene2=rnorm(100),gene3=rnorm(100)) genelist

# Map file with 50 genes
mapfile=data.frame(gene=paste("gene",1:50,sep=""),coordinate=runif(50,61800000,63000000)) mapfile

# Genes in genelist (names)
NAMES=names(genelist)
NAMES # Which genes' names of genelist are in mapfile which(NAMES%in%mapfile[,1])

# What are the names?
NAMES[which(NAMES%in%mapfile[,1])]

# mapfile information for those genes
mapfile[which(NAMES%in%mapfile[,1]),]

HTH, Jorge

On Wed, Jul 2, 2008 at 11:37 AM, Rajasekaramya <ramya.victory_at_gmail.com> wrote:

>
> hi
>
> I want to compare two list by its names and get the values of that list.
>
> can anybody let me know the syntax of comparing the list by their names
> using a for loop
> c.genes<- list()
> for(i in 1:100)
>
> c.genes[[1]]<- geneset(which(geneset == tobecampared[i]))
>
> }
>
> here geneset is a list and also tobecampared is a list
>
>
> Thank you
>
> Ramya
> --
> View this message in context:
> http://www.nabble.com/help-on-list-comparison-tp18240445p18240445.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jul 2008 - 21:57:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jul 2008 - 22:31:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive