Re: [R] add=TRUE function not working

2009-10-11 Thread Mehdi Khan
Okay it worked, is there any way I can define the scale though?

thanks a lot!

On Sun, Oct 11, 2009 at 6:08 PM, Daniel Malter  wrote:

> x1=rnorm(100)
> x2=rnorm(100)
> e=rnorm(100)
> y=1.5*x1+x2+e
>
> plot(y~x1,pch=1,xlim=c(min(x1,x2),max(x1,x2)))
> points(y~x2,pch=16)
>
> HTH
> Daniel
>
>
> -
> cuncta stricte discussurus
> -
>
> -Ursprüngliche Nachricht-
> Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
> Auftrag von Mehdi Khan
> Gesendet: Sunday, October 11, 2009 8:52 PM
> An: r-help@r-project.org
> Betreff: [R] add=TRUE function not working
>
> Hey everybody, I have a matrix with three columns.
>
> I want to plot two columns (independent variable) against one column (the
> defendant). This is my code and the error associated with it:
>
> plot(p, q, data=columns)
>
> > plot(pprime,q, add=TRUE)
> Warning messages:
> 1: In plot.window(...) : "add" is not a graphical parameter
> 2: In plot.xy(xy, type, ...) : "add" is not a graphical parameter
> 3: In axis(side = side, at = at, labels = labels, ...) :
>  "add" is not a graphical parameter
> 4: In axis(side = side, at = at, labels = labels, ...) :
>  "add" is not a graphical parameter
> 5: In box(...) : "add" is not a graphical parameter
> 6: In title(...) : "add" is not a graphical parameter
>
> How do I resolve this problem?
>
> thanks!
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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@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.


[R] add=TRUE function not working

2009-10-11 Thread Mehdi Khan
Hey everybody, I have a matrix with three columns.

I want to plot two columns (independent variable) against one column (the
defendant). This is my code and the error associated with it:

plot(p, q, data=columns)

> plot(pprime,q, add=TRUE)
Warning messages:
1: In plot.window(...) : "add" is not a graphical parameter
2: In plot.xy(xy, type, ...) : "add" is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
  "add" is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
  "add" is not a graphical parameter
5: In box(...) : "add" is not a graphical parameter
6: In title(...) : "add" is not a graphical parameter

How do I resolve this problem?

thanks!

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] fitting a linear model line through srip plot

2009-08-27 Thread Mehdi Khan
Nevermind, I figured another way through the plot command. thanks :)

On Thu, Aug 27, 2009 at 7:16 AM, Mehdi Khan  wrote:

> I am creating a strip plot from the lattice library, and would like the
> display to also have the linear model line through it.  How would I do that?
>
>  stripplot(jitter(vs30)~tif.vs30, data=rastermodel, xlim=c(150,600),
> ylim=c(0,1000))
> yonglm<-lm(vs30~tif.vs30, data=rastermodel)
>
> Thanks!
>

[[alternative HTML version deleted]]

__
R-help@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.


[R] fitting a linear model line through srip plot

2009-08-27 Thread Mehdi Khan
I am creating a strip plot from the lattice library, and would like the
display to also have the linear model line through it.  How would I do that?

 stripplot(jitter(vs30)~tif.vs30, data=rastermodel, xlim=c(150,600),
ylim=c(0,1000))
yonglm<-lm(vs30~tif.vs30, data=rastermodel)

Thanks!

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Problem merging two data frames

2009-08-26 Thread Mehdi Khan
Note: even if I say by=c("LON", "LAT"), it doesn't work, suggesting that
number storage isn't the problem

On Wed, Aug 26, 2009 at 6:19 PM, Mehdi Khan  wrote:

> Hello everyone,
>
> Merging two dataframes should be easy.  However when I try to merge, R
> doesn't recognize identical values, even if I am doing it by values that
> have no decimals.
>
> willclayong:
>vs30  LON LAT  Net  X wills.cat wills.vs30 clahan.cat clahanvs30
> PolyID.wills PolyID.clahan tif.cat STA ELEVATION tif.vs30
> 1 338.539 -3849590 4319319   2 D301  D
> 377 1958  1942   1 150NA  519
> 2 712.822 -3849590 4319319   3 D301  D
> 377 1958  1942   1 479NA  519
> 3 477.652 -3836584 4288164  10 C464  C
> 489 1194  9353   3 148NA  547
> 4 513.703 -3836575 4287739  11 C464  C
> 489 1194  9353   3 485NA  547
> 5 477.652 -3835886 4289120  12 C464  C
> 489 1194  9353   7 147NA  388
>
> wald:
>
> > wald_ol_sta[1:10,]
> X Wald.vs30  STAvs30  LON LAT
> 1   1   434.417 1502 274.500 -3077929 3759564
> 2   2   378.049 NEE2 363.000 -3086165 3718184
> 3   3   196.848  EMS 336.000 -3143337 3500449
> 4   4   557.625 1498 659.600 -3103738 3871531
> 5   5   263.878 1497 274.500 -3102944 3878068
> 6   6   374.898 1499 274.500 -3109753 3858460
> 7   7   150.000  230 274.500 -3154048 3482703
> 8   8   248.342 1205 207.469 -3153294 3497116
> 9   9   422.256 1495 338.600 -3097854 3990339
> 10 10   322.540 1496 274.500 -3115300 3863905
>
> willsclayongwald<-merge(wald_ol_sta, willsclayong, by=c("LON", "LAT",
> "STA", "vs30"))
>
> returns nothing... if I modify the previous script by adding "all=TRUE", I
> get this:
>
>
> lsclayongwald[1:10,]
> LON LAT STAvs30  X.x   Wald.vs30  Net X.y wills.cat
> wills.vs30 clahan.cat clahanvs30 PolyID.wills PolyID.clahan tif.cat
> ELEVATION tif.vs30
> 1  -3854850 4321856 478  513.703 1155   586.685   NA
>  NANA   NANA
> NANA   NA
> 2  -3849590 4319319 150  338.539   NA NA2 D
> 301  D377 1958  1942   1NA
> 519
> 3  -3849590 4319319 479  712.822   NA NA3 D
> 301  D377 1958  1942   1NA
> 519
> 4  -3849590 4319319 150  338.539 1152   336.794   NA
>  NANA   NANA
> NANA   NA
>
>
> rows 2 and 4 should have merged.  Why didn't they?
>
>
> thanks!
>
>
> Mehdi Khan
>
>

[[alternative HTML version deleted]]

__
R-help@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.


[R] Problem merging two data frames

2009-08-26 Thread Mehdi Khan
Hello everyone,

Merging two dataframes should be easy.  However when I try to merge, R
doesn't recognize identical values, even if I am doing it by values that
have no decimals.

willclayong:
   vs30  LON LAT  Net  X wills.cat wills.vs30 clahan.cat clahanvs30
PolyID.wills PolyID.clahan tif.cat STA ELEVATION tif.vs30
1 338.539 -3849590 4319319   2 D301  D
377 1958  1942   1 150NA  519
2 712.822 -3849590 4319319   3 D301  D
377 1958  1942   1 479NA  519
3 477.652 -3836584 4288164  10 C464  C
489 1194  9353   3 148NA  547
4 513.703 -3836575 4287739  11 C464  C
489 1194  9353   3 485NA  547
5 477.652 -3835886 4289120  12 C464  C
489 1194  9353   7 147NA  388

wald:

> wald_ol_sta[1:10,]
X Wald.vs30  STAvs30  LON LAT
1   1   434.417 1502 274.500 -3077929 3759564
2   2   378.049 NEE2 363.000 -3086165 3718184
3   3   196.848  EMS 336.000 -3143337 3500449
4   4   557.625 1498 659.600 -3103738 3871531
5   5   263.878 1497 274.500 -3102944 3878068
6   6   374.898 1499 274.500 -3109753 3858460
7   7   150.000  230 274.500 -3154048 3482703
8   8   248.342 1205 207.469 -3153294 3497116
9   9   422.256 1495 338.600 -3097854 3990339
10 10   322.540 1496 274.500 -3115300 3863905

willsclayongwald<-merge(wald_ol_sta, willsclayong, by=c("LON", "LAT", "STA",
"vs30"))

returns nothing... if I modify the previous script by adding "all=TRUE", I
get this:


lsclayongwald[1:10,]
LON LAT STAvs30  X.x   Wald.vs30  Net X.y wills.cat
wills.vs30 clahan.cat clahanvs30 PolyID.wills PolyID.clahan tif.cat
ELEVATION tif.vs30
1  -3854850 4321856 478  513.703 1155   586.685   NA
 NANA   NANA
NANA   NA
2  -3849590 4319319 150  338.539   NA NA2 D
301  D377 1958  1942   1NA
519
3  -3849590 4319319 479  712.822   NA NA3 D
301  D377 1958  1942   1NA
519
4  -3849590 4319319 150  338.539 1152   336.794   NA
 NANA   NANA
NANA   NA


rows 2 and 4 should have merged.  Why didn't they?


thanks!


Mehdi Khan

[[alternative HTML version deleted]]

__
R-help@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.


[R] Fwd: Overlay on raster loses points when merging with data frame

2009-08-24 Thread Mehdi Khan
Does anyone have an idea about this, it's driving me insane!

Hello everyone.  I have overlayed 1611 points on top of a tif file.

