[R] for loop and if problem

Charles C. Berry cberry at tajo.ucsd.edu
Tue Jan 6 20:17:22 CET 2009


On Tue, 6 Jan 2009, Sake wrote:

>
> Hi,
>
> I'm heaving difficulties with a dataset containing gene names and positions
> of those genes.
> Not such a big problem, but each gene has multiple exons so it's hard to say
> where de gene starts and where it ends. I want the starting and ending
> position of each gene in my dataset.


This looks like a minor variant on the 'first and last observation' thread 
from a few days ago:

 	http://thread.gmane.org/gmane.comp.lang.r.general/135411

to which several useful solutions were posted.

I suggest you read that thread and try to adapt what is there to your 
situation.

If this does not get you all the way there, when you post back it will 
help to "provide commented, minimal, self-contained, reproducible code".

What you have given us is not quite there.

Here is a start:

  data <-
 	read.csv("http://www.nabble.com/file/p21312449/genlistchrompos.csv",sep=';')

and note that

> colnames(data)
  [1] "Query"             "Gene"              "Chrom"             "Strand"            "Accession"
  [6] "Exon"              "Exon_Start.Chr."   "Exon_Stop.Chr."    "Exon_Start.Trans." "Exon_Stop.Trans."

does not include anything like "Column 'B'", so refer to those column 
names if you need further help after studying the thread above.

HTH,

Chuck

> Attached is the dataset:
> http://www.nabble.com/file/p21312449/genlistchrompos.csv genlistchrompos.csv
> Column 'B' is the gene name, 'G' is the starting position and 'H' is the
> stop position.
> You can load the dataset by using: data<-read.csv("genlistchrompos.csv",
> sep=";")
> I hope someone can help me, it's giving me headaches for a week now:-((.
>
> Thanks!
>
> -- 
> View this message in context: http://www.nabble.com/for-loop-and-if-problem-tp21312449p21312449.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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




More information about the R-help mailing list