tifclassoverlay<-overlay(CRS11, classifiedmodrobin)

overlaydf<-as.data.frame(tifclassoverlay)

tifol<-remove.na.rows(overlaydf)


tifol is 854 rows long.   tifol has predicted data, while the
classifiedmodrobin matrix has observed data.  When I try to merge the two, I
get a length of 827:

 ngafulldf<-as.data.frame(classifiedmodrobin)

 NGAfiledata<-merge(tifol, ngafulldf,all=FALSE, by=c("LON", "LAT"))

NGAfiledata<-unique(NGAfiledata)

NGAfiledata<-remove.na.rows(NGAfiledata)
The length should obviously still be 854.  What happened to the missing
rows?  How can I get them back?  Thank you very much!! Here is a sample of
what the data looks like:
LON LAT Net  STA ELEVATION vs30 tif.cat
1  -3086165 3718184  CI NEE2   271  363   8
2  -3143337 3500449  CI  EMS11  336  14
3  -3155773 3704130  CI  DAN   428  304   4
4  -3173788 3722206  CI  GRP   978  509   4
5  -3188256 3548775  EN  SIM   -64  264  NA
6  -3193879 3549663  EN  RED   -64  322  NA
7  -3195312 3547901  CI  RXH   -59  331  NA
8  -3214063 3540800  CI  ERR   -56  233   8
9  -3219756 3587780  CI NSS217  246   4
10 -3226717 3558278  CI  SAL14  473   8
11 -3229979 3516218  CI  CRR66  315   4
12 -3238308 3596300  CI  THX   -31  244  12
13 -3247148 3667171  CI  GTM   836  306   7
14 -3254339 3615978  CI  MGE68  330   4
15 -3257283 3597678  CI  PMD   296  257   3

I am assuming there is no precision error since there are no decimals..

Thanks!

Mehdi Khan

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Unique command not deleting all duplicate rows

2009-08-24 Thread Mehdi Khan
Duplicated did not work, I agree with Erik. Is there any way I can specify a
tolerance limit and then delete?

On Mon, Aug 24, 2009 at 11:41 AM, Erik Iverson  wrote:

> I really don't think this is the issue.  I think the issue is that some
> columns of the data.frame, specifically V1, V2, and V4 should be checked
> versus R FAQ 7.31.
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Don McKenzie
> Sent: Monday, August 24, 2009 1:35 PM
> To: Mehdi Khan
> Cc: r-help@r-project.org
> Subject: Re: [R] Unique command not deleting all duplicate rows
>
> duplicated()
>
>  > test.df
> V1 V2   V3  V4 V5   V6 V7
> 1 -115.380 32.894  195 162.940  D 8419  D
> 2 -115.432 32.864  115 208.910  D 8419  D
> 3 -115.447 32.773 1170 264.570  D 8419  D
> 4 -115.447 32.773 1170 264.570  D 8419  D
> 5 -115.447 32.773 1170 264.570  D 8419  D
> 6 -115.447 32.773 1170 264.570  D 8419  D
> 7 -115.447 32.773  149 186.210  D 8419  D
> 8 -115.466 32.855  114 205.630  D 8419  D
> 9 -115.473 32.800 1121 207.469  D 8419  D
>
>  > test.df[!duplicated(test.df),]
> V1 V2   V3  V4 V5   V6 V7
> 1 -115.380 32.894  195 162.940  D 8419  D
> 2 -115.432 32.864  115 208.910  D 8419  D
> 3 -115.447 32.773 1170 264.570  D 8419  D
> 7 -115.447 32.773  149 186.210  D 8419  D
> 8 -115.466 32.855  114 205.630  D 8419  D
> 9 -115.473 32.800 1121 207.469  D 8419  D
>
>
> On 24-Aug-09, at 11:23 AM, Mehdi Khan wrote:
>
> > Hello everyone, when I run the "unique" command on my data frame,
> > it deletes
> > the majority of duplicate rows, but not all of them.  Here is a
> > sample of my
> > data. How do I get it to delete all the rows?
> >
> >  6 -115.38 32.894 195 162.94 D 8419 D
> >
> >  7 -115.432 32.864 115 208.91 D 8419 D
> >
> >  8 -115.447 32.773 1170 264.57 D 8419 D
> >
> >  9 -115.447 32.773 1170 264.57 D 8419 D
> >
> >  10 -115.447 32.773 1170 264.57 D 8419 D
> >
> >  11 -115.447 32.773 1170 264.57 D 8419 D
> >
> >  12 -115.447 32.773 149 186.21 D 8419 D
> >
> >  13 -115.466 32.855 114 205.63 D 8419 D
> >
> >  14 -115.473 32.8 1121 207.469 D 8419 D
> >
> >
> > Thanks a bunch!
> >
> > Mehdi Khan
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@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.
>
> Don McKenzie, Research Ecologist
> Pacific WIldland Fire Sciences Lab
> US Forest Service
>
> Affiliate Professor
> School of Forest Resources, College of the Environment
> CSES Climate Impacts Group
> University of Washington
>
> desk: 206-732-7824
> cell: 206-321-5966
> d...@u.washington.edu
> donaldmcken...@fs.fed.us
>
> __
> R-help@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@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.


[R] Unique command not deleting all duplicate rows

2009-08-24 Thread Mehdi Khan
Hello everyone, when I run the "unique" command on my data frame, it deletes
the majority of duplicate rows, but not all of them.  Here is a sample of my
data. How do I get it to delete all the rows?

 6 -115.38 32.894 195 162.94 D 8419 D

 7 -115.432 32.864 115 208.91 D 8419 D

 8 -115.447 32.773 1170 264.57 D 8419 D

 9 -115.447 32.773 1170 264.57 D 8419 D

 10 -115.447 32.773 1170 264.57 D 8419 D

 11 -115.447 32.773 1170 264.57 D 8419 D

 12 -115.447 32.773 149 186.21 D 8419 D

 13 -115.466 32.855 114 205.63 D 8419 D

 14 -115.473 32.8 1121 207.469 D 8419 D


Thanks a bunch!

Mehdi Khan

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] REMOVE ME

2009-08-12 Thread Mehdi Khan
You can do it yourself by unsubscribing.

On Wed, Aug 12, 2009 at 8:48 PM, Tim Paysen  wrote:

> This mailing list is too intrusive.  Remove my name.
>[[alternative HTML version deleted]]
>
>
> __
> R-help@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@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.


Re: [R] Creating a column based on data in another column

2009-08-12 Thread Mehdi Khan
willsclahanstationcut$wills.vs30<-
recode(willsclahanstationcut$area.VSCAT,c("B"=686,"C"= 464,"BC"= 724,
"D"=301,"CD"= 372, "D"= 800, "DE"= 1000, "WATER"=0))

where $vs30 is the column I want to create, $area.VSCAT is the column which
contains the labels.


On Wed, Aug 12, 2009 at 8:46 PM, Mehdi Khan  wrote:

> Hey guys, I have the same question, except in reverse: if we had letter
> classifications and wanted to assign numerical values to them (the case I
> stated previously except the other way around) how would we do that?  I am
> trying to use the recode function in the car package but not having any
> luck..
>
> Thank you!!
>
> On Fri, Jul 31, 2009 at 12:04 PM, Mehdi Khan  wrote:
>
>> hello all,
>>
>> I have a data frame and I want to create a column which assigns a letter
>> based upon the value in another column.  The data column has velocities
>> ranging from 0 to 1000.  So for example, for velocities between 0 and 300
>> I'd like to assign the letter "A" in the new column, for 300-600, "B" and so
>> on and so forth.  How would I do this?
>>
>> Thank you very much!
>>
>> Mehdi Khan
>>
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Creating a column based on data in another column

2009-08-12 Thread Mehdi Khan
Hey guys, I have the same question, except in reverse: if we had letter
classifications and wanted to assign numerical values to them (the case I
stated previously except the other way around) how would we do that?  I am
trying to use the recode function in the car package but not having any
luck..

Thank you!!

On Fri, Jul 31, 2009 at 12:04 PM, Mehdi Khan  wrote:

> hello all,
>
> I have a data frame and I want to create a column which assigns a letter
> based upon the value in another column.  The data column has velocities
> ranging from 0 to 1000.  So for example, for velocities between 0 and 300
> I'd like to assign the letter "A" in the new column, for 300-600, "B" and so
> on and so forth.  How would I do this?
>
> Thank you very much!
>
> Mehdi Khan
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Redoing axis in a strip plot

2009-08-06 Thread Mehdi Khan
Well, the tick marks are at every 200, how do i make them at every 100?

On Thu, Aug 6, 2009 at 2:02 PM, Mehdi Khan  wrote:

> nevermind, I just looked at Steve's reply to mohsen and it worked!
> stripplot(jitter(clahanvs30) ~ vs30, data = completetable, ylim=c(0:2000),
> xlim=c(0:2000))
>
>
> On Thu, Aug 6, 2009 at 1:54 PM, Mehdi Khan  wrote:
>
>> Hello everyone, simple question--the documentation is confusing so i am
>> forced to ask:
>>
>> I have a strip plot, how do create my own axis tick marks and set limits?
>>
>> Thanks!
>>
>>  stripplot(jitter(clahanvs30) ~ vs30, data = completetable)
>>
>> Mehdi Khan
>>
>>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Redoing axis in a strip plot

2009-08-06 Thread Mehdi Khan
nevermind, I just looked at Steve's reply to mohsen and it worked!
stripplot(jitter(clahanvs30) ~ vs30, data = completetable, ylim=c(0:2000),
xlim=c(0:2000))

On Thu, Aug 6, 2009 at 1:54 PM, Mehdi Khan  wrote:

> Hello everyone, simple question--the documentation is confusing so i am
> forced to ask:
>
> I have a strip plot, how do create my own axis tick marks and set limits?
>
> Thanks!
>
>  stripplot(jitter(clahanvs30) ~ vs30, data = completetable)
>
> Mehdi Khan
>
>

[[alternative HTML version deleted]]

__
R-help@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.


[R] Redoing axis in a strip plot

2009-08-06 Thread Mehdi Khan
Hello everyone, simple question--the documentation is confusing so i am
forced to ask:

I have a strip plot, how do create my own axis tick marks and set limits?

Thanks!

 stripplot(jitter(clahanvs30) ~ vs30, data = completetable)

Mehdi Khan

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] another automation question

2009-08-01 Thread Mehdi Khan
your name is annoying.

On Fri, Jul 31, 2009 at 2:01 PM, RR!  wrote:

>
> This code works:
>
> x<-letters[1:6]
> ycols<-23:28
> xcols<-rep(c(3,4,5,8),each=length(ycols))
>
> somertime<-function(i,j)somers2(Pred_pres_a_indpdt[,i,,], population[,j])
> results<-mapply(somertime,xcols,ycols)
>
>
>
> How can I make variable "h" work?
>
> x<-letters[1:6]
> ycols<-23:28
> xcols<-rep(c(3,4,5,8),each=length(ycols))
>
> somertime<-function(h,i,j)somers2(Pred_pres_h_indpdt[,i,,], population[,j])
> results<-mapply(somertime,x,xcols,ycols)
>
> -R
> --
> View this message in context:
> http://www.nabble.com/another-automation-question-tp24763017p24763017.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@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@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.


Re: [R] Creating a column based on data in another column

2009-07-31 Thread Mehdi Khan
got it, thank you everyone!

On Fri, Jul 31, 2009 at 12:04 PM, Mehdi Khan  wrote:

> hello all,
>
> I have a data frame and I want to create a column which assigns a letter
> based upon the value in another column.  The data column has velocities
> ranging from 0 to 1000.  So for example, for velocities between 0 and 300
> I'd like to assign the letter "A" in the new column, for 300-600, "B" and so
> on and so forth.  How would I do this?
>
> Thank you very much!
>
> Mehdi Khan
>

[[alternative HTML version deleted]]

__
R-help@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.


[R] Creating a column based on data in another column

2009-07-31 Thread Mehdi Khan
hello all,

I have a data frame and I want to create a column which assigns a letter
based upon the value in another column.  The data column has velocities
ranging from 0 to 1000.  So for example, for velocities between 0 and 300
I'd like to assign the letter "A" in the new column, for 300-600, "B" and so
on and so forth.  How would I do this?

Thank you very much!

Mehdi Khan

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Combining two dataframes and specifying tolerance levels

2009-07-29 Thread Mehdi Khan
I do not know if this message got through or not, but please disregard it!
Thanks!

On Wed, Jul 29, 2009 at 2:57 PM, Mehdi Khan  wrote:

> Hello everyone,
>
> I have two data frames.  One is a vector about 780 rows long consisting of
> lat long data of 780 station locations.  The other table was previously a
> shape file which I have converted into a data frame object of lat long
> coordinates and attribute data.  What I want to do is combine the
> two--assigning attribute data to each station.  The problem is, however,
> that those station locations do not have duplicate location and attribute
> data in the shape file.  So what needs to be done is that a tolerance level
> has to be used to assign attribute data from the shape file data frame to
> the particular station location.
>
> I hope this is clear enough.  I should probably post this to sig geo, but I
> figured that since we are dealing with two data frames and matrices, I can
> push for it to go to this list (since it seems to have a lot more viewers).
>
> Thanks a lot!!!
>
> Mehdi Khan
>

[[alternative HTML version deleted]]

__
R-help@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.


[R] Combining two dataframes and specifying tolerance levels

2009-07-29 Thread Mehdi Khan
Hello everyone,

I have two data frames.  One is a vector about 780 rows long consisting of
lat long data of 780 station locations.  The other table was previously a
shape file which I have converted into a data frame object of lat long
coordinates and attribute data.  What I want to do is combine the
two--assigning attribute data to each station.  The problem is, however,
that those station locations do not have duplicate location and attribute
data in the shape file.  So what needs to be done is that a tolerance level
has to be used to assign attribute data from the shape file data frame to
the particular station location.

I hope this is clear enough.  I should probably post this to sig geo, but I
figured that since we are dealing with two data frames and matrices, I can
push for it to go to this list (since it seems to have a lot more viewers).

Thanks a lot!!!

Mehdi Khan

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Searching for specific values in a matrix

2009-07-28 Thread Mehdi Khan
quick question, i am trying to get an interval of values now with this code
by toggling the tolerance limit.  is there any way i can modify this code to
find values which are within limits of BOTH latitude and longitude?
currently i have to pick one or the other.

On Tue, Jul 28, 2009 at 9:29 AM, Mehdi Khan  wrote:

> all right thank you!  this was big help.
>
>
> On Tue, Jul 28, 2009 at 2:22 AM, Martin Maechler <
> maech...@stat.math.ethz.ch> wrote:
>
>> >>>>> "BertG" == Bert Gunter 
>> >>>>> on Mon, 27 Jul 2009 15:30:08 -0700 writes:
>>
>>BertG> Nothing wrong with rolling your own, but see
>>BertG> ?all.equal for R's built-in "almost.equal" version.
>>
>> Yes, indeed!  Note that that needs a little extra care, as it
>> either returns TRUE or a character vector.
>> In sum, I'd strongly suggest you use
>>
>>  %~% <- function(x,y) isTRUE(all.equal(x,y))
>>
>> Martin Maechler, ETH Zurich and R Core Team
>>
>>BertG> Bert Gunter Genentech Nonclinical Biostatistics
>>
>>BertG> -Original Message- From:
>>BertG> r-help-boun...@r-project.org
>>BertG> [mailto:r-help-boun...@r-project.org] On Behalf Of
>>BertG> Steve Lianoglou Sent: Monday, July 27, 2009 3:17 PM
>>BertG> To: Mehdi Khan Cc: r-help@r-project.org Subject: Re:
>>BertG> [R] Searching for specific values in a matrix
>>
>>BertG> Ahh ..
>>
>>BertG> On Jul 27, 2009, at 6:01 PM, Mehdi Khan wrote:
>>
>>>> Even when choosing a value from the first few rows, it
>>>> doesn't work.  okay here it goes:
>>>>
>>>> > rearranged[1:10, 1:5] x y band1 VSCAT.001 soiltype 1
>>>> -124.3949 40.42468 NA NA CD 2 -124.3463 40.27358 NA NA CD
>>>> 3 -124.3357 40.25226 NA NA CD 4 -124.3663 40.40241 NA NA
>>>> CD 5 -124.3674 40.49810 NA NA CD 6 -124.3083 40.24744 NA
>>>> 464  7 -124.3017 40.31295 NA NA D 8 -124.3375
>>>> 40.47557 NA 464  9 -124.2511 40.11697 1 NA  10
>>>> -124.2532 40.12640 1 NA 
>>>>
>>>> > query<- rearranged$y== 40.42468 > rearranged[query,]
>>>> [1] x y band1 VSCAT.001 soiltype <0 rows> (or 0-length
>>>> row.names)
>>
>> BertG> This isn't working because the numbers you see for y
>>BertG> (40.42468) isn't precisely what that number is. As I
>>BertG> mentioned before you should use an "almost.equals"
>>BertG> type of search for this scenario. My "%~%" function
>>BertG> isn't working in your session because that is a
>>BertG> function I've defined myself. You can of course use
>>BertG> it, you just have to define it in your
>>BertG> workspace. Paste these lines into your workspace (or
>>BertG> save them to a file and "source" that file into your
>>BertG> workspace).
>>
>>BertG> ## === almost.equal functions 
>>
>>BertG> almost.equal <- function(x, y,
>>BertG> tolerance=.Machine$double.eps^0.5) { abs(x - y) <
>>BertG> tolerance }
>>
>>BertG> "%~%" <- function(x, y) almost.equal(x, y)
>>
>>BertG> ## === end paste ==
>>
>>BertG> Now you can use %~% once that's in. Let's use the
>>BertG> almost.equal function now because I don't know if the
>>BertG> default tolerance here is too strict (I suspect
>>BertG> showing the value for rearranged$y[1] will show you
>>BertG> more significant digits than you're seeing in the
>>BertG> table(?))
>>
>>BertG> query <- almost.equal(rearranged$y, 40.42468,
>>BertG> tolerance=0.0001) rearranged[query,]
>>
>>BertG> This will get you something.
>>
>>>> query<- rearranged$ VSCAT.001== 464 except it's a huge
>>>> table (I guess I have to get rid of all rows with NA).
>>
>> BertG> Yes, I believe I mentioned earlier that you have to
>>BertG> axe the NA matches manually:
>>
>>BertG> query <- rearranged$VSCAT.001 == 464 &
>>BertG> !is.na(rearranged$VSCAT.001) rearranged[query,]
>>
>>BertG> Will get you what you want.
>>
>>>> I tried using the %~% but R doesn't recognize it.  So
>>>> maybe it has to do with the roundin

Re: [R] Searching for specific values in a matrix

2009-07-28 Thread Mehdi Khan
all right thank you!  this was big help.

On Tue, Jul 28, 2009 at 2:22 AM, Martin Maechler  wrote:

> >>>>> "BertG" == Bert Gunter 
> >>>>> on Mon, 27 Jul 2009 15:30:08 -0700 writes:
>
>BertG> Nothing wrong with rolling your own, but see
>BertG> ?all.equal for R's built-in "almost.equal" version.
>
> Yes, indeed!  Note that that needs a little extra care, as it
> either returns TRUE or a character vector.
> In sum, I'd strongly suggest you use
>
>  %~% <- function(x,y) isTRUE(all.equal(x,y))
>
> Martin Maechler, ETH Zurich and R Core Team
>
>BertG> Bert Gunter Genentech Nonclinical Biostatistics
>
>BertG> -Original Message- From:
>BertG> r-help-boun...@r-project.org
>BertG> [mailto:r-help-boun...@r-project.org] On Behalf Of
>BertG> Steve Lianoglou Sent: Monday, July 27, 2009 3:17 PM
>BertG> To: Mehdi Khan Cc: r-help@r-project.org Subject: Re:
>BertG> [R] Searching for specific values in a matrix
>
>BertG> Ahh ..
>
>BertG> On Jul 27, 2009, at 6:01 PM, Mehdi Khan wrote:
>
>>> Even when choosing a value from the first few rows, it
>>> doesn't work.  okay here it goes:
>>>
>>> > rearranged[1:10, 1:5] x y band1 VSCAT.001 soiltype 1
>>> -124.3949 40.42468 NA NA CD 2 -124.3463 40.27358 NA NA CD
>>> 3 -124.3357 40.25226 NA NA CD 4 -124.3663 40.40241 NA NA
>>> CD 5 -124.3674 40.49810 NA NA CD 6 -124.3083 40.24744 NA
>>> 464  7 -124.3017 40.31295 NA NA D 8 -124.3375
>>> 40.47557 NA 464  9 -124.2511 40.11697 1 NA  10
>>> -124.2532 40.12640 1 NA 
>>>
>>> > query<- rearranged$y== 40.42468 > rearranged[query,]
>>> [1] x y band1 VSCAT.001 soiltype <0 rows> (or 0-length
>>> row.names)
>
> BertG> This isn't working because the numbers you see for y
>BertG> (40.42468) isn't precisely what that number is. As I
>BertG> mentioned before you should use an "almost.equals"
>BertG> type of search for this scenario. My "%~%" function
>BertG> isn't working in your session because that is a
>BertG> function I've defined myself. You can of course use
>BertG> it, you just have to define it in your
>BertG> workspace. Paste these lines into your workspace (or
>BertG> save them to a file and "source" that file into your
>BertG> workspace).
>
>BertG> ## === almost.equal functions 
>
>BertG> almost.equal <- function(x, y,
>BertG> tolerance=.Machine$double.eps^0.5) { abs(x - y) <
>BertG> tolerance }
>
>BertG> "%~%" <- function(x, y) almost.equal(x, y)
>
>BertG> ## === end paste ==
>
>BertG> Now you can use %~% once that's in. Let's use the
>BertG> almost.equal function now because I don't know if the
>BertG> default tolerance here is too strict (I suspect
>BertG> showing the value for rearranged$y[1] will show you
>BertG> more significant digits than you're seeing in the
>BertG> table(?))
>
>BertG> query <- almost.equal(rearranged$y, 40.42468,
>BertG> tolerance=0.0001) rearranged[query,]
>
>BertG> This will get you something.
>
>>> query<- rearranged$ VSCAT.001== 464 except it's a huge
>>> table (I guess I have to get rid of all rows with NA).
>
> BertG> Yes, I believe I mentioned earlier that you have to
>BertG> axe the NA matches manually:
>
>BertG> query <- rearranged$VSCAT.001 == 464 &
>BertG> !is.na(rearranged$VSCAT.001) rearranged[query,]
>
>BertG> Will get you what you want.
>
>>> I tried using the %~% but R doesn't recognize it.  So
>>> maybe it has to do with the rounding errors?
>
> BertG> Rounding errors won't happen with integer comparisons
>BertG> (and it looks like the VSCAT.001 columns is integers,
>BertG> no?).
>
>BertG> -steve
>
>BertG> -- Steve Lianoglou Graduate Student: Computational
>BertG> Systems Biology | Memorial Sloan-Kettering Cancer
>BertG> Center | Weill Medical College of Cornell University
>BertG> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact>
>
>BertG> __
>BertG> R-help@r-project.org mailing list
>BertG> https://stat.ethz.ch/mailman/listinfo/r-

Re: [R] Searching for specific values in a matrix

2009-07-28 Thread Mehdi Khan
Yes this is working quite well. Basically, I am comparing data obtained from
GIS to data obtained from R.  It's turning out that the latitude and
longitude values from GIS are not matching exactly those obtained in R, and
therefore
I am trying to find the variance in the data.

On Tue, Jul 28, 2009 at 9:48 AM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

> quick question, i am trying to get an interval of values now with this code
>> by toggling the tolerance limit.  is there any way i can modify this code to
>> find values which are within limits of BOTH latitude and longitude?
>>  currently i have to pick one or the other.
>>
>
> It's not really clear where your data is lat/long .. is this x/y?
>
> Anyway, you can "&" two "query vectors" to get the data that's between
> both. For instance:
>
> rearranged[1:10, 1:5]
>  xy band1 VSCAT.001 soiltype
> 1  -124.3949 40.42468NANA   CD
> 2  -124.3463 40.27358NANA   CD
> 3  -124.3357 40.25226NANA   CD
> 4  -124.3663 40.40241NANA   CD
> 5  -124.3674 40.49810NANA   CD
> 6  -124.3083 40.24744NA   464 
> 7  -124.3017 40.31295NANAD
> 8  -124.3375 40.47557NA   464 
> 9  -124.2511 40.11697 1NA 
> 10 -124.2532 40.12640 1NA 
>
> Assume you want a range constrained by x and y:
>
> good.x <- rearranged$x > 124.3 & rearranged$x < 125
> good.y <- rearranged$y > 40.5 & rearranged$y < 41
>
> rearranged[good.x & good.y,]
>
> Like that?
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  |  Memorial Sloan-Kettering Cancer Center
>  |  Weill Medical College of Cornell University
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Searching for specific values in a matrix

2009-07-27 Thread Mehdi Khan
Even when choosing a value from the first few rows, it doesn't work. okay
here it goes:

> rearranged[1:10, 1:5]
   xy band1 VSCAT.001 soiltype
1  -124.3949 40.42468NANA   CD
2  -124.3463 40.27358NANA   CD
3  -124.3357 40.25226NANA   CD
4  -124.3663 40.40241NANA   CD
5  -124.3674 40.49810NANA   CD
6  -124.3083 40.24744NA   464 
7  -124.3017 40.31295NANAD
8  -124.3375 40.47557NA   464 
9  -124.2511 40.11697 1NA 
10 -124.2532 40.12640 1NA 

> query<- rearranged$y== 40.42468
> rearranged[query,]
[1] x y band1 VSCAT.001 soiltype
<0 rows> (or 0-length row.names)

hmm it seems to be working for the whole number...

query<- rearranged$ VSCAT.001== 464
except it's  a huge table (I guess I have to get rid of all rows with NA). I
tried using the %~% but R doesn't recognize it.  So maybe it has to do with
the rounding errors?


On Mon, Jul 27, 2009 at 2:56 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>  no luck, it's okay, i will figure it out!  i might isolate and recombine
>> all the columns, maybe that will work.  thanks for the help!
>>
>
> No, wait .. no luck in being able to select out rows from your data.frame
> using values you see somewhere in the top 10 rows?
>
> Can you just paste in some key lines in your session so we can see?
>
> For instance, let's assume your data is in my.data, I'd like to see the
> results for:
>
> # Replace the column values (1:5) with other columns
> # you want to use for selection
> R> my.data[1:10,1:5]
>
> # Now show me your query and it's result that returns
> # a <0-row> data.frame, for example using a value
> # that appears in that column from the previous query
> R> my.data[my.data[,1] == 'something',]
> <0 rows> (or 0-length row.names)
>
> There should be a simple answer to what's going wrong here.
>
> -steve
>
> --
> Steve Lianoglou
>
> Graduate Student: Computational Systems Biology
>  |  Memorial Sloan-Kettering Cancer Center
>  |  Weill Medical College of Cornell University
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Searching for specific values in a matrix

2009-07-27 Thread Mehdi Khan
it worked! thank you so much!!

On Mon, Jul 27, 2009 at 3:16 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

> Ahh ..
>
> On Jul 27, 2009, at 6:01 PM, Mehdi Khan wrote:
>
>  Even when choosing a value from the first few rows, it doesn't work. okay
>> here it goes:
>>
>> > rearranged[1:10, 1:5]
>>   xy band1 VSCAT.001 soiltype
>> 1  -124.3949 40.42468NANA   CD
>> 2  -124.3463 40.27358NANA   CD
>> 3  -124.3357 40.25226NANA   CD
>> 4  -124.3663 40.40241NANA   CD
>> 5  -124.3674 40.49810NANA   CD
>> 6  -124.3083 40.24744NA   464 
>> 7  -124.3017 40.31295NANAD
>> 8  -124.3375 40.47557NA   464 
>> 9  -124.2511 40.11697 1NA 
>> 10 -124.2532 40.12640 1NA 
>>
>> > query<- rearranged$y== 40.42468
>> > rearranged[query,]
>> [1] x y band1 VSCAT.001 soiltype
>> <0 rows> (or 0-length row.names)
>>
>
> This isn't working because the numbers you see for y (40.42468) isn't
> precisely what that number is. As I mentioned before you should use an
> "almost.equals" type of search for this scenario. My "%~%" function isn't
> working in your session because that is a function I've defined myself. You
> can of course use it, you just have to define it in your workspace. Paste
> these lines into your workspace (or save them to a file and "source" that
> file into your workspace).
>
> ## === almost.equal functions 
>
> almost.equal <- function(x, y, tolerance=.Machine$double.eps^0.5) {
>  abs(x - y) < tolerance
> }
>
> "%~%" <- function(x, y) almost.equal(x, y)
>
> ## === end paste ==
>
> Now you can use %~% once that's in. Let's use the almost.equal function now
> because I don't know if the default tolerance here is too strict (I suspect
> showing the value for rearranged$y[1] will show you more significant digits
> than you're seeing in the table(?))
>
> query <- almost.equal(rearranged$y, 40.42468, tolerance=0.0001)
> rearranged[query,]
>
> This will get you something.
>
>  query<- rearranged$ VSCAT.001== 464
>> except it's  a huge table (I guess I have to get rid of all rows with NA).
>>
>
> Yes, I believe I mentioned earlier that you have to axe the NA matches
> manually:
>
> query <- rearranged$VSCAT.001 == 464 & !is.na(rearranged$VSCAT.001)
> rearranged[query,]
>
> Will get you what you want.
>
>  I tried using the %~% but R doesn't recognize it.  So maybe it has to do
>> with the rounding errors?
>>
>
> Rounding errors won't happen with integer comparisons (and it looks like
> the VSCAT.001 columns is integers, no?).
>
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  |  Memorial Sloan-Kettering Cancer Center
>  |  Weill Medical College of Cornell University
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact>
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Searching for specific values in a matrix

2009-07-27 Thread Mehdi Khan
no luck, it's okay, i will figure it out!  i might isolate and recombine all
the columns, maybe that will work.  thanks for the help!

On Mon, Jul 27, 2009 at 1:00 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 27, 2009, at 3:50 PM, Mehdi Khan wrote:
>
>  the problem is, it works with the example data i gave.  however, it does
>> NOT work with the data set i have, which is 600,000 rows.  the class is
>> still a data frame.
>>
>
> So the problem must be in your data, or what you think is in your data.
> Somehow you're constructing a "boolean query" that returns false for every
> row. As long as you're not getting any memory errors, the size of your data
> doesn't change the mechanics of how this would work.
>
> I suspect you're not getting <0 rows> for every possible query you can come
> up with, right?
>
> Look at the first 10 lines of your dataset and try to select some rows from
> your entire data.frame by using values you can see in the first 10 rows
> you've just looked at.
>
> I'm expecting this would work, in which case I'm not sure how much more
> help I can provide.
>
> -steve
>
>
>
>  On Mon, Jul 27, 2009 at 12:15 PM, Steve Lianoglou <
>> mailinglist.honey...@gmail.com> wrote:
>>
>> On Jul 27, 2009, at 2:54 PM, Mehdi Khan wrote:
>>
>> i am able to return the first column, but anything else returns this:
>> <0 rows> (or 0-length row.names)
>>
>> any idea?
>>
>> I'm not sure what you're doing.
>>
>> The result you're getting happens when no rows "pass" the logical test
>> that you are using to index the rows of your data.frame for.
>>
>> Can you show the code that you are using (based on the example data you
>> gave) that is giving you the <0 rows> result?
>>
>> -steve
>>
>>
>>
>> On Tue, Jul 21, 2009 at 12:49 PM, Steve Lianoglou <
>> mailinglist.honey...@gmail.com> wrote:
>>
>> On Jul 21, 2009, at 3:27 PM, Mehdi Khan wrote:
>>
>> I understand your explanation about the test for even numbers.  However I
>> am still a bit confused as to how to go about finding a particular value.
>>  Here is an example data set
>>
>> col #  attr1attr2   attr 3LONLAT
>> 17209 DNANA -122.9409 38.27645
>> 17210BCNANA -122.9581 38.36304
>> 17211 BNANA -123.6851 41.67121
>> 17212BCNANA -123.0724 38.93073
>> 17213 CNANA -123.7240 41.84403
>> 17214 464NA -122.9430 38.30988
>> 17215 CNANA -123.4442 40.65369
>> 17216BCNANA -122.9389 38.31551
>> 17217 CNANA -123.0747 38.97998
>> 17218 CNANA -123.6580 41.59610
>> 17219 CNANA -123.4513 40.70992
>> 17220 CNANA -123.0901 39.06473
>> 17221BCNANA -123.0653 38.94845
>> 17222BCNANA -122.9464 38.36808
>> 17223 464NA -123.0143 38.70205
>> 17224  NA 5 -122.8609 37.94137
>> 17225  NA 5 -122.8628 37.95057
>> 17226  NA 7 -122.8646 37.95978
>>
>> For future reference, perhaps paste this in a way that's easy for us to
>> paste into a running R session so we can use it, like so:
>>
>> df <- data.frame(
>> coln=c(17209, 17210, 17211, 17212, 17213, 17214, 17215, 17216, 17217,
>> 17218, 17219, 17220, 17221, 17222, 17223, 17224, 17225, 17226),
>>
>> attr1=c("D","BC","B","BC","C",NA,"C","BC","C","C","C","C","BC","BC",NA,NA,NA,NA),
>> attr2=c( NA,NA,NA,NA,NA,464,NA,NA,NA,NA,NA,NA,NA,NA,464,NA,NA,NA),
>> attr3=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,5,5,7),
>> LON=c(
>> -122.9409,-122.9581,-123.6851,-123.0724,-123.7240,-122.9430,-123.4442,-122.9389,-123.0747,-123.6580,-123.4513,-123.0901,-123.0653,-122.9464,-123.0143,-122.8609,-122.8628,-122.8646),
>>
>> LAT=c(38.27645,38.36304,41.67121,38.93073,41.84403,38.30988,40.65369,38.31551,38.97998,41.59610,40.70992,39.06473,38.94845,38.36808,38.70205,37.94137,37.95057,37.95978))
>>
>>
>> If I wanted to find the row with Lat = 37.95978
>>
>> Using an "indexing vector":
>>
>> R> lats <- df$LAT == 37.95978
>> # or with the %~% from before:
>> # lats <- df$LAT %~% 37.95978
>>

Re: [R] Searching for specific values in a matrix

2009-07-27 Thread Mehdi Khan
the problem is, it works with the example data i gave.  however, it does NOT
work with the data set i have, which is 600,000 rows.  the class is still a
data frame.

On Mon, Jul 27, 2009 at 12:15 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 27, 2009, at 2:54 PM, Mehdi Khan wrote:
>
>  i am able to return the first column, but anything else returns this:
>> <0 rows> (or 0-length row.names)
>>
>> any idea?
>>
>
> I'm not sure what you're doing.
>
> The result you're getting happens when no rows "pass" the logical test that
> you are using to index the rows of your data.frame for.
>
> Can you show the code that you are using (based on the example data you
> gave) that is giving you the <0 rows> result?
>
> -steve
>
>
>
>> On Tue, Jul 21, 2009 at 12:49 PM, Steve Lianoglou <
>> mailinglist.honey...@gmail.com> wrote:
>>
>> On Jul 21, 2009, at 3:27 PM, Mehdi Khan wrote:
>>
>> I understand your explanation about the test for even numbers.  However I
>> am still a bit confused as to how to go about finding a particular value.
>>  Here is an example data set
>>
>> col #  attr1attr2   attr 3LONLAT
>> 17209 DNANA -122.9409 38.27645
>> 17210BCNANA -122.9581 38.36304
>> 17211 BNANA -123.6851 41.67121
>> 17212BCNANA -123.0724 38.93073
>> 17213 CNANA -123.7240 41.84403
>> 17214 464NA -122.9430 38.30988
>> 17215 CNANA -123.4442 40.65369
>> 17216BCNANA -122.9389 38.31551
>> 17217 CNANA -123.0747 38.97998
>> 17218 CNANA -123.6580 41.59610
>> 17219 CNANA -123.4513 40.70992
>> 17220 CNANA -123.0901 39.06473
>> 17221BCNANA -123.0653 38.94845
>> 17222BCNANA -122.9464 38.36808
>> 17223 464NA -123.0143 38.70205
>> 17224  NA 5 -122.8609 37.94137
>> 17225  NA 5 -122.8628 37.95057
>> 17226  NA 7 -122.8646 37.95978
>>
>> For future reference, perhaps paste this in a way that's easy for us to
>> paste into a running R session so we can use it, like so:
>>
>> df <- data.frame(
>> coln=c(17209, 17210, 17211, 17212, 17213, 17214, 17215, 17216, 17217,
>> 17218, 17219, 17220, 17221, 17222, 17223, 17224, 17225, 17226),
>>
>> attr1=c("D","BC","B","BC","C",NA,"C","BC","C","C","C","C","BC","BC",NA,NA,NA,NA),
>> attr2=c( NA,NA,NA,NA,NA,464,NA,NA,NA,NA,NA,NA,NA,NA,464,NA,NA,NA),
>> attr3=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,5,5,7),
>> LON=c(
>> -122.9409,-122.9581,-123.6851,-123.0724,-123.7240,-122.9430,-123.4442,-122.9389,-123.0747,-123.6580,-123.4513,-123.0901,-123.0653,-122.9464,-123.0143,-122.8609,-122.8628,-122.8646),
>>
>> LAT=c(38.27645,38.36304,41.67121,38.93073,41.84403,38.30988,40.65369,38.31551,38.97998,41.59610,40.70992,39.06473,38.94845,38.36808,38.70205,37.94137,37.95057,37.95978))
>>
>>
>> If I wanted to find the row with Lat = 37.95978
>>
>> Using an "indexing vector":
>>
>> R> lats <- df$LAT == 37.95978
>> # or with the %~% from before:
>> # lats <- df$LAT %~% 37.95978
>> R> df[lats,]
>>   coln attr1 attr2 attr3   LON  LAT
>> 18 17226  NA 7 -122.8646 37.95978
>>
>> Using the "subset" function:
>>
>> R> subset(df, LAT == 37.95978)
>>   coln attr1 attr2 attr3   LON  LAT
>> 18 17226  NA 7 -122.8646 37.95978
>>
>>
>> , how would i do that?  How would  I find the rows with BC?
>>
>> R> subset(df, attr1 == 'BC')
>>   coln attr1 attr2 attr3   LON  LAT
>> 2  17210BCNANA -122.9581 38.36304
>> 4  17212BCNANA -123.0724 38.93073
>> 8  17216BCNANA -122.9389 38.31551
>> 13 17221BCNANA -123.0653 38.94845
>> 14 17222BCNANA -122.9464 38.36808
>>
>>
>> If you try with an "indexing vector" the NA's will trip you up:
>>
>> R> df[df$attr1 == 'BC',]
>> coln attr1 attr2 attr3   LON  LAT
>> 217210BCNANA -122.9581 38.36304
>> 417212BCNANA -123.0724 38.93073
>> NA  NA  NANANA   NA
>

Re: [R] Searching for specific values in a matrix

2009-07-27 Thread Mehdi Khan
i am able to return the first column, but anything else returns this:
<0 rows> (or 0-length row.names)

any idea?

On Tue, Jul 21, 2009 at 12:49 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 21, 2009, at 3:27 PM, Mehdi Khan wrote:
>
>  I understand your explanation about the test for even numbers.  However I
>> am still a bit confused as to how to go about finding a particular value.
>>  Here is an example data set
>>
>> col #  attr1attr2   attr 3LONLAT
>> 17209 DNANA -122.9409 38.27645
>> 17210BCNANA -122.9581 38.36304
>> 17211 BNANA -123.6851 41.67121
>> 17212BCNANA -123.0724 38.93073
>> 17213 CNANA -123.7240 41.84403
>> 17214 464NA -122.9430 38.30988
>> 17215 CNANA -123.4442 40.65369
>> 17216BCNANA -122.9389 38.31551
>> 17217 CNANA -123.0747 38.97998
>> 17218 CNANA -123.6580 41.59610
>> 17219 CNANA -123.4513 40.70992
>> 17220 CNANA -123.0901 39.06473
>> 17221BCNANA -123.0653 38.94845
>> 17222BCNANA -122.9464 38.36808
>> 17223 464NA -123.0143 38.70205
>> 17224  NA 5 -122.8609 37.94137
>> 17225  NA 5 -122.8628 37.95057
>> 17226  NA 7 -122.8646 37.95978
>>
>
> For future reference, perhaps paste this in a way that's easy for us to
> paste into a running R session so we can use it, like so:
>
> df <- data.frame(
> coln=c(17209, 17210, 17211, 17212, 17213, 17214, 17215, 17216, 17217,
> 17218, 17219, 17220, 17221, 17222, 17223, 17224, 17225, 17226),
>
> attr1=c("D","BC","B","BC","C",NA,"C","BC","C","C","C","C","BC","BC",NA,NA,NA,NA),
> attr2=c( NA,NA,NA,NA,NA,464,NA,NA,NA,NA,NA,NA,NA,NA,464,NA,NA,NA),
> attr3=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,5,5,7),
> LON=c(
> -122.9409,-122.9581,-123.6851,-123.0724,-123.7240,-122.9430,-123.4442,-122.9389,-123.0747,-123.6580,-123.4513,-123.0901,-123.0653,-122.9464,-123.0143,-122.8609,-122.8628,-122.8646),
>
> LAT=c(38.27645,38.36304,41.67121,38.93073,41.84403,38.30988,40.65369,38.31551,38.97998,41.59610,40.70992,39.06473,38.94845,38.36808,38.70205,37.94137,37.95057,37.95978))
>
>  If I wanted to find the row with Lat = 37.95978
>>
>
> Using an "indexing vector":
>
> R> lats <- df$LAT == 37.95978
> # or with the %~% from before:
> # lats <- df$LAT %~% 37.95978
> R> df[lats,]
>coln attr1 attr2 attr3   LON  LAT
> 18 17226  NA 7 -122.8646 37.95978
>
> Using the "subset" function:
>
> R> subset(df, LAT == 37.95978)
>coln attr1 attr2 attr3   LON  LAT
> 18 17226  NA 7 -122.8646 37.95978
>
>  , how would i do that?  How would  I find the rows with BC?
>>
>
> R> subset(df, attr1 == 'BC')
>coln attr1 attr2 attr3   LON  LAT
> 2  17210BCNANA -122.9581 38.36304
> 4  17212BCNANA -123.0724 38.93073
> 8  17216BCNANA -122.9389 38.31551
> 13 17221BCNANA -123.0653 38.94845
> 14 17222BCNANA -122.9464 38.36808
>
>
> If you try with an "indexing vector" the NA's will trip you up:
>
> R> df[df$attr1 == 'BC',]
>  coln attr1 attr2 attr3   LON  LAT
> 217210BCNANA -122.9581 38.36304
> 417212BCNANA -123.0724 38.93073
> NA  NA  NANANA   NA
> 817216BCNANA -122.9389 38.31551
> 13   17221BCNANA -123.0653 38.94845
> 14   17222BCNANA -122.9464 38.36808
> NA.1NA  NANANA   NA
> NA.2NA  NANANA   NA
> NA.3NA  NANANA   NA
> NA.4NA  NANANA   NA
>
> So you could do something like:
>
> > df[df$attr1 == 'BC' & !is.na(df$attr1),]
>coln attr1 attr2 attr3   LON  LAT
> 2  17210BCNANA -122.9581 38.36304
> 4  17212BCNANA -123.0724 38.93073
> 8  17216BCNANA -122.9389 38.31551
> 13 17221BCNANA -123.0653 38.94845
> 14 17222BCNANA -122.9464 38.36808
>
>
> HTH,
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Physiology, Biophysics and Systems Biology
> Weill Medical College of Cornell University
>
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact>
>
>
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Searching for specific values in a matrix

2009-07-21 Thread Mehdi Khan
thank you VERY much, I have to run now, but I will look at this in the next
few days (going on a field trip).  I really appreciate it!

Mehdi Khan

On Tue, Jul 21, 2009 at 12:49 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 21, 2009, at 3:27 PM, Mehdi Khan wrote:
>
>  I understand your explanation about the test for even numbers.  However I
>> am still a bit confused as to how to go about finding a particular value.
>>  Here is an example data set
>>
>> col #  attr1attr2   attr 3LONLAT
>> 17209 DNANA -122.9409 38.27645
>> 17210BCNANA -122.9581 38.36304
>> 17211 BNANA -123.6851 41.67121
>> 17212BCNANA -123.0724 38.93073
>> 17213 CNANA -123.7240 41.84403
>> 17214 464NA -122.9430 38.30988
>> 17215 CNANA -123.4442 40.65369
>> 17216BCNANA -122.9389 38.31551
>> 17217 CNANA -123.0747 38.97998
>> 17218 CNANA -123.6580 41.59610
>> 17219 CNANA -123.4513 40.70992
>> 17220 CNANA -123.0901 39.06473
>> 17221BCNANA -123.0653 38.94845
>> 17222BCNANA -122.9464 38.36808
>> 17223 464NA -123.0143 38.70205
>> 17224  NA 5 -122.8609 37.94137
>> 17225  NA 5 -122.8628 37.95057
>> 17226  NA 7 -122.8646 37.95978
>>
>
> For future reference, perhaps paste this in a way that's easy for us to
> paste into a running R session so we can use it, like so:
>
> df <- data.frame(
> coln=c(17209, 17210, 17211, 17212, 17213, 17214, 17215, 17216, 17217,
> 17218, 17219, 17220, 17221, 17222, 17223, 17224, 17225, 17226),
>
> attr1=c("D","BC","B","BC","C",NA,"C","BC","C","C","C","C","BC","BC",NA,NA,NA,NA),
> attr2=c( NA,NA,NA,NA,NA,464,NA,NA,NA,NA,NA,NA,NA,NA,464,NA,NA,NA),
> attr3=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,5,5,7),
> LON=c(
> -122.9409,-122.9581,-123.6851,-123.0724,-123.7240,-122.9430,-123.4442,-122.9389,-123.0747,-123.6580,-123.4513,-123.0901,-123.0653,-122.9464,-123.0143,-122.8609,-122.8628,-122.8646),
>
> LAT=c(38.27645,38.36304,41.67121,38.93073,41.84403,38.30988,40.65369,38.31551,38.97998,41.59610,40.70992,39.06473,38.94845,38.36808,38.70205,37.94137,37.95057,37.95978))
>
>  If I wanted to find the row with Lat = 37.95978
>>
>
> Using an "indexing vector":
>
> R> lats <- df$LAT == 37.95978
> # or with the %~% from before:
> # lats <- df$LAT %~% 37.95978
> R> df[lats,]
>coln attr1 attr2 attr3   LON  LAT
> 18 17226  NA 7 -122.8646 37.95978
>
> Using the "subset" function:
>
> R> subset(df, LAT == 37.95978)
>coln attr1 attr2 attr3   LON  LAT
> 18 17226  NA 7 -122.8646 37.95978
>
>  , how would i do that?  How would  I find the rows with BC?
>>
>
> R> subset(df, attr1 == 'BC')
>coln attr1 attr2 attr3   LON  LAT
> 2  17210BCNANA -122.9581 38.36304
> 4  17212BCNANA -123.0724 38.93073
> 8  17216BCNANA -122.9389 38.31551
> 13 17221BCNANA -123.0653 38.94845
> 14 17222BCNANA -122.9464 38.36808
>
>
> If you try with an "indexing vector" the NA's will trip you up:
>
> R> df[df$attr1 == 'BC',]
>  coln attr1 attr2 attr3   LON  LAT
> 217210BCNANA -122.9581 38.36304
> 417212BCNANA -123.0724 38.93073
> NA  NA  NANANA   NA
> 817216BCNANA -122.9389 38.31551
> 13   17221BCNANA -123.0653 38.94845
> 14   17222BCNANA -122.9464 38.36808
> NA.1NA  NANANA   NA
> NA.2NA  NANANA   NA
> NA.3NA  NANANA   NA
> NA.4NA  NANANA   NA
>
> So you could do something like:
>
> > df[df$attr1 == 'BC' & !is.na(df$attr1),]
>coln attr1 attr2 attr3   LON  LAT
> 2  17210BCNANA -122.9581 38.36304
> 4  17212BCNANA -123.0724 38.93073
> 8  17216BCNANA -122.9389 38.31551
> 13 17221BCNANA -123.0653 38.94845
> 14 17222BCNANA -122.9464 38.36808
>
>
> HTH,
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Physiology, Biophysics and Systems Biology
> Weill Medical College of Cornell University
>
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact>
>
>
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Searching for specific values in a matrix

2009-07-21 Thread Mehdi Khan
I understand your explanation about the test for even numbers.  However I am
still a bit confused as to how to go about finding a particular value.  Here
is an example data set

col #  attr1attr2   attr 3LONLAT
17209 DNANA -122.9409 38.27645
17210BCNANA -122.9581 38.36304
17211 BNANA -123.6851 41.67121
17212BCNANA -123.0724 38.93073
17213 CNANA -123.7240 41.84403
17214 464NA -122.9430 38.30988
17215 CNANA -123.4442 40.65369
17216BCNANA -122.9389 38.31551
17217 CNANA -123.0747 38.97998
17218 CNANA -123.6580 41.59610
17219 CNANA -123.4513 40.70992
17220 CNANA -123.0901 39.06473
17221BCNANA -123.0653 38.94845
17222BCNANA -122.9464 38.36808
17223 464NA -123.0143 38.70205
17224  NA 5 -122.8609 37.94137
17225  NA 5 -122.8628 37.95057
17226  NA 7 -122.8646 37.95978

If I wanted to find the row with Lat = 37.95978, how would i do that?  How
would  I find the rows with BC?

Thank you for all your help!

Mehdi Khan

On Tue, Jul 21, 2009 at 12:10 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

> I am a bit confused as to what the following command does:
>> evens <- df$nums %% 2 == 0
>>
>
> It returns a logical vector (I'm calling this an "indexing vector") that is
> TRUE where df$nums %% 2 == 0 (%% is modulo division, and 4 mod 2 == 0 -- so
> it's a test for "being even")
>
>  In my matrix example, let's say I am looking for the variable(s) BC and I
>> want R to return all the rows with that value...
>>
>
> You "just" have to setup a suitable test and build an "indexing" vector to
> select the appropriate rows -- or use the subset function (see ?subset).
>
> If it's still confusing to you, please create a trivial example data.frame
> and send it back to the list along with things you'd like to "find", so we
> can give you concrete examples on different ways you can find what you need.
>
>  or If I want a value such as 33.543.  How would I get it to do that?
>> Just a single value in the latter case.  I have already converted it to a
>> data frame.
>>
>
> Be careful when searching for doubles/floats as sometimes you'll miss what
> you're looking for if you are using exact matches (ie something ==
> something.else) ... I have an almost.equals function in my "bag of
> utilities" that I'd probably use for stuff like this:
>
> almost.equal <- function(x, y, eps=0.01) {
>  abs(x - y) < eps
> }
>
> '%~%' <- function(x, y) almost.equal(x, y))
>
> R> x <- rnorm(1000, sd=.0001)
> R> sum(x %~% 0)
> ## Equivalently: sum(almost.equal(x, 0))
> [1] 8
>
> R> sum(x == 0)
> [1] 0
>
> Summing over a logical vector treats the TRUE values as 1 and FALSE values
> as 0.
>
> HTH,
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Physiology, Biophysics and Systems Biology
> Weill Medical College of Cornell University
>
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact>
>
>
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Re gression using age and Duration of disease as a continous factors

2009-07-21 Thread Mehdi Khan
It was decent, I ended up not going to class and only going to discussions
and reading the book, got an A-.

On Tue, Jul 21, 2009 at 12:18 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 21, 2009, at 1:56 PM, Mehdi Khan wrote:
>
>
>> http://www.amazon.com/gp/product/007310874X/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=304485901&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=0256117365&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=155Y7AP1SHTSJESHM15M
>>
>> This is our textbook for regression analysis.  Go through the first 8 or 9
>> chapters and you're good.
>>
>
> By the by, do you like this book?
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Searching for specific values in a matrix

2009-07-21 Thread Mehdi Khan
I am a bit confused as to what the following command does:
evens <- df$nums %% 2 == 0

In my matrix example, let's say I am looking for the variable(s) BC and I
want R to return all the rows with that value... or If I want a value such
as 33.543.  How would I get it to do that?   Just a single value in the
latter case.  I have already converted it to a data frame.

Thanks a lot!

On Tue, Jul 21, 2009 at 11:34 AM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 21, 2009, at 1:47 PM, Mehdi Khan wrote:
>
>  Hello all,
>>
>> I have a seemingly simple question which I have searched for an answer for
>> for a few hours without luck.  I have a matrix of both values and
>> characters
>> with thousands of rows.  I would like to run a search of this matrix for
>> certain values and would like the search to retrieve the entire row.  How
>> would I accomplish this?
>>
>
> Oh, values! Woops
>
> Like so?
>
> df <- data.frame(nums=1:10, words=c("Abelonian",
>"abeltree",
>"Abencerrages",
>"abenteric",
>"abepithymia",
>"Aberdeen",
>"aberdevine",
>"Aberdonian",
>"Aberia",
>"aberrance"))
>
> evens <- df$nums %% 2 == 0
> df[evens,]
>
> You can build such an indexing vector (like evens) in a number of different
> ways to suite your problem.
>
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Physiology, Biophysics and Systems Biology
> Weill Medical College of Cornell University
>
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact>
>
>
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Re gression using age and Duration of disease as a continous factors

2009-07-21 Thread Mehdi Khan
http://www.amazon.com/gp/product/007310874X/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=304485901&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=0256117365&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=155Y7AP1SHTSJESHM15M

This is our textbook for regression analysis.  Go through the first 8 or 9
chapters and you're good.

Mehdi Khan

On Tue, Jul 21, 2009 at 9:29 AM, 1Rnwb  wrote:

>
> Thanks Steve,Thanks for the explanation,  I agree the question is too
> vague,
> I do not what a regression is I have switched to R a couple of months ago,
> after working in Excel for a long time.  I also know the lm, glm functions
> in R. but due to my data I am completely lost.  it looks like the experts
> individuals just come to poke fun at our expesense who has no background of
> statistics.
>
> I have a 8 proteins and I have two groups with 840 samples in control and
> 1140 samples in diseases further stratified by sex, draw age, duration of
> disease. all these groups and sub groups is making the thing very confusing
> as how to do the regression in R. the pupose is to show the changes in the
> levels of these proteins as the disease progress or changes in their levels
> with respect to progression in age, effect of gender, SNPs for these
> proteins, it is a pretty big dataset.
>
> The suggestion that consult the statistician is kind of funny as  the
> statistician in my center is my co-mentor and from past 5 years he is
> sitting on the data without any output.
>
> I am not here to ask someone to do my data analysis, but to get an
> understanding of the process as well as a proper direction to look for the
> analysis.  after all I do have to explain all these things to my boss as
> well.
>
> Thanks
>
>
>
> Steve Lianoglou-6 wrote:
> >
> >
> > On Jul 20, 2009, at 5:30 PM, 1Rnwb wrote:
> >
> >> I have read that multiple times without understanding anything.
> >
> > If that's the case, then perhaps you should follow Greg's first piece
> > of advice:
> >
> >> Greg Snow-2 wrote:
> >>>
> >>> If you need an explanation of what regression means, then you need
> >>> to take
> >>> a course or 2 at your local university, or at least hire a
> >>> statistical
> >>> consultant.
> >
> > We're not trying to be rude, but your question is quite ill formed,
> > and no one can really help you:
> >
> >> Please explain me as what it means and how this analysis can be done
> >> using R and which library(ies) are needed.
> >
> > It's not clear what you do/don't understand, and your problem
> > statement is too vague for anyone to tell you more.
> >
> > It seems like you're saying you don't understand what "regression" is,
> > in which case a simple email will not help you.
> >
> > "Simply put" regression is a method to predict a (typically)
> > "continuous" output by some combination of inputs, eg. predicting
> > someone's height by knowing their weight and shoe size (these are
> > continuous variables, too). It looks like in your case, your "inputs"
> > are the "continuous factors" of your email subject, which are age and
> > duration of disease?
> >
> > You haven't even mentioned what it is you are trying to predict.
> > Survival?
> >
> > The thing is, as soon as one puts something in "simple terms," it's
> > often wrong -- which is why Greg suggested taking a class or hiring
> > someone to help you.
> >
> > Anyway, I'm assuming you must know what regression is, otherwise you
> > wouldn't be looking to know how to do it. One way to perform linear
> > regression in R is using the "lm" function. Type ?lm at the R prompt
> > for help.
> >
> >
> >> I thought this forum is for help. now i know what the statistician
> >> in my dept
> >> does all day long
> >
> > It is for help -- you'll see it's quite active around here.
> >
> > It's *not* for soliciting other people to do your analysis for you,
> > which is how your email comes across. All of us have our own work to
> > do, but are here to help if you're stuck on something *in
> > particular* ... perhaps you can do a bit more legwork and rephrase
> > your question in a more meaningful way.
> >
> > -steve
> >
> > --
> > Steve Lianoglou
> > Graduate Student: Physiology, Biophysics and Systems Biology
> > Weill Medical College of Cornell University
> >
> > Contact Info: 
> > http://cbio.mskcc

[R] Searching for specific values in a matrix

2009-07-21 Thread Mehdi Khan
Hello all,

I have a seemingly simple question which I have searched for an answer for
for a few hours without luck.  I have a matrix of both values and characters
with thousands of rows.  I would like to run a search of this matrix for
certain values and would like the search to retrieve the entire row.  How
would I accomplish this?

Thanks!

Mehdi Khan

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Problems generating image from tiff file

2009-07-17 Thread Mehdi Khan
Paul,

Thank you very much for your explanation.  I have only been using R for GIS
purposes for about a week, so my expertise in the field is shallow.  Your
explanation helped me out and I was able to plot the tif file simply by
using the spplot command.

The reason I was projecting it was that I am trying to project a separate
shape file on top of the tif--and the coordinates of the two files are
different.

What I ended up doing was using spTransform to change the coordinate system
of the shape file into that of the tif file, and used the image () and plot
commands to graph them on top of one another.

I'm definately a novice when it comes to R, but I am learning.  Thanks a
lot!


On Fri, Jul 17, 2009 at 12:25 AM, Paul Hiemstra wrote:

> Hi Mehdi,
>
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> I don't mean to rude, but you seem to lack basic knowledge regarding the
> use of spatial data in R. Starting to use R is hard, but please ask your
> supervisor to help you or try and read more information on the internet.
> Some hints:
>
> The Spatial taskview:
> http://cran.r-project.org/web/views/Spatial.html
>
> The R tips wiki:
> http://wiki.r-project.org/rwiki/doku.php?id=tips:spatial-data
>
> Or read the sp-documentation:
> ?sp
> vignette("sp")
>
> In addition, there is a mailing list specifically for geographic data and
> analysis in R, r-sig-geo. This is a much better place for your type of
> questions.
>
> I also have some comments inline below.
>
> cheers and good luck with your R adventures!
> Paul
>
> Mehdi Khan wrote:
>
>> I imported the attached tiff file and converted the coordinate system to
>> long lat and graphed it:
>>
>> californiatiff<- readGDAL("california1.tif")
>> proj4string(californiatiff)
>>
>>
> What is the outcome of this command?
>
>> rasterprojection <- spTransform(californiatiff, CRS("+proj=longlat")
>>>
>>>
>> It seems that you reproject a grid here. Remember that when reprojecting a
> grid, the grid structure is lost. The squares in the grid in the new
> projection aren't squares anymore. So the output of spTransform is no longer
> a grid (SpatialGrid or SpatialPixels) but a point dataset (SpatialPoints).
>
>>
>> however, when using the plot command for rasterprojection,
>>
> The sp-objects are plotted not using the plot command, but using the spplot
> command. If you are using this, this is not obvious from your e-mail.
>
>> I get a blob.  I
>> can see the outline of the state of california and nevada, but rather than
>> being able to see the geographic features, it is just a monocolor blob. My
>> suspicion is that since it is a list of coordinates and another column
>> that
>> contains attributes, I need to turn it into a polygon.  I've tried the
>> following codes but none work:
>>
>>
>>
>>> rasterprojection2<-SpatialPolygons(rasterprojection)
>>>
>>>
>> You are trying to convert a grid to a polygon, this is not possible.
>
>> Error in is.vector(X) :
>>  trying to get slot "Polygons" from an object of a basic class ("integer")
>> with no slots
>>
>>  rasterprojection2<- Polygons(rasterprojection)
>> Error in as.vector(x, "list") :
>>  cannot coerce type 'S4' to vector of type 'list'
>>
>> Essentially, all I need to do is to connect the coordinates into polygons.
>> What am I doing wrong?
>>
>>
> You used readgdal to read the tif file. If you want polygons, get a
> shapefile and read it using readOGR or readShapeLines or readShapePoly.
>
>> Thank you!
>>  
>>
>> __
>> R-help@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.
>>
>>
>
>
> --
> Drs. Paul Hiemstra
> Department of Physical Geography
> Faculty of Geosciences
> University of Utrecht
> Heidelberglaan 2
> P.O. Box 80.115
> 3508 TC Utrecht
> Phone:  +3130 274 3113 Mon-Tue
> Phone:  +3130 253 5773 Wed-Fri
> http://intamap.geo.uu.nl/~paul <http://intamap.geo.uu.nl/%7Epaul>
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Problems generating image from tiff file

2009-07-16 Thread Mehdi Khan
when you post this can you please remove the tiff file?  my supervisor
doesn't want me to let it out. sorry!

On Thu, Jul 16, 2009 at 4:02 PM, Mehdi Khan  wrote:

> I imported the attached tiff file and converted the coordinate system to
> long lat and graphed it:
>
> californiatiff<- readGDAL("california1.tif")
> proj4string(californiatiff)
> > rasterprojection <- spTransform(californiatiff, CRS("+proj=longlat")
>
> however, when using the plot command for rasterprojection, I get a blob.  I
> can see the outline of the state of california and nevada, but rather than
> being able to see the geographic features, it is just a monocolor blob.  My
> suspicion is that since it is a list of coordinates and another column that
> contains attributes, I need to turn it into a polygon.  I've tried the
> following codes but none work:
>
> > rasterprojection2<-SpatialPolygons(rasterprojection)
> Error in is.vector(X) :
>   trying to get slot "Polygons" from an object of a basic class ("integer")
> with no slots
>
>  rasterprojection2<- Polygons(rasterprojection)
> Error in as.vector(x, "list") :
>   cannot coerce type 'S4' to vector of type 'list'
>
> Essentially, all I need to do is to connect the coordinates into polygons.
> What am I doing wrong?
>
> Thank you!
>

[[alternative HTML version deleted]]

__
R-help@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.


[R] Problems generating image from tiff file

2009-07-16 Thread Mehdi Khan
I imported the attached tiff file and converted the coordinate system to
long lat and graphed it:

californiatiff<- readGDAL("california1.tif")
proj4string(californiatiff)
> rasterprojection <- spTransform(californiatiff, CRS("+proj=longlat")

however, when using the plot command for rasterprojection, I get a blob.  I
can see the outline of the state of california and nevada, but rather than
being able to see the geographic features, it is just a monocolor blob.  My
suspicion is that since it is a list of coordinates and another column that
contains attributes, I need to turn it into a polygon.  I've tried the
following codes but none work:

> rasterprojection2<-SpatialPolygons(rasterprojection)
Error in is.vector(X) :
  trying to get slot "Polygons" from an object of a basic class ("integer")
with no slots

 rasterprojection2<- Polygons(rasterprojection)
Error in as.vector(x, "list") :
  cannot coerce type 'S4' to vector of type 'list'

Essentially, all I need to do is to connect the coordinates into polygons.
What am I doing wrong?

Thank you!
__
R-help@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.