Re: [R] error returned by "make check" in R-2.5.0

2007-04-27 Thread Prof Brian Ripley
How big is abs(lam - lam2[i])/Meps ?

This could be one of those cases where your system (which CPU, what 
compilers?) is unusually inaccurate, but Linux systems do not usually 
differ much in their accuracies on the same CPU.

I've checked several systems, as see maximum values of around 40.

R 2.5.0 has an updated LAPACK so it will be different from 2.4.1.  My 
hunch is that this is a compiler optimization bug, so you could see what 
happens at lower optimization levels.


On Fri, 27 Apr 2007, Eric Thompson wrote:

> Today I tried to install the R-2.5.0 (currently running R-2.4.1) on
> Mandriva Linux. The ./configure and make commands seem to run fine,
> but "make check" gives the following messages:
>
> running regression tests
> make[3]: Entering directory `/home/ethomp04/R-2.5.0/tests'
> running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1
> make[3]: Leaving directory `/home/ethomp04/R-2.5.0/tests'
> make[2]: *** [test-Reg] Error 2
> make[2]: Leaving directory `/home/ethomp04/R-2.5.0/tests'
> make[1]: *** [test-all-basics] Error 1
> make[1]: Leaving directory `/home/ethomp04/R-2.5.0/tests'
> make: *** [check] Error 2
>
> Regarding "make check", the R-admin.html page says "Failures are not
> necessarily problems as they might be caused by missing
> functionality..."
>
> So, looking at the "reg-tests-1.Rout.fail" file, I see that the error
> occurs here:
>
>> ## eigen
>> Meps <- .Machine$double.eps
>> set.seed(321, kind = "default")   # force a particular seed
>> m <- matrix(round(rnorm(25),3), 5,5)
>> sm <- m + t(m) #- symmetric matrix
>> em <- eigen(sm); V <- em$vect
>> print(lam <- em$values) # ordered DEcreasingly
> [1]  5.1738946  3.1585064  0.6849974 -1.6299494 -2.5074489
>>
>> stopifnot(
> +  abs(sm %*% V - V %*% diag(lam))  < 60*Meps,
> +  abs(sm   - V %*% diag(lam) %*% t(V)) < 60*Meps)
>>
>> ##--- Symmetric = FALSE:  -- different to above : ---
>>
>> em <- eigen(sm, symmetric = FALSE); V2 <- em$vect
>> print(lam2 <- em$values) # ordered decreasingly in ABSolute value !
> [1]  5.1738946  3.1585064 -2.5074489 -1.6299494  0.6849974
>> print(i <- rev(order(lam2)))
> [1] 1 2 5 4 3
>> stopifnot(abs(lam - lam2[i]) < 60 * Meps)
> Error: abs(lam - lam2[i]) < 60 * Meps is not all TRUE
> Execution halted
>
>
> Interestingly, running these same tests on R-2.4.1 on the same system
> does not give an error:
>
>> Meps <- .Machine$double.eps
>> set.seed(321, kind = "default") # force a particular seed
>> m <- matrix(round(rnorm(25),3), 5,5)
>> sm <- m + t(m) #- symmetric matrix
>> em <- eigen(sm); V <- em$vect
>> print(lam <- em$values) # ordered DEcreasingly
> [1]  5.17389456321  3.15850637323  0.68499738238 -1.62994940108 -2.50744891774
>> stopifnot(
> +  abs(sm %*% V - V %*% diag(lam))  < 60*Meps,
> +  abs(sm  - V %*% diag(lam) %*% t(V)) < 60*Meps)
>>
>> ##--- Symmetric = FALSE:  -- different to above : ---
>>
>> em <- eigen(sm, symmetric = FALSE); V2 <- em$vect
>> print(lam2 <- em$values) # ordered decreasingly in ABSolute value !
> [1]  5.17389456321  3.15850637323 -2.50744891774 -1.62994940108  0.68499738238
>> print(i <- rev(order(lam2)))
> [1] 1 2 5 4 3
>> stopifnot(abs(lam - lam2[i]) < 60 * Meps)
>> abs(lam - lam2[i]) < 60 * Meps
> [1] TRUE TRUE TRUE TRUE TRUE
>
> I'm not sure what to do next, or how serious of a problem this might
> be. I would appreciate any suggestions or advice. I thought maybe this
> was due to something about how my system is setup, but since I don't
> get the error in R-2.4.1, that seems to imply to me that there is
> something different in R-2.5.0 that is causing it.
>
> Thanks.
>
> Eric Thompson
> Tufts University
> Civil & Environmental Engineering
>
>> sessionInfo()
> R version 2.4.1 (2006-12-18)
> i686-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] "datasets"  "utils" "stats" "graphics"  "grDevices" "methods"
> [7] "base"
>
> other attached packages:
>MASS
> "7.2-31"
>
> __
> R-help@stat.math.ethz.ch 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.
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch 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 commen

Re: [R] acf and pacf plot

2007-04-27 Thread Prof Brian Ripley
On Fri, 27 Apr 2007, tom soyer wrote:

> Thanks Eric!
>
> I also noticed that in R, acf returns ac at lag 0, while pacf does not (pac
> for pacf starts at lag 1). Do you know if there is a good reason for that?
> Shouldn't ac at lag 0 always be 1?

No.  The acf is an autocovariance or autocorrelation function, depending 
on the arguments, and it is for multiple timeseries where the value at lag 
0 is the covariance/correlation matrix.


> On 4/27/07, Eric Thompson <[EMAIL PROTECTED]> wrote:
>>
>> The lines indicate the confidence interval (95% by default). I think
>> you mean that it is not documented in help(acf), but it directs you to
>> plot.acf in the "See Also" secion.
>>
>> From ?plot.acf:
>>
>> Note:
>>
>> The confidence interval plotted in 'plot.acf' is based on an
>> _uncorrelated_ series and should be treated with appropriate
>> caution.  Using 'ci.type = "ma"' may be less potentially
>> misleading.
>>
>> also see the description of the ci and ci.type arguments. As far as
>> HOW they are calculated, I believe that the default is
>>
>> qnorm(c(0.025, 0.975))/sqrt(n)
>>
>> And yes, I think that they are very important.
>>
>> Hope that helps.
>>
>> Eric
>>
>>
>> On 4/27/07, tom soyer <[EMAIL PROTECTED]> wrote:
>>> Hi,
>>>
>>> I noticed that whenever I ran acf or pacf, the plot generated by R
>> always
>>> includes two horizontal blue doted lines. Furthermore, these two lines
>> are
>>> not documented in the acf documentation. I don't know what they are for,
>> but
>>> it seems that they are important. Could someone tell me what they are
>> and
>>> how are they calculated?
>>>
>>> Thanks,
>>>
>>> --
>>> Tom
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@stat.math.ethz.ch 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.
>>>
>>
>
>
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch 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] Limit on vector evaluation

2007-04-27 Thread jim holtman
try this way instead:

> system.time(x <- sapply(1:10, function(x)mean(rnorm(10, mean=9, sd=1.5
[1] 5.44 0.00 5.95   NA   NA
> str(x)
 num [1:10] 10.11  9.17  9.33  9.41 10.14 ...
>



On 4/27/07, Robert Barber <[EMAIL PROTECTED]> wrote:
> Dear R Experts,
>
> Why I try to run this expression:
>
> x<-sapply(rnorm(rep(10,10),mean=9,sd=1.5),mean)
>
> it evaluates the first 1 values and then stops, but does not return
> to the command prompt.  My cpu keeps running at 100%.  When I exit the
> expression with CTL-C, I then see that x holds 1 values.  How can I
> evalute the expression 10 times, or more if I want?
>
> Thanks in advance.
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@stat.math.ethz.ch 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] Configuring R-2.5.0 for X11 on Red Hat WS 4 x86-64

2007-04-27 Thread Bruce Foster
I have been unable to configure R-2.5.0 for the X11 interface on Red 
Hat WS 4 x86-64 (AMD Opteron).

The configure script looks for XtToolkitInitialize in libXt, and does 
not find it because it's not in libXt (which is present, however).

I tried installing openmotif and openmotif-devel, and that is no help.

How do I configure the X11 interface under this situations?

Thanks,
Bruce

__
R-help@stat.math.ethz.ch 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] Limit on vector evaluation

2007-04-27 Thread Duncan Murdoch
On 4/27/2007 7:13 PM, Robert Barber wrote:
> Dear R Experts,
> 
> Why I try to run this expression:
> 
> x<-sapply(rnorm(rep(10,10),mean=9,sd=1.5),mean)
> 
> it evaluates the first 1 values and then stops, but does not return
> to the command prompt.  My cpu keeps running at 100%.  When I exit the
> expression with CTL-C, I then see that x holds 1 values.  How can I
> evalute the expression 10 times, or more if I want?

If you interrupt the calculation, then x will be unchanged.  You see 
1 values there because there were 1 values the last time you 
finished an assignment to x.

But more importantly, I think you don't understand what your expression 
is calculating.  If you try it with smaller numbers, bit by bit, you may 
be surprised:

 > rnorm(rep(10, 3), mean=9, sd=1.5)
[1] 8.790434 8.29 8.935716

This doesn't give you 3 sets of 10 values, it gives you one vector of 3 
values.

 > sapply(.Last.value, mean)
[1] 8.790434 8.29 8.935716

This takes the mean of each entry:  i.e. it does nothing.  I doubt this 
is what you intended to do.

I suspect what you wanted was to generate 10 sets of 10 values, and 
take the mean of each set.  You can do that this way:

x <- replicate(10, mean(rnorm(10, mean=9, sd=1.5)))

Duncan Murdoch

__
R-help@stat.math.ethz.ch 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] like SPSS

2007-04-27 Thread Natalie O'Toole
Hi,

I've written code to extact a pumf file in R, subset it, and weight it 
like you would do in SPSS. My code is below & it works great. My question 
is: how do i then calculate the frequencies of smokers (1) versus 
non-smokers (2) after having weighted my file? or even the process that 
SPSS is going through to aggregate the data?

Thanks,

Nat


Here is my code:

myfile<-("c:/test2.txt") 
mysubset<-myfile
mysubset$Y_Q02 <-mysubset$DVSELF <-NULL
mysubset2<-mysubset
mysubset2$Y_Q10B <-mysubset2$GP2_07 <-NULL

myVariableNames<-c("PUMFID","PROV","REGION","GRADE","Y_Q10A","WTPP")
myVariableWidths<-c(5,2,1,2,1,12.4)


mysubset2<-read.fwf( 
file=myfile, 
width=myVariableWidths, 
col.names=myVariableNames, 
row.names="PUMFID", 
fill=TRUE, 
strip.white=TRUE) 



print(mysubset2)

happyguys<-subset(mysubset2, PROV==48 & GRADE == 7  & Y_Q10A < 9)
print(happyguys)

 data.frame<-happyguys


> df<-data.frame(PROV,REGION,GRADE,Y_Q10A,WTPP)
> df1 <- df[, 1:4] * df[, 5]
> print(df1)






 

This communication is intended for the use of the recipient to which it is 
addressed, and may
contain confidential, personal, and or privileged information. Please 
contact the sender
immediately if you are not the intended recipient of this communication, 
and do not copy,
distribute, or take action relying on it. Any communication received in 
error, or subsequent
reply, should be deleted or destroyed.
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] xy plot key colors don't match plot

2007-04-27 Thread Ken Nussear
Deepayan fixed it in the end with this command. Posting for future  
questions.

Thanks!

Ken


xyplot(DistanceMeters~Hours, groups=Surveyor, xlab="Time (h)",  
ylab="Distace Moved(m)", par.settings = list(superpose.symbol = list 
(  pch = c(1, 16), col=c("black","black"))), auto.key=list(space =  
"right"))


On Apr 27, 2007, at 4:17 PM, Deepayan Sarkar wrote:

> On 4/27/07, Ken Nussear <[EMAIL PROTECTED]> wrote:
>> Hi
>>
>> Trying to finish a simple xyplot, but the key colors don't match
>> those specified on the plot. I have only been able to change the
>> color of the key text, but not the points.
>>
>>
>> Hours <- c
>> (25.88,32.31,24.04,23.27,16.64,19.75,27.25,17.9,20.45,29.65,20.83,27. 
>> 17,
>> 28.42,28,18.85,17.4,19.75,25.34,23.23,29.85,28.96,25.6,14.67,20.55,25 
>> .77
>> ,
>> 23.18,30.37,25.68,24.74,23.57,20.12,15.47,27.63,35,21.88,23.17,26.65, 
>> 26.
>> 5,19.64,19.57,26.67,23.03,21.85,28.43,27.11,17.43,24.36,23.88,24.13,3 
>> 1.2
>> 7,28.82)
>>
>> DistanceMeters <- c
>> (244.77,101.49,188.54,94.76,4.31,34.83,91.76,8.5,1,475.71,337.13,737. 
>> 32,
>> 272.06,173.71,5.39,45.39,92.69,304.39,487.79,342.87,396.17,382.04,1,0 
>> ,26
>> 9.4,441.37,303.39,330.39,169.89,462.5,84.62,41.24,1,574.75,5.65,61.52 
>> ,16
>> 0.99,94.14,103.93,24.38,575.64,4.15,251.73,347.13,5.8,69.92,477.86,46 
>> 5.7
>> 3,152.09,390.05,205.81)
>>
>> Surveyor <- as.factor(c
>> ("K9","Human","K9","Human","Human","Human","K9","Human","Human","K9", 
>> "K9
>> ","K9","K9","Human","Human","Human","Human","Human","K9","Human","Hum 
>> an"
>> ,"K9","Human","Human","K9","Human","Human","Human","Human","Human","K 
>> 9",
>> "K9","K9","Human","Human","K9","K9","K9","Human","Human","Human","Hum 
>> an"
>> ,"Human","K9","Human","Human","K9","Human","Human","Human","Human"))
>>
>> library(lattice)
>>
>>
>> xyplot(DistanceMeters~Hours, groups=Surveyor, xlab="Time (h)",
>> ylab="Distace Moved (m)", pch = c(1, 16), col=c("black","black"),
>> auto.key=T)
>
> You need
>
> xyplot(DistanceMeters~Hours, groups=Surveyor, [...] ,
>   par.settings = list(superpose.symbol = list(
> pch = c(1, 16), col=c("black","black")),
>   auto.key=TRUE)
>
> -Deepayan


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Restructuring Hadley CET data

2007-04-27 Thread Gabor Grothendieck
Here is a bit more.  It creates a zoo series.

URL <- "http://hadobs.metoffice.com/hadcet/cetdl1772on.dat";
DF <- read.table(URL, col.names = c("Year", "DoM", 1:12), check = FALSE)

library(reshape)
long <- melt(DF, c("Year", "DoM"))
long <- subset(long, value != -999)

library(zoo)
dd <- as.Date(with(long, paste(Year, variable, DoM, sep = "-")))
z <- zoo(long$value, dd)


On 4/27/07, hadley wickham <[EMAIL PROTECTED]> wrote:
> Ooops, add library(reshape) before that, and see
> http://had.co.nz/reshape for more info
>
> Hadley
>
> On 4/27/07, hadley wickham <[EMAIL PROTECTED]> wrote:
> > Hi Ted,
> >
> > melt(df, id=c("year","DoM"))
> > should get you started.
> >
> > Hadley
> >
> > On 4/27/07, Ted Harding <[EMAIL PROTECTED]> wrote:
> > > Hi Folks,
> > > I have a nasty data restructuring problem!
> > >
> > > I can think of one or two really clumsy ways of doing it
> > > with 'for' loops and the like, but I can't think of a
> > > *neat* way of doing it in R.
> > >
> > > The data are the Hadley Centre "Central England Temperature"
> > > series, daily from 01/01/1772 to 31/03/2007, and can be
> > > viewed/downloaded at
> > >
> > >   http://hadobs.metoffice.com/hadcet/cetdl1772on.dat
> > >
> > > and the structure is as follows:
> > >
> > > Year DoM Jan  Feb Mar  Apr May  Jun Jul Aug  Sep Oct  Nov Dec
> > > -
> > > 1772  1   32  -15  18   25  87  128 187 177  105 111   78 112
> > > 1772  2   207  28   38  77  138 154 158  143 150   85  62
> > > 1772  3   27   15  36   33  84  170 139 153  113 124   83  60
> > > 1772  4   27  -25  61   58  96   90 151 160  173 114   60  47
> > > 1772  5   15   -5  68   69 133  146 179 170  173 116   83  50
> > > 1772  6   22  -45  51   77 113  105 175 198  160 134  134  42
> > > .
> > > .
> > > 1772 270   46  66   74  77  198 156 144   76 104   45   5
> > > 1772 28   15   77  86   64 116  167 151 155   66  84   60  10
> > > 1772 29  -33   56  83   50 113  131 170 182  135 140   63  12
> > > 1772 30  -10 -999  66   77 121  122 179 163  143 143   55  15
> > > 1772 31   -8 -999  46 -999 108 -999 168 144 -999 145 -999  22
> > > 1773  1   200  79   13  93  174 104 151  171 131   68  55
> > > 1773  2   10   17  71   25  65  109 128 184  164  91   34  75
> > > 1773  35  -28  94   70  41   79 135 192  149 101   78  85
> > > 1773  45  -23  99  107  49  107 144 173  144  98   86  83
> > > 1773  5  -28  -30  76   65  83  128 144 182  116  98   66  38
> > > .
> > >
> > > "DoM" is Day of Month, 1-31 for each month ("short" months
> > > get entries -999 on missing days).
> > >
> > > So each year is a block of 31 lines and 14 columns, pf
> > > which the last 12 are Temperature (in 10ths of a degreeC),
> > > each column a month, running down each column for the
> > > 31 days of the month in that year.
> > >
> > > What I want to do is convert this into a 4-column format:
> > >
> > >   Year, Month, DoM, Temp
> > >
> > > with a separate row for each consecutive day from 01/01/1772
> > > to 31/02/2007, and omitting days which have a "-999" entry
> > > (OK I still have to check that "-999" is only used for DoMs
> > > which don't exist, and don't also indicate that a Temperature
> > > may be missing for some other reason; but I believe the series
> > > to be complete).
> > >
> > > What it boils down to is stacking the 12 31-day Temperature
> > > columns on top of each other in each year, filling in the
> > > Year, Month, DoM, and stacking the results for consecutive
> > > years on top of each other (after which one can strike out
> > > the "-999"s). Hence, really clunky for-loops!
> > >
> > > Any really *neat* ideas for this?
> > >
> > > With thanks,
> > > Ted.
> > >
> > > 
> > > E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
> > > Fax-to-email: +44 (0)870 094 0861
> > > Date: 27-Apr-07   Time: 22:24:51
> > > -- XFMail --
> > >
> > > __
> > > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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, 

Re: [R] xy plot key colors don't match plot

2007-04-27 Thread Deepayan Sarkar
On 4/27/07, Ken Nussear <[EMAIL PROTECTED]> wrote:
> Hi
>
> Trying to finish a simple xyplot, but the key colors don't match
> those specified on the plot. I have only been able to change the
> color of the key text, but not the points.
>
>
> Hours <- c
> (25.88,32.31,24.04,23.27,16.64,19.75,27.25,17.9,20.45,29.65,20.83,27.17,
> 28.42,28,18.85,17.4,19.75,25.34,23.23,29.85,28.96,25.6,14.67,20.55,25.77
> ,
> 23.18,30.37,25.68,24.74,23.57,20.12,15.47,27.63,35,21.88,23.17,26.65,26.
> 5,19.64,19.57,26.67,23.03,21.85,28.43,27.11,17.43,24.36,23.88,24.13,31.2
> 7,28.82)
>
> DistanceMeters <- c
> (244.77,101.49,188.54,94.76,4.31,34.83,91.76,8.5,1,475.71,337.13,737.32,
> 272.06,173.71,5.39,45.39,92.69,304.39,487.79,342.87,396.17,382.04,1,0,26
> 9.4,441.37,303.39,330.39,169.89,462.5,84.62,41.24,1,574.75,5.65,61.52,16
> 0.99,94.14,103.93,24.38,575.64,4.15,251.73,347.13,5.8,69.92,477.86,465.7
> 3,152.09,390.05,205.81)
>
> Surveyor <- as.factor(c
> ("K9","Human","K9","Human","Human","Human","K9","Human","Human","K9","K9
> ","K9","K9","Human","Human","Human","Human","Human","K9","Human","Human"
> ,"K9","Human","Human","K9","Human","Human","Human","Human","Human","K9",
> "K9","K9","Human","Human","K9","K9","K9","Human","Human","Human","Human"
> ,"Human","K9","Human","Human","K9","Human","Human","Human","Human"))
>
> library(lattice)
>
>
> xyplot(DistanceMeters~Hours, groups=Surveyor, xlab="Time (h)",
> ylab="Distace Moved (m)", pch = c(1, 16), col=c("black","black"),
> auto.key=T)

You need

xyplot(DistanceMeters~Hours, groups=Surveyor, [...] ,
   par.settings = list(superpose.symbol = list(
 pch = c(1, 16), col=c("black","black")),
   auto.key=TRUE)

-Deepayan

__
R-help@stat.math.ethz.ch 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] Restructuring Hadley CET data

2007-04-27 Thread Ted Harding
On 27-Apr-07 22:43:58, hadley wickham wrote:
> Ooops, add library(reshape) before that, and see
> http://had.co.nz/reshape for more info
> 
> Hadley
> 
> On 4/27/07, hadley wickham <[EMAIL PROTECTED]> wrote:
>> Hi Ted,
>>
>> melt(df, id=c("year","DoM"))
>> should get you started.
>>
>> Hadley
>>
>> On 4/27/07, Ted Harding <[EMAIL PROTECTED]> wrote:
>> > Hi Folks,
>> > I have a nasty data restructuring problem!
[...]

Thanks for the pointer, Hadley -- I hadn't come across these before.
I'll have a look!
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 28-Apr-07   Time: 00:15:45
-- XFMail --

__
R-help@stat.math.ethz.ch 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] Limit on vector evaluation

2007-04-27 Thread Robert Barber
Dear R Experts,

Why I try to run this expression:

x<-sapply(rnorm(rep(10,10),mean=9,sd=1.5),mean)

it evaluates the first 1 values and then stops, but does not return
to the command prompt.  My cpu keeps running at 100%.  When I exit the
expression with CTL-C, I then see that x holds 1 values.  How can I
evalute the expression 10 times, or more if I want?

Thanks in advance.

__
R-help@stat.math.ethz.ch 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] xy plot key colors don't match plot

2007-04-27 Thread Ken Nussear
Hi

Trying to finish a simple xyplot, but the key colors don't match  
those specified on the plot. I have only been able to change the  
color of the key text, but not the points.


Hours <- c 
(25.88,32.31,24.04,23.27,16.64,19.75,27.25,17.9,20.45,29.65,20.83,27.17, 
28.42,28,18.85,17.4,19.75,25.34,23.23,29.85,28.96,25.6,14.67,20.55,25.77 
, 
23.18,30.37,25.68,24.74,23.57,20.12,15.47,27.63,35,21.88,23.17,26.65,26. 
5,19.64,19.57,26.67,23.03,21.85,28.43,27.11,17.43,24.36,23.88,24.13,31.2 
7,28.82)

DistanceMeters <- c 
(244.77,101.49,188.54,94.76,4.31,34.83,91.76,8.5,1,475.71,337.13,737.32, 
272.06,173.71,5.39,45.39,92.69,304.39,487.79,342.87,396.17,382.04,1,0,26 
9.4,441.37,303.39,330.39,169.89,462.5,84.62,41.24,1,574.75,5.65,61.52,16 
0.99,94.14,103.93,24.38,575.64,4.15,251.73,347.13,5.8,69.92,477.86,465.7 
3,152.09,390.05,205.81)

Surveyor <- as.factor(c 
("K9","Human","K9","Human","Human","Human","K9","Human","Human","K9","K9 
","K9","K9","Human","Human","Human","Human","Human","K9","Human","Human" 
,"K9","Human","Human","K9","Human","Human","Human","Human","Human","K9", 
"K9","K9","Human","Human","K9","K9","K9","Human","Human","Human","Human" 
,"Human","K9","Human","Human","K9","Human","Human","Human","Human"))

library(lattice)


xyplot(DistanceMeters~Hours, groups=Surveyor, xlab="Time (h)",  
ylab="Distace Moved (m)", pch = c(1, 16), col=c("black","black"),  
auto.key=T)

Produces dots correctly, but not the points in the key. Switching to  
simpleKey I have only been able to change the color of the key text,  
but not the points.

xyplot(DistanceMeters~Hours, groups=Surveyor, xlab="Time (h)",  
ylab="Distace Moved (m)", pch = c(1, 16), col=c("black","black"),  
key=simpleKey( points = TRUE, text=c("Human", "Dog"), pch=c(1,16),  
col=c("black","black"), space = "right"))

Can anyone help?


Thanks

Ken

__
R-help@stat.math.ethz.ch 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] Restructuring Hadley CET data

2007-04-27 Thread hadley wickham
Ooops, add library(reshape) before that, and see
http://had.co.nz/reshape for more info

Hadley

On 4/27/07, hadley wickham <[EMAIL PROTECTED]> wrote:
> Hi Ted,
>
> melt(df, id=c("year","DoM"))
> should get you started.
>
> Hadley
>
> On 4/27/07, Ted Harding <[EMAIL PROTECTED]> wrote:
> > Hi Folks,
> > I have a nasty data restructuring problem!
> >
> > I can think of one or two really clumsy ways of doing it
> > with 'for' loops and the like, but I can't think of a
> > *neat* way of doing it in R.
> >
> > The data are the Hadley Centre "Central England Temperature"
> > series, daily from 01/01/1772 to 31/03/2007, and can be
> > viewed/downloaded at
> >
> >   http://hadobs.metoffice.com/hadcet/cetdl1772on.dat
> >
> > and the structure is as follows:
> >
> > Year DoM Jan  Feb Mar  Apr May  Jun Jul Aug  Sep Oct  Nov Dec
> > -
> > 1772  1   32  -15  18   25  87  128 187 177  105 111   78 112
> > 1772  2   207  28   38  77  138 154 158  143 150   85  62
> > 1772  3   27   15  36   33  84  170 139 153  113 124   83  60
> > 1772  4   27  -25  61   58  96   90 151 160  173 114   60  47
> > 1772  5   15   -5  68   69 133  146 179 170  173 116   83  50
> > 1772  6   22  -45  51   77 113  105 175 198  160 134  134  42
> > .
> > .
> > 1772 270   46  66   74  77  198 156 144   76 104   45   5
> > 1772 28   15   77  86   64 116  167 151 155   66  84   60  10
> > 1772 29  -33   56  83   50 113  131 170 182  135 140   63  12
> > 1772 30  -10 -999  66   77 121  122 179 163  143 143   55  15
> > 1772 31   -8 -999  46 -999 108 -999 168 144 -999 145 -999  22
> > 1773  1   200  79   13  93  174 104 151  171 131   68  55
> > 1773  2   10   17  71   25  65  109 128 184  164  91   34  75
> > 1773  35  -28  94   70  41   79 135 192  149 101   78  85
> > 1773  45  -23  99  107  49  107 144 173  144  98   86  83
> > 1773  5  -28  -30  76   65  83  128 144 182  116  98   66  38
> > .
> >
> > "DoM" is Day of Month, 1-31 for each month ("short" months
> > get entries -999 on missing days).
> >
> > So each year is a block of 31 lines and 14 columns, pf
> > which the last 12 are Temperature (in 10ths of a degreeC),
> > each column a month, running down each column for the
> > 31 days of the month in that year.
> >
> > What I want to do is convert this into a 4-column format:
> >
> >   Year, Month, DoM, Temp
> >
> > with a separate row for each consecutive day from 01/01/1772
> > to 31/02/2007, and omitting days which have a "-999" entry
> > (OK I still have to check that "-999" is only used for DoMs
> > which don't exist, and don't also indicate that a Temperature
> > may be missing for some other reason; but I believe the series
> > to be complete).
> >
> > What it boils down to is stacking the 12 31-day Temperature
> > columns on top of each other in each year, filling in the
> > Year, Month, DoM, and stacking the results for consecutive
> > years on top of each other (after which one can strike out
> > the "-999"s). Hence, really clunky for-loops!
> >
> > Any really *neat* ideas for this?
> >
> > With thanks,
> > Ted.
> >
> > 
> > E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
> > Fax-to-email: +44 (0)870 094 0861
> > Date: 27-Apr-07   Time: 22:24:51
> > -- XFMail --
> >
> > __
> > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Restructuring Hadley CET data

2007-04-27 Thread hadley wickham
Hi Ted,

melt(df, id=c("year","DoM"))
should get you started.

Hadley

On 4/27/07, Ted Harding <[EMAIL PROTECTED]> wrote:
> Hi Folks,
> I have a nasty data restructuring problem!
>
> I can think of one or two really clumsy ways of doing it
> with 'for' loops and the like, but I can't think of a
> *neat* way of doing it in R.
>
> The data are the Hadley Centre "Central England Temperature"
> series, daily from 01/01/1772 to 31/03/2007, and can be
> viewed/downloaded at
>
>   http://hadobs.metoffice.com/hadcet/cetdl1772on.dat
>
> and the structure is as follows:
>
> Year DoM Jan  Feb Mar  Apr May  Jun Jul Aug  Sep Oct  Nov Dec
> -
> 1772  1   32  -15  18   25  87  128 187 177  105 111   78 112
> 1772  2   207  28   38  77  138 154 158  143 150   85  62
> 1772  3   27   15  36   33  84  170 139 153  113 124   83  60
> 1772  4   27  -25  61   58  96   90 151 160  173 114   60  47
> 1772  5   15   -5  68   69 133  146 179 170  173 116   83  50
> 1772  6   22  -45  51   77 113  105 175 198  160 134  134  42
> .
> .
> 1772 270   46  66   74  77  198 156 144   76 104   45   5
> 1772 28   15   77  86   64 116  167 151 155   66  84   60  10
> 1772 29  -33   56  83   50 113  131 170 182  135 140   63  12
> 1772 30  -10 -999  66   77 121  122 179 163  143 143   55  15
> 1772 31   -8 -999  46 -999 108 -999 168 144 -999 145 -999  22
> 1773  1   200  79   13  93  174 104 151  171 131   68  55
> 1773  2   10   17  71   25  65  109 128 184  164  91   34  75
> 1773  35  -28  94   70  41   79 135 192  149 101   78  85
> 1773  45  -23  99  107  49  107 144 173  144  98   86  83
> 1773  5  -28  -30  76   65  83  128 144 182  116  98   66  38
> .
>
> "DoM" is Day of Month, 1-31 for each month ("short" months
> get entries -999 on missing days).
>
> So each year is a block of 31 lines and 14 columns, pf
> which the last 12 are Temperature (in 10ths of a degreeC),
> each column a month, running down each column for the
> 31 days of the month in that year.
>
> What I want to do is convert this into a 4-column format:
>
>   Year, Month, DoM, Temp
>
> with a separate row for each consecutive day from 01/01/1772
> to 31/02/2007, and omitting days which have a "-999" entry
> (OK I still have to check that "-999" is only used for DoMs
> which don't exist, and don't also indicate that a Temperature
> may be missing for some other reason; but I believe the series
> to be complete).
>
> What it boils down to is stacking the 12 31-day Temperature
> columns on top of each other in each year, filling in the
> Year, Month, DoM, and stacking the results for consecutive
> years on top of each other (after which one can strike out
> the "-999"s). Hence, really clunky for-loops!
>
> Any really *neat* ideas for this?
>
> With thanks,
> Ted.
>
> 
> E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
> Fax-to-email: +44 (0)870 094 0861
> Date: 27-Apr-07   Time: 22:24:51
> -- XFMail --
>
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread John Kane
When I reread it, I think you are right. I read split
the data plot and assumed a backround rather than just
the points .  
--- Petr Klasterecky <[EMAIL PROTECTED]>
wrote:

> If I understand correctly what A. Ezhil asked for,
> polygons won't help 
> here. For coloring the individual points check
> ?points and use subsets, e.g.
> 
> plot(x,y)
> points(x[x>y-1],y[x>y-1], col="red")
> 
> or something similar.
> Petr
> 
> John Kane napsal(a):
> > Here is a recent posting by Petr Klasterecky  that
> > does not seem to be on the archive yet that may
> help.
> > --
> > 
> > What do you mean by background? Maybe this is
> enough:
> > 
> > plot(seq(-3,3,.01), dnorm(seq(-3,3,.01)),
> type="n",
> > xlab="x", 
> > ylab="f(x)", main="Normal density")
> > polygon(x=c(-4,0,0,-4), y=c(-1,-1,.5,.5),
> col="red")
> > polygon(x=c(4,0,0,4), y=c(-1,-1,.5,.5),
> col="blue")
> > lines(seq(-3,3,.01), dnorm(seq(-3,3,.01)),
> type="l",
> > lwd=2)
> > 
> > Play a little bit with the polygon margins to get
> what
> > you need. You 
> > can 
> > even generate them automatically based on your
> data.
> > 
> > Petr
> > ---
> > --- A Ezhil <[EMAIL PROTECTED]> wrote:
> > 
> >> Dear All,
> >>
> >> I am using the following commands to do the
> scatter
> >> plot of two vectors, say X and Y.
> >>
> >> plot(X,Y, col="blue")
> >> abline(a=1,b=1, col="red")
> >> abline(a=-1,b=1, col="green")
> >>
> >> I would like to split the scatter plot into 3
> part
> >> with 3 different colors: (i) points lies between
> 2
> >> lines, (ii) points above line 1, and (iii) points
> >> below line 2. I am struggling to do this. I would
> >> greatly appreciate any help in doing this.
> >>
> >> Thanks in advance.
> >>
> >> Kind regards,
> >> Ezhil
> >>
> >> __
> >> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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.
> > 
> 
> -- 
> Petr Klasterecky
> Dept. of Probability and Statistics
> Charles University in Prague
> Czech Republic
>

__
R-help@stat.math.ethz.ch 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] acf and pacf plot

2007-04-27 Thread tom soyer
Thanks Eric!

I also noticed that in R, acf returns ac at lag 0, while pacf does not (pac
for pacf starts at lag 1). Do you know if there is a good reason for that?
Shouldn't ac at lag 0 always be 1?


On 4/27/07, Eric Thompson <[EMAIL PROTECTED]> wrote:
>
> The lines indicate the confidence interval (95% by default). I think
> you mean that it is not documented in help(acf), but it directs you to
> plot.acf in the "See Also" secion.
>
> From ?plot.acf:
>
> Note:
>
> The confidence interval plotted in 'plot.acf' is based on an
> _uncorrelated_ series and should be treated with appropriate
> caution.  Using 'ci.type = "ma"' may be less potentially
> misleading.
>
> also see the description of the ci and ci.type arguments. As far as
> HOW they are calculated, I believe that the default is
>
> qnorm(c(0.025, 0.975))/sqrt(n)
>
> And yes, I think that they are very important.
>
> Hope that helps.
>
> Eric
>
>
> On 4/27/07, tom soyer <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I noticed that whenever I ran acf or pacf, the plot generated by R
> always
> > includes two horizontal blue doted lines. Furthermore, these two lines
> are
> > not documented in the acf documentation. I don't know what they are for,
> but
> > it seems that they are important. Could someone tell me what they are
> and
> > how are they calculated?
> >
> > Thanks,
> >
> > --
> > Tom
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch 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.
> >
>



-- 
Tom

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Restructuring Hadley CET data

2007-04-27 Thread Ted Harding
Hi Folks,
I have a nasty data restructuring problem!

I can think of one or two really clumsy ways of doing it
with 'for' loops and the like, but I can't think of a
*neat* way of doing it in R.

The data are the Hadley Centre "Central England Temperature"
series, daily from 01/01/1772 to 31/03/2007, and can be
viewed/downloaded at

  http://hadobs.metoffice.com/hadcet/cetdl1772on.dat

and the structure is as follows:

Year DoM Jan  Feb Mar  Apr May  Jun Jul Aug  Sep Oct  Nov Dec
-
1772  1   32  -15  18   25  87  128 187 177  105 111   78 112
1772  2   207  28   38  77  138 154 158  143 150   85  62
1772  3   27   15  36   33  84  170 139 153  113 124   83  60
1772  4   27  -25  61   58  96   90 151 160  173 114   60  47
1772  5   15   -5  68   69 133  146 179 170  173 116   83  50
1772  6   22  -45  51   77 113  105 175 198  160 134  134  42
.
.
1772 270   46  66   74  77  198 156 144   76 104   45   5
1772 28   15   77  86   64 116  167 151 155   66  84   60  10
1772 29  -33   56  83   50 113  131 170 182  135 140   63  12
1772 30  -10 -999  66   77 121  122 179 163  143 143   55  15
1772 31   -8 -999  46 -999 108 -999 168 144 -999 145 -999  22
1773  1   200  79   13  93  174 104 151  171 131   68  55
1773  2   10   17  71   25  65  109 128 184  164  91   34  75
1773  35  -28  94   70  41   79 135 192  149 101   78  85
1773  45  -23  99  107  49  107 144 173  144  98   86  83
1773  5  -28  -30  76   65  83  128 144 182  116  98   66  38
.

"DoM" is Day of Month, 1-31 for each month ("short" months
get entries -999 on missing days).

So each year is a block of 31 lines and 14 columns, pf
which the last 12 are Temperature (in 10ths of a degreeC),
each column a month, running down each column for the
31 days of the month in that year.

What I want to do is convert this into a 4-column format:

  Year, Month, DoM, Temp

with a separate row for each consecutive day from 01/01/1772
to 31/02/2007, and omitting days which have a "-999" entry
(OK I still have to check that "-999" is only used for DoMs
which don't exist, and don't also indicate that a Temperature
may be missing for some other reason; but I believe the series
to be complete).

What it boils down to is stacking the 12 31-day Temperature
columns on top of each other in each year, filling in the
Year, Month, DoM, and stacking the results for consecutive
years on top of each other (after which one can strike out
the "-999"s). Hence, really clunky for-loops!

Any really *neat* ideas for this?

With thanks,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 27-Apr-07   Time: 22:24:51
-- XFMail --

__
R-help@stat.math.ethz.ch 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] how to evaluate a dynamic variable?

2007-04-27 Thread Don MacQueen
Does
   get(DV)
do what you want?

-Don

At 4:35 PM -0400 4/27/07, Bobby Prill wrote:
>Please help me evaluate a "dynamic variable" as show in the code 
>snippet below.
>
># regular variable
>a = c(1,2,3,4)
>
># dynamic variable set at runtime
>DV = "a"
>
>eval(DV)
>--> a
>
>eval(eval(DV))
>--> a
>
># what I want
>something_goes_here(DV)
>-->  1,2,3,4
>
>Can someone teach me how to do this?  Thanks very much.
>
>- Bobby
>
>__
>R-help@stat.math.ethz.ch 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 MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

__
R-help@stat.math.ethz.ch 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] weight

2007-04-27 Thread Natalie O'Toole
Does anyone know why it is giving me this error? Any help would be greatly 
appreciated!!

Thanks,

Nat



myfile<-("c:/test2.txt")
mysubset<-myfile
mysubset$Y_Q02 <-mysubset$DVSELF <-NULL
mysubset2<-mysubset
mysubset2$Y_Q10B <-mysubset2$GP2_07 <-NULL

myVariableNames<-c("PUMFID=rnorm(10)","PROV=rnorm(10)","REGION=rnorm(10)","GRADE=rnorm(10)","Y_Q10A=rnorm(10)","WTPP=rnorm(10)")
> df<-mysubset2[, 2:5] * mysubset2[, 6]
myVariableWidths<-c(5,2,1,2,1,12.4)
df<-read.fwf(
file=myfile,
width=myVariableWidths,
col.names=myVariableNames,
row.names="PUMFID",
fill=TRUE,
strip.white=TRUE)

happyguys<-subset(df, PROV==48 & GRADE == 7  & Y_Q10A < 9)
print(happyguys)


where it is bolded, i'm getting the following error: Error in mysubset2[, 
2:5] : incorrect number of dimensions

__

__


Hi Dr. Kubovy,

Here is my code so far: My question is: how do I then get a frequency
count of Y_Q10A with the WTPP applied to it?

myfile<-("c:/test2.txt")
mysubset<-myfile
mysubset$Y_Q02 <-mysubset$DVSELF <-NULL
mysubset2<-mysubset
mysubset2$Y_Q10B <-mysubset2$GP2_07 <-NULL

myVariableNames<-c("PUMFID","PROV","REGION","GRADE","Y_Q10A","WTPP")
myVariableWidths<-c(5,2,1,2,1,12.4)


mysubset2<-read.fwf(
file=myfile,
width=myVariableWidths,
col.names=myVariableNames,
row.names="PUMFID",
fill=TRUE,
strip.white=TRUE)



print(mysubset2)

happyguys<-subset(mysubset2, PROV==48 & GRADE == 7  & Y_Q10A < 9)
print(happyguys)


df <- data.frame(PROV = rnorm(10), REGION = rnorm(10), GRADE = rnorm
(10), Y_Q10A = rnorm(10), WTTP = rnorm(10))
df1 <- df[, 1:4] * df[, 5]

Thanks,

Nat


__


df <- data.frame(PROV = rnorm(10), REGION = rnorm(10), GRADE = rnorm
(10), Y_Q10A = rnorm(10), WTTP = rnorm(10))
df1 <- df[, 1:4] * df[, 5]
The column you were worried about is not part of the data.
You can get a vector of the record ids by
rownames(df)

On Apr 27, 2007, at 1:05 PM, Natalie O'Toole wrote:

> I have the file below called happyguys. It is a subset of data. How
> do I
> apply the weight variable (WTPP) to this file? Can i just multiply
> each
> column (except the first column because it is a record id) by WTPP?
> If the
> answer is yes, how do I multiply one variable name by another?
>
>   PROV REGION GRADE Y_Q10A WTPP
> 83  48  4 7  2 342233324020
> 115 48  4 7  1 434413433040
> 185 48  4 7  1 432312433040
> 222 48  4 7  2 13311030
> 242 48  4 7  1 421313332020
> 247 48  4 7  2 312134212030

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/





This communication is intended for the use of the recipient to which it is
addressed, and may
contain confidential, personal, and or privileged information. Please
contact the sender
immediately if you are not the intended recipient of this communication,
and do not copy,
distribute, or take action relying on it. Any communication received in
error, or subsequent
reply, should be deleted or destroyed.


This communication is intended for the use of the recipient to which it is
addressed, and may
contain confidential, personal, and or privileged information. Please
contact the sender
immediately if you are not the intended recipient of this communication,
and do not copy,
distribute, or take action relying on it. Any communication received in
error, or subsequent
reply, should be deleted or destroyed.
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.


 

This communication is intended for the use of the recipient to which it is 
addressed, and may
contain confidential, personal, and or privileged information. Please 
contact the sender
immediately if you are not the intended recipient of this communication, 
and do not copy,
distribute, or take action relying on it. Any communication received in 
error, or subsequent
reply, should be deleted or destroyed.
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailm

Re: [R] how to evaluate a dynamic variable?

2007-04-27 Thread Bobby Prill
Mark,

You're right.  Thank you.  Look, it works:

 > a = c(1,2,3)
 > a
[1] 1 2 3

 > b = "a"
 > b
[1] "a"

 > get(b)
[1] 1 2 3


On Apr 27, 2007, at 5:05 PM, Leeds, Mark (IED) wrote:

> check out get using ?get. I'm not an expert but that might help or
> work.
>
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Bobby Prill
> Sent: Friday, April 27, 2007 4:35 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] how to evaluate a dynamic variable?
>
> Please help me evaluate a "dynamic variable" as show in the code  
> snippet
> below.
>
> # regular variable
> a = c(1,2,3,4)
>
> # dynamic variable set at runtime
> DV = "a"
>
> eval(DV)
> --> a
>
> eval(eval(DV))
> --> a
>
> # what I want
> something_goes_here(DV)
> -->  1,2,3,4
>
> Can someone teach me how to do this?  Thanks very much.
>
> - Bobby
>
> __
> R-help@stat.math.ethz.ch 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.
> 
>
> This is not an offer (or solicitation of an offer) to buy/sell the  
> securities/instruments mentioned or an official confirmation.   
> Morgan Stanley may deal as principal in or own or act as market  
> maker for securities/instruments mentioned or may advise the  
> issuers.  This is not research and is not from MS Research but it  
> may refer to a research analyst/research report.  Unless indicated,  
> these views are the author's and may differ from those of Morgan  
> Stanley research or others in the Firm.  We do not represent this  
> is accurate or complete and we may not update this.  Past  
> performance is not indicative of future returns.  For additional  
> information, research reports and important disclosures, contact me  
> or see https://secure.ms.com/servlet/cls.  You should not use e- 
> mail to request, authorize or effect the purchase or sale of any  
> security or instrument, to send transfer instructions, or to effect  
> any other transactions.  We cannot guarantee that any such requests  
> received via e-mail will be processed in a timely manner.  This  
> communication is solely for the addressee(s) and may contain  
> confidential information.  We do not waive confidentiality by  
> mistransmission.  Contact me if you do not wish to receive these  
> communications.  In the UK, this communication is directed in the  
> UK to those persons who are market counterparties or intermediate  
> customers (as defined in the UK Financial Services Authority's rules).

__
R-help@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread Petr Klasterecky
If I understand correctly what A. Ezhil asked for, polygons won't help 
here. For coloring the individual points check ?points and use subsets, e.g.

plot(x,y)
points(x[x>y-1],y[x>y-1], col="red")

or something similar.
Petr

John Kane napsal(a):
> Here is a recent posting by Petr Klasterecky  that
> does not seem to be on the archive yet that may help.
> --
> 
> What do you mean by background? Maybe this is enough:
> 
> plot(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type="n",
> xlab="x", 
> ylab="f(x)", main="Normal density")
> polygon(x=c(-4,0,0,-4), y=c(-1,-1,.5,.5), col="red")
> polygon(x=c(4,0,0,4), y=c(-1,-1,.5,.5), col="blue")
> lines(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type="l",
> lwd=2)
> 
> Play a little bit with the polygon margins to get what
> you need. You 
> can 
> even generate them automatically based on your data.
> 
> Petr
> ---
> --- A Ezhil <[EMAIL PROTECTED]> wrote:
> 
>> Dear All,
>>
>> I am using the following commands to do the scatter
>> plot of two vectors, say X and Y.
>>
>> plot(X,Y, col="blue")
>> abline(a=1,b=1, col="red")
>> abline(a=-1,b=1, col="green")
>>
>> I would like to split the scatter plot into 3 part
>> with 3 different colors: (i) points lies between 2
>> lines, (ii) points above line 1, and (iii) points
>> below line 2. I am struggling to do this. I would
>> greatly appreciate any help in doing this.
>>
>> Thanks in advance.
>>
>> Kind regards,
>> Ezhil
>>
>> __
>> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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.
> 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

__
R-help@stat.math.ethz.ch 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] how to evaluate a dynamic variable?

2007-04-27 Thread Greg Snow
What are you trying to do with that?  Most times when someone asks this
question, they are trying to accomplish something that can be done
better a different way, so if you tell us what you are trying to
accomplish, we can suggest better approaches.

The short answer to your question is ?get.  

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Bobby Prill
> Sent: Friday, April 27, 2007 2:35 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] how to evaluate a dynamic variable?
> 
> Please help me evaluate a "dynamic variable" as show in the 
> code snippet below.
> 
> # regular variable
> a = c(1,2,3,4)
> 
> # dynamic variable set at runtime
> DV = "a"
> 
> eval(DV)
> --> a
> 
> eval(eval(DV))
> --> a
> 
> # what I want
> something_goes_here(DV)
> -->  1,2,3,4
> 
> Can someone teach me how to do this?  Thanks very much.
> 
> - Bobby
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] how to evaluate a dynamic variable?

2007-04-27 Thread Finny Kuruvilla
I'm not sure if I'm understanding what you're asking for but this may
be it:

> DV="b"
> assign(DV,1:4)
> DV
[1] "b"
> b
[1] 1 2 3 4


On Fri, 27 Apr 2007, Bobby Prill wrote:

> Please help me evaluate a "dynamic variable" as show in the code
> snippet below.
>
> # regular variable
> a = c(1,2,3,4)
>
> # dynamic variable set at runtime
> DV = "a"
>
> eval(DV)
> --> a
>
> eval(eval(DV))
> --> a
>
> # what I want
> something_goes_here(DV)
> -->  1,2,3,4
>
> Can someone teach me how to do this?  Thanks very much.
>
> - Bobby
>
> __
> R-help@stat.math.ethz.ch 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.
>

*
Finny Kuruvilla, MD, PhD
Harvard Medical School Fellowship Program in Transfusion Medicine
Broad Institute of MIT and Harvard
Homepage: http://www.people.fas.harvard.edu/~kuruvill/home/

__
R-help@stat.math.ethz.ch 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] xyplot() and controlling panel.polygon()

2007-04-27 Thread Michael Kubovy
I can't thank you enough! (I am also grateful to Sundar Dorai-Raj and  
Bert Gunter for their initial responses.)

On Apr 27, 2007, at 4:14 PM, Deepayan Sarkar wrote:

> On 4/27/07, Michael Kubovy <[EMAIL PROTECTED]> wrote:
>> Hi Deepayan,
>>
>> Your solution works, anf the polygon are drawn where I wanted them to
>> go. I thought that I could figure out how to gain control over the
>> colors of the four ensuing polygons (I'm trying to get two lighter
>> shades of the lines).
>>
>> I've tried, for example, to see if I could control the color of the
>> polyon outline, by adding border = 'red' to panel.polygon. That
>> didn't work. Does it work only in lpolygon()?
>
> No. This is a bug, and the border color can currently only be black or
> transparent (but it's easy to find and fix the bug; lpolygon is very
> short, so just write a replacement).
>
> However, panel.superpose recognizes and splits certain graphical
> parameters; border is not among them, but fill is. So you could do:
>
> my.panel.bands <-
>function(x, y, upper, lower,
> fill, col,
> subscripts, ..., font, fontface)
> {
>upper <- upper[subscripts]
>lower <- lower[subscripts]
>panel.polygon(c(x, rev(x)), c(upper, rev(lower)),
>  col = fill, border = FALSE,
>  ...)
> }
>
> xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
>   col = c("#0080ff", "#ff00ff"),
>   fill = c("#bbddff", "#ffbbff"),
>   upper = data$upper,
>   lower = data$lower,
>   panel = function(x, y, ...){
>   panel.superpose(x, y, panel.groups = 'my.panel.bands', ...)
>   panel.xyplot(x, y, ...)
>   })
>
>
>> I often can figure things out on my own, but obviously there's
>> something fundamental that I'm not getting about inheritance and
>> passing in these sorts of objects. I've been trying to get it from
>> the help pages and from Murrell's book, but neither offers enough of
>> a cookbook for me to figure these things out. Is there something I
>> should have read?
>
> The concepts are all there in the help page (but it's often difficult
> to put them together). The main points are:
>
> (1) unrecognized arguments get passed on to the panel function as is
> (2) subscripts give indices of x, y, etc in the original data frame
>
> (the implication being that if you have another column from the
> original data frame, such as upper and lower in your example, indexing
> by subscripts will give you the matching subset). Other than that, the
> panel functions have to do their own work (and what they do should
> ideally be documented); nothing is enforced, so nothing is guaranteed.
>
> This sort of thing doesn't get used often enough for examples to be
> easily found. The following demo in lattice might be helpful.
>
> file.show(system.file("demo/intervals.R", package = "lattice"))
>
> -Deepayan

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@stat.math.ethz.ch 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] acf and pacf plot

2007-04-27 Thread Eric Thompson
The lines indicate the confidence interval (95% by default). I think
you mean that it is not documented in help(acf), but it directs you to
plot.acf in the "See Also" secion.

>From ?plot.acf:

Note:

 The confidence interval plotted in 'plot.acf' is based on an
 _uncorrelated_ series and should be treated with appropriate
 caution.  Using 'ci.type = "ma"' may be less potentially
 misleading.

also see the description of the ci and ci.type arguments. As far as
HOW they are calculated, I believe that the default is

qnorm(c(0.025, 0.975))/sqrt(n)

And yes, I think that they are very important.

Hope that helps.

Eric


On 4/27/07, tom soyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I noticed that whenever I ran acf or pacf, the plot generated by R always
> includes two horizontal blue doted lines. Furthermore, these two lines are
> not documented in the acf documentation. I don't know what they are for, but
> it seems that they are important. Could someone tell me what they are and
> how are they calculated?
>
> Thanks,
>
> --
> Tom
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] how to evaluate a dynamic variable?

2007-04-27 Thread Bobby Prill
Please help me evaluate a "dynamic variable" as show in the code  
snippet below.

# regular variable
a = c(1,2,3,4)

# dynamic variable set at runtime
DV = "a"

eval(DV)
--> a

eval(eval(DV))
--> a

# what I want
something_goes_here(DV)
-->  1,2,3,4

Can someone teach me how to do this?  Thanks very much.

- Bobby

__
R-help@stat.math.ethz.ch 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] acf and pacf plot

2007-04-27 Thread tom soyer
Hi,

I noticed that whenever I ran acf or pacf, the plot generated by R always
includes two horizontal blue doted lines. Furthermore, these two lines are
not documented in the acf documentation. I don't know what they are for, but
it seems that they are important. Could someone tell me what they are and
how are they calculated?

Thanks,

-- 
Tom

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] xyplot() and controlling panel.polygon()

2007-04-27 Thread Deepayan Sarkar
On 4/27/07, Michael Kubovy <[EMAIL PROTECTED]> wrote:
> Hi Deepayan,
>
> Your solution works, anf the polygon are drawn where I wanted them to
> go. I thought that I could figure out how to gain control over the
> colors of the four ensuing polygons (I'm trying to get two lighter
> shades of the lines).
>
> I've tried, for example, to see if I could control the color of the
> polyon outline, by adding border = 'red' to panel.polygon. That
> didn't work. Does it work only in lpolygon()?

No. This is a bug, and the border color can currently only be black or
transparent (but it's easy to find and fix the bug; lpolygon is very
short, so just write a replacement).

However, panel.superpose recognizes and splits certain graphical
parameters; border is not among them, but fill is. So you could do:

my.panel.bands <-
function(x, y, upper, lower,
 fill, col,
 subscripts, ..., font, fontface)
{
upper <- upper[subscripts]
lower <- lower[subscripts]
panel.polygon(c(x, rev(x)), c(upper, rev(lower)),
  col = fill, border = FALSE,
  ...)
}

xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
   col = c("#0080ff", "#ff00ff"),
   fill = c("#bbddff", "#ffbbff"),
   upper = data$upper,
   lower = data$lower,
   panel = function(x, y, ...){
   panel.superpose(x, y, panel.groups = 'my.panel.bands', ...)
   panel.xyplot(x, y, ...)
   })


> I often can figure things out on my own, but obviously there's
> something fundamental that I'm not getting about inheritance and
> passing in these sorts of objects. I've been trying to get it from
> the help pages and from Murrell's book, but neither offers enough of
> a cookbook for me to figure these things out. Is there something I
> should have read?

The concepts are all there in the help page (but it's often difficult
to put them together). The main points are:

(1) unrecognized arguments get passed on to the panel function as is
(2) subscripts give indices of x, y, etc in the original data frame

(the implication being that if you have another column from the
original data frame, such as upper and lower in your example, indexing
by subscripts will give you the matching subset). Other than that, the
panel functions have to do their own work (and what they do should
ideally be documented); nothing is enforced, so nothing is guaranteed.

This sort of thing doesn't get used often enough for examples to be
easily found. The following demo in lattice might be helpful.

file.show(system.file("demo/intervals.R", package = "lattice"))

-Deepayan

__
R-help@stat.math.ethz.ch 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] bootstrap

2007-04-27 Thread Cody_Hamilton

Marc,

I believe the problem is with the function you are passing to the statistic
option.  According to the documentation for boot, the statistic option
provides:

 A function which when applied to data returns a vector containing the  
 statistic(s) of interest. When sim="parametric", the first argument to 
 statistic must be the data. For each replicate a simulated dataset 
 returned by ran.gen will be passed. In all other cases statistic must take 
 at least two arguments. The first argument passed will always be the   
 original data. The second will be a vector of indices, frequencies or  
 weights which define the bootstrap sample.  [italics added]

 I haven't verified this yet, but try   

 y <- rnorm(100)
 Quantile <- function(df,i){
quantile(df[i],  probs=c(0.05,0.95))
 }  
 boot.ci(boot.out,index=1,type='basic',conf=0.95)   
 boot.ci(boot.out,index=2,type='basic',conf=0.95)   

 This should give you a 95% CI on the 5th and 95th percentiles, 
 respectively.  

 Regards,   
 -Cody  







   
 Marc Bernard  
 <[EMAIL PROTECTED] 
 o.fr>  To 
 Sent by:  r-help@stat.math.ethz.ch
 [EMAIL PROTECTED]  cc 
 at.math.ethz.ch   
   Subject 
   [R] bootstrap   
 04/27/2007 03:36  
 AM
   
   
   
   




Dear All,

  I would like to use a nonparametric bootstrap to calculate the confidence
intervals for the 5% and 95% quantiles using boot.ci. As you know, boot.ci
requires the use of boot to generate bootstrap replicates for my statistic.
However this last function  doesn't work in my case because I am missing
something. Here is an example

  y <- rnorm(100)
  Quantile <- function(df)
{
quantile(df,  probs=c(0.05,0.95))
  }
  boot.out <- boot(y,Quantile, R=999, sim="ordinary")

  Error in statistic(data, original, ...) : unused argument(s) (c(1, 2, 3,
4, 5, 6, 7, 8

  I think  that it's due to another parameter (stype) that I have not
included but I don't know what this paremeter represents.

  Many thanks for any suggestion.

  Bernard



-

 [[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] weight

2007-04-27 Thread Natalie O'Toole
__


Hi Dr. Kubovy, 

Here is my code so far: My question is: how do I then get a frequency 
count of Y_Q10A with the WTPP applied to it? 

myfile<-("c:/test2.txt") 
mysubset<-myfile 
mysubset$Y_Q02 <-mysubset$DVSELF <-NULL
mysubset2<-mysubset 
mysubset2$Y_Q10B <-mysubset2$GP2_07 <-NULL 

myVariableNames<-c("PUMFID","PROV","REGION","GRADE","Y_Q10A","WTPP") 
myVariableWidths<-c(5,2,1,2,1,12.4) 


mysubset2<-read.fwf(  
file=myfile,  
width=myVariableWidths,  
col.names=myVariableNames,  
row.names="PUMFID",  
fill=TRUE,  
strip.white=TRUE)  



print(mysubset2)

happyguys<-subset(mysubset2, PROV==48 & GRADE == 7  & Y_Q10A < 9) 
print(happyguys) 


df <- data.frame(PROV = rnorm(10), REGION = rnorm(10), GRADE = rnorm  
(10), Y_Q10A = rnorm(10), WTTP = rnorm(10)) 
df1 <- df[, 1:4] * df[, 5]

Thanks, 

Nat 


__


df <- data.frame(PROV = rnorm(10), REGION = rnorm(10), GRADE = rnorm 
(10), Y_Q10A = rnorm(10), WTTP = rnorm(10))
df1 <- df[, 1:4] * df[, 5]
The column you were worried about is not part of the data.
You can get a vector of the record ids by
rownames(df)

On Apr 27, 2007, at 1:05 PM, Natalie O'Toole wrote:

> I have the file below called happyguys. It is a subset of data. How  
> do I
> apply the weight variable (WTPP) to this file? Can i just multiply  
> each
> column (except the first column because it is a record id) by WTPP?  
> If the
> answer is yes, how do I multiply one variable name by another?
>
>   PROV REGION GRADE Y_Q10A WTPP
> 83  48  4 7  2 342233324020
> 115 48  4 7  1 434413433040
> 185 48  4 7  1 432312433040
> 222 48  4 7  2 13311030
> 242 48  4 7  1 421313332020
> 247 48  4 7  2 312134212030

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/




 

This communication is intended for the use of the recipient to which it is 
addressed, and may
contain confidential, personal, and or privileged information. Please 
contact the sender
immediately if you are not the intended recipient of this communication, 
and do not copy,
distribute, or take action relying on it. Any communication received in 
error, or subsequent
reply, should be deleted or destroyed. 

 

This communication is intended for the use of the recipient to which it is 
addressed, and may
contain confidential, personal, and or privileged information. Please 
contact the sender
immediately if you are not the intended recipient of this communication, 
and do not copy,
distribute, or take action relying on it. Any communication received in 
error, or subsequent
reply, should be deleted or destroyed.
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Unsubscription Confirmation

2007-04-27 Thread Egoldsystem
Thank you for subscribing. You have now unsubscribed and no more messages will 
be sent.

__
R-help@stat.math.ethz.ch 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] xyplot() and controlling panel.polygon()

2007-04-27 Thread Michael Kubovy
Hi Deepayan,

Your solution works, anf the polygon are drawn where I wanted them to  
go. I thought that I could figure out how to gain control over the  
colors of the four ensuing polygons (I'm trying to get two lighter  
shades of the lines).

I've tried, for example, to see if I could control the color of the  
polyon outline, by adding border = 'red' to panel.polygon. That  
didn't work. Does it work only in lpolygon()?

I often can figure things out on my own, but obviously there's  
something fundamental that I'm not getting about inheritance and  
passing in these sorts of objects. I've been trying to get it from  
the help pages and from Murrell's book, but neither offers enough of  
a cookbook for me to figure these things out. Is there something I  
should have read?

Thanks,
MIchael

On Apr 27, 2007, at 2:25 PM, Deepayan Sarkar wrote:

> On 4/27/07, Michael Kubovy <[EMAIL PROTECTED]> wrote:
>> Hi Deepayan,
>>
>> Thanks for your advice. This is moving along, however:
>> The following is drawing the same polygons in each panel. I'm trying
>> to get a different polygon (confidence band) for each group in each
>> panel. That's why I thought I would need to pass groups and
>> subscripts to the panel.groups
>>
>> est <- c(1:4, 3:6, 7, 9, 11, 13, 12, 15, 18, 21)
>> cond <- rep(c('a','b'), each = 8)
>> grp <- rep(c('I', 'II'), each = 4, 2)
>> x <- rep(c(.5, .7, .9, 1.1), 4)
>> upper <- est + 1
>> lower = est - 1
>> data <- data.frame(est = est, x = x, cond = cond, grp = grp, upper =
>> upper, lower = lower)
>>
>> my.panel.polygon <- function(..., font, fontface)
>> {
>> panel.polygon(...)
>> }
>>
>> xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
>>  panel = function(x, y, ...){
>>  panel.superpose(c(x, rev(x)), c(upper, rev(lower)),
>>  panel.groups = 'my.panel.polygon', default.units =
>> 'native', ...)
>>  panel.xyplot(x, y, ...)
>>  }
>> )
>>
>> It's pretty clear that panel.superpose is not getting its x and y
>> values after they are split by group and panel.
>
> You are not even trying to do that; you have
>
>  panel.superpose(c(x, rev(x)), c(upper, rev(lower)), <...>
>
> so your x=c(x, rev(x)) is not the same length as x (and  
> subscripts), and your
> y = c(upper, rev(lower)) is not the same length as anything. Also,
> your upper and lower are being taken from the global env, not data
> (they happen to be the same, but since your data has them, I assume
> you want to use them).
>
> Perhaps you are looking for something like this:
>
>
> panel.bands <-
>function(x, y, upper, lower,
> subscripts, ..., font, fontface)
> {
>upper <- upper[subscripts]
>lower <- lower[subscripts]
>panel.polygon(c(x, rev(x)), c(upper, rev(lower)), ...)
> }
>
> xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
>   upper = data$upper,
>   lower = data$lower,
>   panel = function(x, y, ...){
>   panel.superpose(x, y, panel.groups = 'panel.bands', ...)
>   panel.xyplot(x, y, ...)
>   })
>
> -Deepayan

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@stat.math.ethz.ch 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] digest readability/ thunderbird email client/ R-help

2007-04-27 Thread Sam McClatchie
System:
Linux kernel 2.6.15 Ubuntu dapper
R version 2.4.1
ESS on Emacs 21.4.1
-
Colleagues

Has anyone figured out how to make the R-help digest more easily 
readable in the Thunderbird mail client? I think the digest used to be 
more readable than is currently the case with all of the messages as 
attachments.

I know the work around is to get individual messages rather than the 
digest, use another mail client, or just look at the archives on the web...

Best fishes

Sam

-- 
Sam McClatchie,
Fisheries oceanographer
Southwest Fisheries Science Center, NOAA,
8604 La Jolla Shores Drive
La Jolla, CA 92037-1508, U.S.A.
email <[EMAIL PROTECTED]>
work phone: 858 546 7083
Cellular:  858 752 8495
Research home page 

   /\
  ...>>
 
   <°)Xx><<
  /  \\
><(((°>
  >><(((°>   ...>>O<°)Xx><<

__
R-help@stat.math.ethz.ch 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] Quadratcount() plotting in R spatstat

2007-04-27 Thread beamer

Hello,

I am trying to plot a quadratcount object over a ppp object in the spatstat
package. I ultimately want to get something like this 
http://bg9.imslab.co.jp/Rhelp/R-2.4.0/src/library/spatstat/man/images/big_quadratcount_001.png
http://bg9.imslab.co.jp/Rhelp/R-2.4.0/src/library/spatstat/man/images/big_quadratcount_001.png


See 
http://66.102.9.104/search?q=cache:zK2o-grKXgEJ:bg9.imslab.co.jp/Rhelp/R-2.4.0/src/library/spatstat/man/quadratcount.html+quadratcount&hl=en&ct=clnk&cd=2&client=firefox-a
here , for example code.

When I plot the quadratcount output (a table) it plots a mosaic graph over
the points (try this line for instance plot(Titanic, main ="plot(Titanic,
main= *)")   ), not the quads I want.

I'd appreciate any idea on how I can get the quadratcount to plot correctly.

Thanks
John
-- 
View this message in context: 
http://www.nabble.com/Quadratcount%28%29-plotting-in-R-spatstat-tf3659113.html#a10224070
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] xyplot() and controlling panel.polygon()

2007-04-27 Thread Michael Kubovy
Hi Deepayan,

Thanks for your advice. This is moving along, however:
The following is drawing the same polygons in each panel. I'm trying  
to get a different polygon (confidence band) for each group in each  
panel. That's why I thought I would need to pass groups and  
subscripts to the panel.groups

est <- c(1:4, 3:6, 7, 9, 11, 13, 12, 15, 18, 21)
cond <- rep(c('a','b'), each = 8)
grp <- rep(c('I', 'II'), each = 4, 2)
x <- rep(c(.5, .7, .9, 1.1), 4)
upper <- est + 1
lower = est - 1
data <- data.frame(est = est, x = x, cond = cond, grp = grp, upper =
upper, lower = lower)

my.panel.polygon <- function(..., font, fontface)
{
panel.polygon(...)
}

xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
 panel = function(x, y, ...){
 panel.superpose(c(x, rev(x)), c(upper, rev(lower)),
 panel.groups = 'my.panel.polygon', default.units =  
'native', ...)
 panel.xyplot(x, y, ...)
 }
)

It's pretty clear that panel.superpose is not getting its x and y  
values after they are split by group and panel.

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread John Kane
Here is a recent posting by Petr Klasterecky  that
does not seem to be on the archive yet that may help.
--

What do you mean by background? Maybe this is enough:

plot(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type="n",
xlab="x", 
ylab="f(x)", main="Normal density")
polygon(x=c(-4,0,0,-4), y=c(-1,-1,.5,.5), col="red")
polygon(x=c(4,0,0,4), y=c(-1,-1,.5,.5), col="blue")
lines(seq(-3,3,.01), dnorm(seq(-3,3,.01)), type="l",
lwd=2)

Play a little bit with the polygon margins to get what
you need. You 
can 
even generate them automatically based on your data.

Petr
---
--- A Ezhil <[EMAIL PROTECTED]> wrote:

> Dear All,
> 
> I am using the following commands to do the scatter
> plot of two vectors, say X and Y.
> 
> plot(X,Y, col="blue")
> abline(a=1,b=1, col="red")
> abline(a=-1,b=1, col="green")
> 
> I would like to split the scatter plot into 3 part
> with 3 different colors: (i) points lies between 2
> lines, (ii) points above line 1, and (iii) points
> below line 2. I am struggling to do this. I would
> greatly appreciate any help in doing this.
> 
> Thanks in advance.
> 
> Kind regards,
> Ezhil
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Protocol for data inclusion in new packages

2007-04-27 Thread Doran, Harold
In the near future I will release MiscPsycho, a package that contains
various functions useful for applied psychometricians. I would like to
include some data sets for distribution in the package, but have not
created any of these on my own, but have used data distributed in other
packages such as the LSAT data in the ltm package.

Is it appropriate for me to distribute a data set in the package I
develop even though it originally came from another package? Or, is it
more appropriate for my package to depend on the package where the data
originally live?

The functions planned for the current distribution of MiscPsycho will
include:

1) JML estimation of Rasch and Master's partial credit model
2) Various IRT statistics (e.g., item information and test information
functions)
3) Various "Classical" statistics for item analysis
4) Coefficient alpha
5) Score conversion tables
6) Classification consistency analysis
7) Procedures for linking scales using mean equating 


Future development will include

* 2PL, 3PL, and GPCM also using JML
* Stocking-Lord procedure
* Various methods for assessing DIF, including MH
* Bayesian scoring methods (e.g., EAP)

The JML procedure is not the world's best technology as MML is commonly
preferred. However, that is already implemented in the ltm package and
these procedures are provided only for those who want to JML option. 

Thanks,
Harold



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Integrating R-programs into larger systems

2007-04-27 Thread Rajarshi Guha
On Fri, 2007-04-27 at 20:29 +0300, Ralf Finne wrote:
> Hi experts!
> 
> Have anybody experience in including an R-program 
> as part of a larger system?  In Matlab there is a toolbox
> that converts a m-script into C-code. 
> One application in mind is that I do the model building in R,
> for estimating the risk for cancer based on clinical measurements.
> 
> When the model is ready, a small R-program can simulate
> the model to estimate the risk for a new patient. The idea is
> that a doctor gets the measurements for the patient sitting in his
> office.  Then he goes to Internet and types in the test measuremnets
> and gets the estimated risk.

We are in a similar situation and the approach we've used is to keep R
as a backend computation engine (using Rserve) and have a web service
interface to it.

Thus when we develop a predictive model, we dump it on the backend and
have a web service interface to it. With this interface we can then
write a web page client or even include the model into custom code
(command line or GUI).

You can see some examples at:

http://www.chembiogrid.org/cheminfo/rws/ames
http://www.chembiogrid.org/cheminfo/ncidtp/dtp
http://www.chembiogrid.org/cheminfo/pkcell/


The first two use previously built predictive models. The last one is a
piece of R code.

Alternatively you could use RApache
---
Rajarshi Guha <[EMAIL PROTECTED]>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
---
A sine curve goes off to infinity, or at least the end 
of the blackboard.
-- Prof. Steiner

__
R-help@stat.math.ethz.ch 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] xyplot() and controlling panel.polygon()

2007-04-27 Thread Deepayan Sarkar
On 4/27/07, Michael Kubovy <[EMAIL PROTECTED]> wrote:
> Hi Deepayan,
>
> Thanks for your advice. This is moving along, however:
> The following is drawing the same polygons in each panel. I'm trying
> to get a different polygon (confidence band) for each group in each
> panel. That's why I thought I would need to pass groups and
> subscripts to the panel.groups
>
> est <- c(1:4, 3:6, 7, 9, 11, 13, 12, 15, 18, 21)
> cond <- rep(c('a','b'), each = 8)
> grp <- rep(c('I', 'II'), each = 4, 2)
> x <- rep(c(.5, .7, .9, 1.1), 4)
> upper <- est + 1
> lower = est - 1
> data <- data.frame(est = est, x = x, cond = cond, grp = grp, upper =
> upper, lower = lower)
>
> my.panel.polygon <- function(..., font, fontface)
> {
> panel.polygon(...)
> }
>
> xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
>  panel = function(x, y, ...){
>  panel.superpose(c(x, rev(x)), c(upper, rev(lower)),
>  panel.groups = 'my.panel.polygon', default.units =
> 'native', ...)
>  panel.xyplot(x, y, ...)
>  }
> )
>
> It's pretty clear that panel.superpose is not getting its x and y
> values after they are split by group and panel.

You are not even trying to do that; you have

  panel.superpose(c(x, rev(x)), c(upper, rev(lower)), <...>

so your x=c(x, rev(x)) is not the same length as x (and subscripts), and your
y = c(upper, rev(lower)) is not the same length as anything. Also,
your upper and lower are being taken from the global env, not data
(they happen to be the same, but since your data has them, I assume
you want to use them).

Perhaps you are looking for something like this:


panel.bands <-
function(x, y, upper, lower,
 subscripts, ..., font, fontface)
{
upper <- upper[subscripts]
lower <- lower[subscripts]
panel.polygon(c(x, rev(x)), c(upper, rev(lower)), ...)
}

xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
   upper = data$upper,
   lower = data$lower,
   panel = function(x, y, ...){
   panel.superpose(x, y, panel.groups = 'panel.bands', ...)
   panel.xyplot(x, y, ...)
   })

-Deepayan

__
R-help@stat.math.ethz.ch 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] Integrating R-programs into larger systems

2007-04-27 Thread Frank E Harrell Jr
Ralf Finne wrote:
> Hi experts!
> 
> Have anybody experience in including an R-program 
> as part of a larger system?  In Matlab there is a toolbox
> that converts a m-script into C-code. 
> One application in mind is that I do the model building in R,
> for estimating the risk for cancer based on clinical measurements.
> 
> When the model is ready, a small R-program can simulate
> the model to estimate the risk for a new patient. The idea is
> that a doctor gets the measurements for the patient sitting in his
> office.  Then he goes to Internet and types in the test measuremnets
> and gets the estimated risk.
> Look at www.finne.info for an early version to get the idea.
> There I developed the model in Matlab and converted it to Excel.
> Don't use the results!  Much better are available in R!
> There are many more applications that need a higher degree
> of integration.
> 
> Than you in advance.
> 
> Ralf Finne
> SYH, University of Applied Sciences
> Vasa Finland

The Design package for R has a version for S-Plus.  In S-Plus you can 
use its Dialog function to automatically create a GUI for getting 
predicted values from a series of fitted models.  We will be working on 
an R version but it will publish the model to a web server.

Frank
-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
R-help@stat.math.ethz.ch 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] [R-pkgs] New packages: contrast and desirability

2007-04-27 Thread Kuhn, Max
The contrast and desirability packages are available for all platforms
at cran.r-project.org (and coming soon to a mirror near you).

The contrast package extends Frank Harrell's contrast.Design function
for one degree of freedom contrasts of model parameters to other types
of models, such as lm, glm, lme, gls and geese models. Fold-changes are
also calculated for all contrasts. There is a package vignette that
shows examples for a basic two-way layout and a design with repeated
measures.

The desirability package contains S3 classes for multivariate
optimization using the desirability function approach of Harrington
(1965) using the functional forms described by Derringer and Suich
(1980). There are functions for maximization, minimization, hitting a
target, box constraints and a function for creating arbitrarily shaped
desirability equations. There is also a package vignette that shows an
example of a multi-response surface experiment. 

Please send me emails for suggestions and bug fixes at max.kuhn at
pfizer.com.

Max

--
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@stat.math.ethz.ch 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] add arrows to barchart with groups

2007-04-27 Thread Deepayan Sarkar
On 4/27/07, GOUACHE David <[EMAIL PROTECTED]> wrote:
> Hello Rhelpers,
>
> I am trying to represent the following data (hereafter named donnees) in a 
> barchart with a grouping variable :
>
>
> sitetraitement  dates   res
> 1   NT  17/10/2005  normal  76.2
> 1   T   17/10/2005  normal  103.2
> 1   NT  23/11/2005  tardif  81.6
> 1   T   23/11/2005  tardif  98
> 2   NT  15/10/2005  normal  72.71
> 2   T   15/10/2005  normal  94.47
> 2   NT  15/11/2005  tardif  79.65
> 2   T   15/11/2005  tardif  94.7
>
> barchart(res~s|site,groups=traitement,data=donnees)
>
> What I'd like to do is for each site represent with an arrow the difference 
> in value of variable res between normal and tardif values of variable s.
> I've found one way of doing it:
>
>
> trellis.focus("panel",1,1)
> xx<-trellis.panelArgs()$x
> yy<-trellis.panelArgs()$y
> panel.arrows(as.numeric(xx)[c(1,3)]-0.1,yy[c(1,3)],as.numeric(xx)[c(1,3)]-0.1,yy[c(2,4)],lwd=2,code=3)
> panel.text(as.numeric(xx)[c(1,3)]-0.35,c(87,87),paste(yy[c(2,4)]-yy[c(1,3)],"\nq/ha"),font=2)
> trellis.focus("panel",2,1)
> xx<-trellis.panelArgs()$x
> yy<-trellis.panelArgs()$y
> panel.arrows(as.numeric(xx)[c(1,3)]-0.1,yy[c(1,3)],as.numeric(xx)[c(1,3)]-0.1,yy[c(2,4)],lwd=2,code=3)
> panel.text(as.numeric(xx)[c(1,3)]-0.35,c(87,87),paste(yy[c(2,4)]-yy[c(1,3)],"\nq/ha"),font=2)
> trellis.unfocus()
>
> But I would prefer doing this within a custom panel function so I can apply 
> it more generally, and I haven't been able to figure out how...
> Could anyone give me a hand?

The obvious analog (just copy/pasting your code) is:

my.panel <- function(x, y, ...)
{
panel.barchart(x, y, ...)
xx <- x
yy <- y
panel.arrows(as.numeric(xx)[c(1,3)]-0.1, yy[c(1,3)],
 as.numeric(xx)[c(1,3)]-0.1, yy[c(2,4)],
 lwd = 2, code = 3)
panel.text(as.numeric(xx)[c(1,3)] - 0.35, c(87,87),
   paste(yy[c(2,4)] - yy[c(1,3)], "\nq/ha"),
   font=2)
}

and this seems to work:

barchart(res~s|site,groups=traitement,data=donnees,
 panel = my.panel)

barchart(res~s|site,groups=traitement,data=donnees,
 panel = my.panel,
 origin = 0)

I'm not sure what else you are looking for and what you mean by "more
general". For example, it's not clear what you want to happen If you
have more than 2 levels in 'groups', or if the second bar is not
always higher than the first.

-Deepayan

__
R-help@stat.math.ethz.ch 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] Unwanted white borders on semi-transparent polygons?

2007-04-27 Thread Prof Brian Ripley
On Fri, 27 Apr 2007, Matthew Neilson wrote:

> Hey again,
>
> Just to let you know that I managed to test out R-2.5.0, and the transparency 
> glitch has thankfully disappeared. I apologise for wasting your time with 
> this.
>
> One final question, though. Did you mean to say that the known transparency 
> bug was fixed in version 2.5.0? Or was it fixed in a patched version of 
> R-2.4.0? Only asking because, if the final Panther binary (version 2.4.0) 
> available on CRAN doesn't fix the bug, there's no point in me installing this 
> on top of my happily working (and otherwise fully functional) version of R.

I meant to say '2.4.0 patched', which became 2.4.1.  The release of 2.4.0 
has the bug: NEWS says

 o  A request for an opaque colour in the pdf() device after a
translucent one did not set the transparency back to opaque in
2.4.0.

Semi-transparent background colours were not being plotted on
the pdf() device.



>
> Many thanks,
>
>
> -Matt
>
>
>
> On 27 Apr 2007, at 13:35, Matthew Neilson wrote:
>
>> Hi Brian,
>> 
>> Terribly sorry if I accidentally broke a rule. sessionInfo() produces the 
>> following:
>> 
>>> sessionInfo()
>> R version 2.2.1, 2005-12-20, powerpc-apple-darwin7.9.0
>> 
>> attached base packages:
>> [1] "methods"   "stats" "graphics"  "grDevices" "utils" "datasets"
>> [7] "base"
>> 
>> I cannot upgrade to the latest version of R, since I'm using OS X 10.3.9 
>> (Panther) and the latest builds require 10.4.4 (Tiger) or greater. It's 
>> interesting to know that R version 2.4.0
>> contains a transparency bug, though - I'll ask IT Services to install the 
>> latest version of R on the G5 and see if that helps.
>> 
>> Many thanks for all your help,
>> 
>> 
>> -Matt
>> 
>> 
>> 
>> On Fri Apr 27 12:58 , Prof Brian Ripley <[EMAIL PROTECTED]> sent:
>> 
>>> The posting guide says
>>>
>>>   For questions about unexpected behavior or a possible bug, you should,
>>>   at a minimum, copy and paste the output from sessionInfo() into your 
>>> message.
>>>
>>>   If you are using an old version of R and think it does not work
>>>   properly, upgrade to the latest version and try that, before posting.
>>> 
>>> [There is a known bug in 2.4.0 related to semi-transparency, fixed in
>>> 2.4.0.  I would not have attempted to answer a question about 2.1.1, and
>>> we do rely on people seeking free technical assistance doing their bit.]
>>> 
>>> 
>>> On Fri, 27 Apr 2007, Matthew Neilson wrote:
>>> 
 Thanks for your fast response.
 
 I'm using R version 2.1.1 on OS X 10.3.9 to create the pdfs. I have tried 
 viewing the pdf output in both Acrobat 6 and 7 (both display a white 
 border around each polygon) as well
>> as
 Preview (displays fine). I have emailed the pdf file to some 
 correspondents running Windows, and they also see white borders when 
 viewing with Acrobat (version unspecified).
 
 I have tried using R version 2.4.0 on a G5 machine (which I can access 
 remotely) running OS X 10.4.8, but the resulting pdf renders incorrectly 
 (i.e. with a white border around
>> each
 polygon) in both Acrobat *and* Preview. So it would appear that the 
 combination of R 2.1.1 and OS X 10.3.9 gives slightly better results - 
 although plots still appear incorrect
>> when
 printed or viewed in Acrobat.
 
 Unfortunately, I don't have access to a Windows machine to test this out. 
 Even if I did, many of my scripts include various Unix system calls so I 
 don't think that would be a viable
 solution. Could this be a bug in the OS X pdf driver?
>>> 
>>> The R pdf() device is the same on all platforms.
>>> 
 Many thanks,
 
 
 -Matt
 
 
 
 On 27 Apr 2007, at 06:42, Prof Brian Ripley wrote:
 
> What version of R, what OS, what version of Acrobat?
> 
> I don't see this in 2.5.0 on Windows (using Acrobat 7: Acrobat does not
> exist on Linux, AFAIK).  And reading the PDF produced shows no sign of 
> an
> extra object for the border.
> 
> On Fri, 27 Apr 2007, Matthew Neilson wrote:
> 
>> Hey all,
>> 
>> I'm trying to create a plot of two semi-transparent regions. The reason 
>> they need to be partially transparent is so that I can see if there's 
>> any overlap. Here's some example
>> code:
>> 
>> # BEGIN
>> 
>> pdf(file="test.pdf",version="1.4")
>> plot(0,0,type="l",ylim=range(-3,3),xlim=range(-1,5))
>> polygon(c(0,1,2,3,4,3,2,1,0), c(0,1,2,1,0,-1,-2,-1,0), 
>> col=rgb(1,0,0,0.5),
>> border=NA)
>> polygon(c(1,2,3,4,5,4,3,2,1), c(0,1,2,1,0,-1,-2,-1,0), 
>> col=rgb(0,0,1,0.5),
>> border=NA)
>> dev.off()
>> 
>> # END
>> 
>> The problem with this is that, despite setting "border = NA", I get a
>> big white border surrounding each polygon!! Funnily enough, setting the
>> alpha channel equal to 1 (as opposed to 0.5) *doesn't* give the

Re: [R] xyplot() and controlling panel.polygon()

2007-04-27 Thread Deepayan Sarkar
On 4/26/07, Michael Kubovy <[EMAIL PROTECTED]> wrote:

> I'm not sure I understand.
>
> I'm trying to add a filled band to show CIs around the data (which is
> why I tried to use xYplot, where 'filled bands' have bug).
> So with these data:
>
> est <- c(1:4, 3:6, 7, 9, 11, 13, 12, 15, 18, 21)
> cond <- rep(c('a','b'), each = 8)
> grp <- rep(c('I', 'II'), each = 4, 2)
> x <- rep(c(.5, .7, .9, 1.1), 4)
> upper <- est + 1
> lower = est - 1
> data <- data.frame(est = est, x = x, cond = cond, grp = grp, upper =
> upper, lower = lower)
>
>   I'm trying to decorate this with bands:
>
> xyplot(est ~ x | cond, group = grp, data = data, type = 'b')
>
> So I'm not sure why your proposal is failing:

And in what sense exactly is it "failing"?

> my.panel.polygon <- function(..., font, fontface)
> {
> panel.polygon(...)
> }
>
> xYplot(est ~ x | cond, group = grp, data = data, type = 'b',
>  panel = function(x, y, subscripts, groups, ...){

No, my proposal did not have 'groups' and 'subscripts' as arguments in
the custom panel function.

My point was precisely that you shouldn't have them unless you use
them, in which case, they will be simply passed on as appropriate as
part of the ... argument, whereas now they are not being passed on to
panel.xYplot at all. This should have been obvious from the error
message:

Error in panel.xYplot(x, y, , ...) : argument "subscripts" is missing,
with no default

(at least that's the error I get)

It's perfectly OK to have them as explicit arguments, but this
increases the chances of a mistake. For example, you had in your
original code (the equivalent of):

panel = function(x, y, groups, ...) {
   panel.xYplot(x, y, groups, ...)
}

which looks OK until you realize that 'groups' is not the 3rd argument
panel.xYplot().

-Deepayan

>  panel.superpose(c(x, rev(x)), c(upper, rev(lower)),
> subscripts, groups,
>  panel.groups = 'my.panel.polygon', default.units =
> 'native', ...)
>  panel.xYplot(x, y,,...)
>  }
> )
>
> _
> Professor Michael Kubovy
> University of Virginia
> Department of Psychology
> USPS: P.O.Box 400400Charlottesville, VA 22904-4400
> Parcels:Room 102Gilmer Hall
>  McCormick RoadCharlottesville, VA 22903
> Office:B011+1-434-982-4729
> Lab:B019+1-434-982-4751
> Fax:+1-434-982-4766
> WWW:http://www.people.virginia.edu/~mk9y/
>
>
>

__
R-help@stat.math.ethz.ch 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] weight

2007-04-27 Thread Natalie O'Toole
Hi,

I have the file below called happyguys. It is a subset of data. How do I 
apply the weight variable (WTPP) to this file? Can i just multiply each 
column (except the first column because it is a record id) by WTPP? If the 
answer is yes, how do I multiply one variable name by another?

Thanks,

Nat



  PROV REGION GRADE Y_Q10A WTPP
83  48  4 7  2 342233324020
115 48  4 7  1 434413433040
185 48  4 7  1 432312433040
222 48  4 7  2 13311030
242 48  4 7  1 421313332020
247 48  4 7  2 312134212030
352 48  4 7  1 331112411040
562 48  4 7  2 331112321030
591 48  4 7  1 321334413030
663 48  4 7  2 441412442040
691 48  4 7  1 333213343020
730 48  4 7  1 43321030
850 48  4 7  1 343113422040
101648  4 7  1 322124413050
104148  4 7  1 331133432040
116348  4 7  1 433913439040
121148  4 7  2 211213421030
124548  4 7  2 231113331020
128348  4 7  1 432114432030
172348  4 7  2 233112422040
176548  4 7  1 331113421040
176648  4 7  2 443434234040
189448  4 7  2 311142321040
197648  4 7  1 113124312040
209248  4 7  1 333122343040
209348  4 7  1 341312412040
224848  4 7  2 31213040
239648  4 7  2 424113332040
240548  4 7  1 43220030
243848  4 7  1 421314432030
248848  4 7  1 421123322040
257948  4 7  2 312113241040
263748  4 7  1 421132432030
269948  4 7  1 444212433050
273848  4 7  1 24311040
275948  4 7  1 43311040
285648  4 7  1 14410060
296448  4 7  2 413223413030
310748  4 7  2 232233324030
316648  4 7  2 322234324030
316948  4 7  2 32424040
348048  4 7  2 311122421040
351948  4 7  2 432224234020
364548  4 7  1 321112221040
368148  4 7  2 344112432040
369848  4 7  1 44311030
370348  4 7  1 313311412040
373748  4 7  2 343234324040
388948  4 7  1 431123322020
389648  4 7  2 233313223030
391548  4 7  1 311312411040
392948  4 7  2 243314223030
393448  4 7  2 223112332040
393748  4 7  2 332122423030
395748  4 7  2 211194449030
398348  4 7  1 331312432040
405248  4 7  2 423313413040
414748  4 7  1 33321030
416848  4 7  2 322131323040
425348  4 7  1 343432324040
426348  4 7  1 211132411060
432448  4 7  1 331113421040
440248  4 7  2 321112331030
452848  4 7  1 444113312030
457048  4 7  2 441114221040
460048  4 7  1 22220030
464048  4 7  2 321234323050
467248  4 7  2 342134433040
470148  4 7  2 241433423020
471048  4 7  2 331114331030
472848  4 7  2 321213422050
476448  4 7  2 333413233040
476548  4 7  2 24224030
479448  4 7  2 32320030
491548  4 7  1 43420050
492148  4 7  2 443412413040
494448  4 7  1 411343412050
496348  4 7  2 322314313030
508948  4 7  1 22411040
517348  4 7  2 311134431030
546648  4 7  2 332332424030
548448  4 7  2 33324030
__




 

This communication is intended for the use of the recipient to which it is 
addressed, and may
contain confidential, personal, and or privileged information. Please 
contact the sender
immediately if you are not the intended recipient of this communication, 
and do not copy,
distribute, or take action relying on it. Any communication received in 
error, or subsequent
reply, should be deleted or destroyed.
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Unwanted white borders on semi-transparent polygons?

2007-04-27 Thread Matthew Neilson
Hey again,

Just to let you know that I managed to test out R-2.5.0, and the 
transparency glitch has thankfully disappeared. I apologise for wasting 
your time with this.

One final question, though. Did you mean to say that the known 
transparency bug was fixed in version 2.5.0? Or was it fixed in a 
patched version of R-2.4.0? Only asking because, if the final Panther 
binary (version 2.4.0) available on CRAN doesn't fix the bug, there's 
no point in me installing this on top of my happily working (and 
otherwise fully functional) version of R.

Many thanks,


-Matt



On 27 Apr 2007, at 13:35, Matthew Neilson wrote:

> Hi Brian,
>
> Terribly sorry if I accidentally broke a rule. sessionInfo() produces 
> the following:
>
>> sessionInfo()
> R version 2.2.1, 2005-12-20, powerpc-apple-darwin7.9.0
>
> attached base packages:
> [1] "methods"   "stats" "graphics"  "grDevices" "utils" 
> "datasets"
> [7] "base"
>
> I cannot upgrade to the latest version of R, since I'm using OS X 
> 10.3.9 (Panther) and the latest builds require 10.4.4 (Tiger) or 
> greater. It's interesting to know that R version 2.4.0
> contains a transparency bug, though - I'll ask IT Services to install 
> the latest version of R on the G5 and see if that helps.
>
> Many thanks for all your help,
>
>
> -Matt
>
>
>
> On Fri Apr 27 12:58 , Prof Brian Ripley <[EMAIL PROTECTED]> sent:
>
>> The posting guide says
>>
>>   For questions about unexpected behavior or a possible bug, you 
>> should,
>>   at a minimum, copy and paste the output from sessionInfo() into 
>> your message.
>>
>>   If you are using an old version of R and think it does not work
>>   properly, upgrade to the latest version and try that, before 
>> posting.
>>
>> [There is a known bug in 2.4.0 related to semi-transparency, fixed in
>> 2.4.0.  I would not have attempted to answer a question about 2.1.1, 
>> and
>> we do rely on people seeking free technical assistance doing their 
>> bit.]
>>
>>
>> On Fri, 27 Apr 2007, Matthew Neilson wrote:
>>
>>> Thanks for your fast response.
>>>
>>> I'm using R version 2.1.1 on OS X 10.3.9 to create the pdfs. I have 
>>> tried viewing the pdf output in both Acrobat 6 and 7 (both display a 
>>> white border around each polygon) as well
> as
>>> Preview (displays fine). I have emailed the pdf file to some 
>>> correspondents running Windows, and they also see white borders when 
>>> viewing with Acrobat (version unspecified).
>>>
>>> I have tried using R version 2.4.0 on a G5 machine (which I can 
>>> access remotely) running OS X 10.4.8, but the resulting pdf renders 
>>> incorrectly (i.e. with a white border around
> each
>>> polygon) in both Acrobat *and* Preview. So it would appear that the 
>>> combination of R 2.1.1 and OS X 10.3.9 gives slightly better results 
>>> - although plots still appear incorrect
> when
>>> printed or viewed in Acrobat.
>>>
>>> Unfortunately, I don't have access to a Windows machine to test this 
>>> out. Even if I did, many of my scripts include various Unix system 
>>> calls so I don't think that would be a viable
>>> solution. Could this be a bug in the OS X pdf driver?
>>
>> The R pdf() device is the same on all platforms.
>>
>>> Many thanks,
>>>
>>>
>>> -Matt
>>>
>>>
>>>
>>> On 27 Apr 2007, at 06:42, Prof Brian Ripley wrote:
>>>
 What version of R, what OS, what version of Acrobat?

 I don't see this in 2.5.0 on Windows (using Acrobat 7: Acrobat does 
 not
 exist on Linux, AFAIK).  And reading the PDF produced shows no sign 
 of an
 extra object for the border.

 On Fri, 27 Apr 2007, Matthew Neilson wrote:

> Hey all,
>
> I'm trying to create a plot of two semi-transparent regions. The 
> reason they need to be partially transparent is so that I can see 
> if there's any overlap. Here's some example
> code:
>
> # BEGIN
>
> pdf(file="test.pdf",version="1.4")
> plot(0,0,type="l",ylim=range(-3,3),xlim=range(-1,5))
> polygon(c(0,1,2,3,4,3,2,1,0), c(0,1,2,1,0,-1,-2,-1,0), 
> col=rgb(1,0,0,0.5),
> border=NA)
> polygon(c(1,2,3,4,5,4,3,2,1), c(0,1,2,1,0,-1,-2,-1,0), 
> col=rgb(0,0,1,0.5),
> border=NA)
> dev.off()
>
> # END
>
> The problem with this is that, despite setting "border = NA", I 
> get a
> big white border surrounding each polygon!! Funnily enough, 
> setting the
> alpha channel equal to 1 (as opposed to 0.5) *doesn't* give the 
> border,
> but an alpha channel of 1 produces an opaque polygon! :S
>
> I have read the FAQ, and (unfortunately) turning off line-art 
> smoothing
> does not give the desired effect. Furthermore, my pdfs print with a
> white border surrounding each transparent polygon.
>
> Now, here comes the really bizarre part. Whilst Adobe Acrobat 
> displays
> the unwanted white border, Apple Preview respects the "border=NA"
> argument and shows the two diamonds as they are intended. However,
>

[R] Integrating R-programs into larger systems

2007-04-27 Thread Ralf Finne
Hi experts!

Have anybody experience in including an R-program 
as part of a larger system?  In Matlab there is a toolbox
that converts a m-script into C-code. 
One application in mind is that I do the model building in R,
for estimating the risk for cancer based on clinical measurements.

When the model is ready, a small R-program can simulate
the model to estimate the risk for a new patient. The idea is
that a doctor gets the measurements for the patient sitting in his
office.  Then he goes to Internet and types in the test measuremnets
and gets the estimated risk.
Look at www.finne.info for an early version to get the idea.
There I developed the model in Matlab and converted it to Excel.
Don't use the results!  Much better are available in R!
There are many more applications that need a higher degree
of integration.

Than you in advance.

Ralf Finne
SYH, University of Applied Sciences
Vasa Finland

__
R-help@stat.math.ethz.ch 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] Siegel-Tukey Test

2007-04-27 Thread Ralf Finne
Hi everybody!

Can anybody help me to find an R-function
for the Siegel-Tukey test.

Than you in advance.

Ralf Finne
SYH, University of Applied Sciences
Vasa Finland

__
R-help@stat.math.ethz.ch 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] Scatter Plot in R - Help

2007-04-27 Thread J . delasHeras
Quoting A Ezhil <[EMAIL PROTECTED]>:

> Dear All,
>
> I am using the following commands to do the scatter
> plot of two vectors, say X and Y.
>
> plot(X,Y, col="blue")
> abline(a=1,b=1, col="red")
> abline(a=-1,b=1, col="green")
>
> I would like to split the scatter plot into 3 part
> with 3 different colors: (i) points lies between 2
> lines, (ii) points above line 1, and (iii) points
> below line 2. I am struggling to do this. I would
> greatly appreciate any help in doing this.
>
> Thanks in advance.
>
> Kind regards,
> Ezhil

check ?points

'points' allows you to plot points using different plotting parameters  
(type, size, colours...).
You can subset the points in your scatter plot into three groups, and  
use 'points' on each group separately.

For instance:

x<-sample(c(-10:10),size=21)
y<-sample(c(-10:10),size=21)
plot(x,y, col="blue",pch=16)
abline(a=1,b=1, col="red")
abline(a=-1,b=1, col="green")
# then find the red and green groups:
reds<-which(y>x+1)
greens<-which(x>y+1)
points(x[reds],y[reds], col="red",pch=16)
points(x[greens],y[greens], col="green",pch=16)

you could also choose to not plot anything at first (use parameter  
type="n"), and define not just the red and green groups, but also teh  
blue ones too. You may need to do this if you want to use different  
plotting characters or sizes and overplotting doesn't look good.

Jose


-- 
Dr. Jose I. de las Heras  Email: [EMAIL PROTECTED]
The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374
Institute for Cell & Molecular BiologyFax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK

__
R-help@stat.math.ethz.ch 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] Example of mcmcsamp() failing with lmer() output

2007-04-27 Thread Michael Kubovy
Hi,

I would appreciate help with the following model

<<1>>=
gunload <- read.table(hh('datasets/gunload.dat'), header = T)
gunload$method <- factor(gunload$method, labels = c('new', 'old'))
gunload$physique <- factor(gunload$group, labels = c('slight',  
'average', 'heavy'))
gunload$team9 <- factor(rep(1:9, each = 2))
@

This is a split plot design with randomly selected teams for each  
physique, which was crossed with two methods.

Following the Oats example in chap. 1 of MEMSS, and adapting to lmer:

<<2>>=
require(lme4)
gl.lmer <- lmer(rounds ~ method * physique + (1 | physique/team),  
data = gunload)
mcmcsamp(gl.lmer)
@
lmer runs as expected, but mcmcsamp() gives:
Error: Leading minor of order 1 in downdated X'X is not positive  
definite
Error in t(.Call(mer_MCMCsamp, object, saveb, n, trans, verbose,  
deviance)) :
error in evaluating the argument 'x' in selecting a method for  
function 't'

I tried:

<<3>>=
require(nlme)
gl.lme <- lme(rounds ~ method * physique, random = ~1 | physique/ 
team, data = gunload)
@
which gave all the expected output except that two p-values were NaN.

Which aspect of the data is making the simulation fail, and is there  
anything to be done about it?

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@stat.math.ethz.ch 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] Logistic Regression Question: Risk Threshold

2007-04-27 Thread diana
Hi,

I am working on problem 2 of Chapter 8 in Data Analysis and Graphics Using R 
and don't know how to approach the second half of the question:

In the data set (an artificial one of 3121 patients, that is similar to a 
subset of the data analyzed in Stiell et al., 2001) head.injury, obtain a 
logistic regression model relating clinically.important.brain.injury to other 
variables. Patients whose risk is sufficiently high will be sent for CT 
(computed tomography). Using a risk threshold of 0.025 (2.5%), turn the result 
into a decision rule for use of CT.

This is what I have so far:

> names(head.injury)
 [1] "age.65""amnesia.before"   
 [3] "basal.skull.fracture"  "GCS.decrease" 
 [5] "GCS.13""GCS.15.2hours"
 [7] "high.risk" "loss.of.consciousness"
 [9] "open.skull.fracture"   "vomiting" 
[11] "clinically.important.brain.injury"
> attach(head.injury)

> head.glm = glm(clinically.important.brain.injury ~ ., family=binomial, 
> data=head.injury)
> summary(head.glm)

Call:
glm(formula = clinically.important.brain.injury ~ ., family = binomial, 
data = head.injury)

Deviance Residuals: 
Min   1Q   Median   3Q  Max  
-2.2774  -0.3511  -0.2095  -0.1489   3.0028  

Coefficients:
  Estimate Std. Error z value Pr(>|z|)
(Intercept)-4.4972 0.1629 -27.611  < 2e-16 ***
age.65  1.3734 0.1827   7.518 5.56e-14 ***
amnesia.before  0.6893 0.1725   3.996 6.45e-05 ***
basal.skull.fracture1.9620 0.2064   9.504  < 2e-16 ***
GCS.decrease   -0.2688 0.3680  -0.730 0.465152
GCS.13  1.0613 0.2820   3.764 0.000168 ***
GCS.15.2hours   1.9408 0.1663  11.669  < 2e-16 ***
high.risk   1.1115 0.1591   6.984 2.86e-12 ***
loss.of.consciousness   0.9554 0.1959   4.877 1.08e-06 ***
open.skull.fracture 0.6304 0.3151   2.001 0.045424 *  
vomiting1.2334 0.1961   6.290 3.17e-10 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 1741.6  on 3120  degrees of freedom
Residual deviance: 1201.3  on 3110  degrees of freedom
AIC: 1223.3

Number of Fisher Scoring iterations: 6


How do I assess which patients have a high risk level, and how does the risk 
threshold play into that?

Thanks in advance,

Diana

   
-


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Issues with Sweave and inclusion of graphics from nlme

2007-04-27 Thread Friedrich Leisch
> On Fri, 27 Apr 2007 07:15:22 -0400,
> Duncan Murdoch (DM) wrote:

  > On 4/27/2007 5:39 AM, [EMAIL PROTECTED] wrote:
  >> Dear all,
  >> I'm using the nlme package. I would like to introduce the plot of my
  >> groupedData object in my latex report using Sweave but it doesn't work. 
  >> I have no error message in R (Sweave(my.file_Rnw)) and the plot is
  >> generated in R, but when I want to see the pdf (I'm using TexnicCenter) of
  >> my report, there is an error message and no pdf file is generated. It seems
  >> that the plot generated by plot.nmGroupedData is not found by TexnicCenter.
  >> Does anyone have an idea on how to solve this problem?

  > If the dot in the filename is real, I'd guess that's your problem. To 
  > confirm, take a look at the .tex file produced by Sweave.  Find the line 
  > corresponding to this figure.  It will be an \includegraphics call, 
  > something like

  > \includegraphics{my.file_Rnw-fig}

  > Your TeX is probably interpreting this as the file my.file_Rnw-fig 
  > rather than automatically adding the .pdf file extension, because it 
  > thinks you've specified the extension to be file_Rnw-fig.

Another reason could be that many nlme plots are using lattice, see

  http://www.ci.tuwien.ac.at/~leisch/Sweave/FAQ.html#x1-9000A.7

Best,

-- 
---
Prof. Dr. Friedrich Leisch 

Institut für Statistik  Tel: (+49 89) 2180 3165
Ludwig-Maximilians-Universität  Fax: (+49 89) 2180 5308
Ludwigstraße 33
D-80539 München http://www.stat.uni-muenchen.de/~leisch

__
R-help@stat.math.ethz.ch 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] select if + other questions

2007-04-27 Thread Natalie O'Toole
Hi John,

I figured out the skipping of variables using a first subset & then making 
a second subset & it worked!

Thanks,

Natalie

__

You need to have a look at Chapter 5 of the Intro to
R.   I would recommend downloading the pdf and
printing it out.  It is not an easy read but it should
help.

newdata <- mydata[, c(PUMDID, Y_Q10A)]

or
newdata <- mydata[, c(1,33)]

should do the trick

--- Natalie O'Toole <[EMAIL PROTECTED]> wrote:

> Hi,
>
> Does anyone know how to skip variables (or columns)
> in R. Say, for example
> i had PUMFID position1 and Y_Q10A position 33 and i
> do not want to include
> all the variables in between. Is there a way to do
> this in R when you are
> extracting variables from a large .txt file with
> many, many variables?
>
> Thanks,
>
> Nat
>
> __
>
>
> Yes but I believe it will vary depending on what
> package you're using.  I don't deal with weigthed
> data
> so I'm not a good source
>
> Have a look at help for something like lm in the
> stats
>   package (part of the base installation) for an
> example.
>
> ?lm
>
> weight is the fourth argument down.
>
> However for more information try
> http://finzi.psych.upenn.edu/search.html and type in
> weight.
>
> As Brian Ripley says in a reply to a question about
> weights:
>  "Almost all methods I know of do: logistic
> regression, neural nets, classification trees, PPR
>  "
>
>
> --- Natalie O'Toole <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> > Thank-you for the response!! That worked great!!
> Is
> > there any way to apply
> > a weight variable to your file similar to what you
> > can do in SPSS? So that
> > all of your other variables will be weighted by
> the
> > weight variable?
> >
> > Thanks,
> >
> > Nat
> >
> > __
> >
> >
> > Hi,
> >
> > i am trying to read a .txt file, do a couple of
> > select if statements on my
> > data, and then finally use the ?table function to
> > get frequency counts on
> > the data. Specifically, i am looking at answering
> > the following question:
> >
> > What is the frequency of Grade 7 students in the
> > province of Alberta who
> > are smokers?
> >
> > I am having some problems:
> >
> > 1)i cannot get the column names to show up when
> > print to screen
> >
> > 2)I cannot seem to skip variables properly when i
> > choose certain other
> > variables
> >
> > 3)i cannot get the combination of Select If
> > statements to work to produce
> > a different table with my new criteria
> >
> > Here are the variables
> >
> > PUMFID position1 length 5
> > PROV position 6 length 2
> > GRADE position 9 length 2
> > Y_Q10A position 33 length 1
> >
> >
> > Y_Q10A has the following 1=yes
> >2=no
> >   9=skip
> >
> > all the others have no skipped or missing values
> >
> > Here is my code:
> >
> > myfile<-("c:/test2.txt")
> >
> myVariableNames<-c("PUMFID","PROV","GRADE","Y_Q10A")
> >
> > myVariableWidths<-c(5,2,2,1)
> >
> >
> >  mydata<-read.fwf(
> > file=myfile,
> > width=myVariableWidths,
> > col.names=myVariableNames,
> > row.names="PUMFID",
> > fill=TRUE,
> > strip.white=TRUE)
> >
> >
> > print(mydata)
> >
> > print( mydata [which(PROV=="AB" & GRADE==7 &
> > Y_Q10A<9), ] )
> >
> >
> >
> > Any help would be greatly appreciated!!
> >
> > Thank-you,
> >
> > Nat
> >
> >
>

> >
> >
> > This communication is intended for the use of the
> > recipient to which it is
> > addressed, and may
> > contain confidential, personal, and or privileged
> > information. Please
> > contact the sender
> > immediately if you are not the intended recipient
> of
> > this communication,
> > and do not copy,
> > distribute, or take action relying on it. Any
> > communication received in
> > error, or subsequent
> > reply, should be deleted or destroyed.
> >
>

> >
> >
> > This communication is intended for the use of the
> > recipient to which it is
> > addressed, and may
> > contain confidential, personal, and or privileged
> > information. Please
> > contact the sender
> > immediately if you are not the intended recipient
> of
> > this communication,
> > and do not copy,
> > distribute, or take action relying on it. Any
> > communication received in
> > error, or subsequent
> > reply, should be deleted or destroyed.
> >[[alternative HTML version
> deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch 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.
> >
>
>
>
>   Be smarter than spam. See how smart SpamGuard
> is at giving junk
> email the boot with the All-new Yahoo

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-27 Thread rolf
I think Duncan's suggestion that the poster work it out for
him/her self is perfectly reasonable.  People can be anonymous
all they like.  Those of us who are made suspicious by this
anonymity (what have they got to hide?) can decline to provide
assistance.

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] A coding question involving variable assignments in ifelse()

2007-04-27 Thread Duncan Murdoch
On 4/27/2007 11:41 AM, Gabor Grothendieck wrote:
> I don't think there is any requirement to identify yourself in any
> way nor should their be.  Many people on the list are in academia
> and in those cases they probably want their name in lights but
> others may wish to have a lower profile and its common to use
> an alias on the net for privacy.

I agree with some of the above, but it's also true that there is no 
requirement on anyone to respond to any particular posting, and you are 
likely to get more responses if you do identify yourself.  If you don't, 
there's always the possibility that you are a student asking us to do 
your homework for you, or that you really should hire someone to do your 
programming.

My response may have seemed rude, but I thought at the time that it 
would have been more rude to ignore the question completely.  In my 
judgment the original answer was sufficient, and the followups showed 
that Mr./Ms. Anonymous wasn't willing to put a reasonable effort into 
solving the problem her/himself.

Duncan Murdoch


> 
> On 4/27/07, xpRt.wannabe <[EMAIL PROTECTED]> wrote:
>> Is this an ad hominem comment or a comment of brevity?  Unless my eyes
>> are playing tricks on me, I can't seem to find any language in the
>> Posting Guide on what is considered a reasonable vs. unreasonable
>> request from an anonymous poster.  Kindly point me to it if it exists.
>>
>> In any case, thanks for your time and suggestion.
>>
>> On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>> > On 4/26/2007 5:21 PM, xpRt.wannabe wrote:
>> > > I made a few slight modifications to the original model in an effort
>> > > to see the inner workings of the code:
>> > >
>> > > deductible <- 1
>> > > coverage.limit <- 2
>> > > insurance.threshold <- deductible + coverage.limit
>> > >
>> > > 
>> > >
>> > > set.seed(123)
>> > > loss <- abs(rnorm(rpois(1, 5), 1, 3))
>> > > n <- length(loss)
>> > > accept <- runif(n) < 0.8
>> > > payout <- runif(n) < 0.999
>> > > sum(ifelse(accept & payout, ifelse(loss > insurance.threshold,
>> > > loss - coverage.limit, pmin(loss, deductible)), 0))
>> > >
>> > > [1] 6.188817
>> > >
>> > > 
>> > >
>> > > To tease out the data as well as to see the effect of 'accept &
>> > > payout', I did the following:
>> > >
>> > >> loss
>> > > [1] 3.401663 4.570620 4.068667 4.718488
>> > >> accept
>> > > [1]  TRUE FALSE  TRUE  TRUE  # The second loss claim is NOT accepted
>> > > by the insurance company.
>> > >> payout
>> > > [1] TRUE TRUE TRUE TRUE
>> > >> accept & payout
>> > > [1]  TRUE FALSE  TRUE  TRUE  # The second entry is FALSE because of
>> > > the second entry in 'accept.'
>> > >
>> > > Based on the inner ifelse() expression, the original loss numbers
>> > > become : 1.401663, 2.570620, 2.068667, 2.718488, respectively (which
>> > > is fine and what I wanted).
>> > >
>> > > Because the second entry in 'accept & payout' is FALSE, the second
>> > > altered loss number (2.570620) becomes 0, making sum(...) equal
>> > > 6.188817.  Unfortunately this is _not_ what I want, and I apologize
>> > > for not being clear in the first place.  What I want is: for any FALSE
>> > > entry, the original loss number is unaltered, as opposed to become 0.
>> > > So in the example above, the four numbers that should have been added
>> > > are: 1.401663, 4.570620, 2.068667, 2.718488, yielding 10.759438
>> > > instead of 6.188817.
>> > >
>> > > Any further suggestions would be greatly appreciated.
>> >
>> > I'm sorry, but from an anonymous poster that's not a reasonable request.
>> >  Just work it out yourself.
>> >
>> > Duncan Murdoch
>> >
>> > >
>> > > On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>> > >> On 4/26/2007 2:31 PM, xpRt.wannabe wrote:
>> > >>> Just to be sure, is what I have below the right intepretation of your
>> > >>> suggestion:
>> > >> Yes, that's what I suggested.
>> > >>
>> > >> Duncan Murdoch
>> > >>
>> > >>> deductible <- 15
>> > >>> coverage.limit <- 75
>> > >>> insurance.threshold <- deductible + coverage.limit
>> > >>>
>> > >>> tmpf <- function() {
>> > >>> loss <- rlnorm(rpois(1, 3), 2, 5)
>> > >>> n <- length(loss)
>> > >>> accept <- runif(n) < 0.8
>> > >>> payout <- runif(n) < 0.999
>> > >>> sum(ifelse(accept & payout, ifelse(loss > insurance.threshold, loss -
>> > >>> coverage.limit, pmin(loss, deductible)), 0))
>> > >>> }
>> > >>> net <- replicate(100, tmpf())
>> > >>>
>> > >>> On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>> >  On 4/26/2007 12:48 PM, xpRt.wannabe wrote:
>> > > Dear List,
>> > >
>> > > Below is a simple, standard loss model that takes into account the
>> > > terms of an insurance policy:
>> > >
>> > > deductible <- 15
>> > > coverage.limit <- 75
>> > > insurance.threshold <- deductible + coverage.limit
>> > >
>> > > tmpf <- function() {
>> > > loss <- rlnorm(rpois(1, 3), 2, 5)
>> > > sum(ifelse(loss > insurance.threshold, loss - coverage.limit,
>> > > pmin(loss, deductible)))
>> > > }

[R] Scatter Plot in R - Help

2007-04-27 Thread A Ezhil
Dear All,

I am using the following commands to do the scatter
plot of two vectors, say X and Y.

plot(X,Y, col="blue")
abline(a=1,b=1, col="red")
abline(a=-1,b=1, col="green")

I would like to split the scatter plot into 3 part
with 3 different colors: (i) points lies between 2
lines, (ii) points above line 1, and (iii) points
below line 2. I am struggling to do this. I would
greatly appreciate any help in doing this.

Thanks in advance.

Kind regards,
Ezhil

__
R-help@stat.math.ethz.ch 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] select if + other questions

2007-04-27 Thread John Kane
You need to have a look at Chapter 5 of the Intro to
R.   I would recommend downloading the pdf and
printing it out.  It is not an easy read but it should
help.

newdata <- mydata[, c(PUMDID, Y_Q10A)]

or 
newdata <- mydata[, c(1,33)]

should do the trick

--- Natalie O'Toole <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> Does anyone know how to skip variables (or columns)
> in R. Say, for example 
> i had PUMFID position1 and Y_Q10A position 33 and i
> do not want to include 
> all the variables in between. Is there a way to do
> this in R when you are 
> extracting variables from a large .txt file with
> many, many variables?
> 
> Thanks,
> 
> Nat
> 
> __
> 
> 
> Yes but I believe it will vary depending on what
> package you're using.  I don't deal with weigthed
> data
> so I'm not a good source
> 
> Have a look at help for something like lm in the
> stats
>   package (part of the base installation) for an
> example.
>  
> ?lm 
> 
> weight is the fourth argument down.
> 
> However for more information try
> http://finzi.psych.upenn.edu/search.html and type in
> weight.
> 
> As Brian Ripley says in a reply to a question about
> weights:
>  "Almost all methods I know of do: logistic
> regression, neural nets, classification trees, PPR
>  "
> 
> 
> --- Natalie O'Toole <[EMAIL PROTECTED]> wrote:
> 
> > Hi,
> > 
> > Thank-you for the response!! That worked great!!
> Is
> > there any way to apply 
> > a weight variable to your file similar to what you
> > can do in SPSS? So that 
> > all of your other variables will be weighted by
> the
> > weight variable?
> > 
> > Thanks,
> > 
> > Nat
> > 
> > __
> > 
> > 
> > Hi, 
> > 
> > i am trying to read a .txt file, do a couple of
> > select if statements on my 
> > data, and then finally use the ?table function to
> > get frequency counts on 
> > the data. Specifically, i am looking at answering
> > the following question: 
> > 
> > What is the frequency of Grade 7 students in the
> > province of Alberta who 
> > are smokers? 
> > 
> > I am having some problems: 
> > 
> > 1)i cannot get the column names to show up when
> > print to screen 
> > 
> > 2)I cannot seem to skip variables properly when i
> > choose certain other 
> > variables 
> > 
> > 3)i cannot get the combination of Select If
> > statements to work to produce 
> > a different table with my new criteria
> > 
> > Here are the variables 
> > 
> > PUMFID position1 length 5 
> > PROV position 6 length 2 
> > GRADE position 9 length 2 
> > Y_Q10A position 33 length 1 
> > 
> > 
> > Y_Q10A has the following 1=yes 
> >2=no
> >   9=skip 
> > 
> > all the others have no skipped or missing values 
> > 
> > Here is my code: 
> > 
> > myfile<-("c:/test2.txt") 
> >
> myVariableNames<-c("PUMFID","PROV","GRADE","Y_Q10A")
> > 
> > myVariableWidths<-c(5,2,2,1) 
> > 
> > 
> >  mydata<-read.fwf( 
> > file=myfile, 
> > width=myVariableWidths, 
> > col.names=myVariableNames, 
> > row.names="PUMFID", 
> > fill=TRUE, 
> > strip.white=TRUE) 
> > 
> > 
> > print(mydata) 
> > 
> > print( mydata [which(PROV=="AB" & GRADE==7 &
> > Y_Q10A<9), ] ) 
> > 
> > 
> > 
> > Any help would be greatly appreciated!! 
> > 
> > Thank-you, 
> > 
> > Nat 
> > 
> >
>

> > 
> > 
> > This communication is intended for the use of the
> > recipient to which it is 
> > addressed, and may
> > contain confidential, personal, and or privileged
> > information. Please 
> > contact the sender
> > immediately if you are not the intended recipient
> of
> > this communication, 
> > and do not copy,
> > distribute, or take action relying on it. Any
> > communication received in 
> > error, or subsequent
> > reply, should be deleted or destroyed. 
> >
>

> > 
> > 
> > This communication is intended for the use of the
> > recipient to which it is 
> > addressed, and may
> > contain confidential, personal, and or privileged
> > information. Please 
> > contact the sender
> > immediately if you are not the intended recipient
> of
> > this communication, 
> > and do not copy,
> > distribute, or take action relying on it. Any
> > communication received in 
> > error, or subsequent
> > reply, should be deleted or destroyed.
> >[[alternative HTML version
> deleted]]
> > 
> > __
> > R-help@stat.math.ethz.ch 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.
> > 
> 
> 
> 
>   Be smarter than spam. See how smart SpamGuard
> is at giving junk 

> http://mrd.mail.yahoo.com/try_beta?.intl=ca
> 
> 
>

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-27 Thread Gabor Grothendieck
I don't think there is any requirement to identify yourself in any
way nor should their be.  Many people on the list are in academia
and in those cases they probably want their name in lights but
others may wish to have a lower profile and its common to use
an alias on the net for privacy.

On 4/27/07, xpRt.wannabe <[EMAIL PROTECTED]> wrote:
> Is this an ad hominem comment or a comment of brevity?  Unless my eyes
> are playing tricks on me, I can't seem to find any language in the
> Posting Guide on what is considered a reasonable vs. unreasonable
> request from an anonymous poster.  Kindly point me to it if it exists.
>
> In any case, thanks for your time and suggestion.
>
> On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> > On 4/26/2007 5:21 PM, xpRt.wannabe wrote:
> > > I made a few slight modifications to the original model in an effort
> > > to see the inner workings of the code:
> > >
> > > deductible <- 1
> > > coverage.limit <- 2
> > > insurance.threshold <- deductible + coverage.limit
> > >
> > > 
> > >
> > > set.seed(123)
> > > loss <- abs(rnorm(rpois(1, 5), 1, 3))
> > > n <- length(loss)
> > > accept <- runif(n) < 0.8
> > > payout <- runif(n) < 0.999
> > > sum(ifelse(accept & payout, ifelse(loss > insurance.threshold,
> > > loss - coverage.limit, pmin(loss, deductible)), 0))
> > >
> > > [1] 6.188817
> > >
> > > 
> > >
> > > To tease out the data as well as to see the effect of 'accept &
> > > payout', I did the following:
> > >
> > >> loss
> > > [1] 3.401663 4.570620 4.068667 4.718488
> > >> accept
> > > [1]  TRUE FALSE  TRUE  TRUE  # The second loss claim is NOT accepted
> > > by the insurance company.
> > >> payout
> > > [1] TRUE TRUE TRUE TRUE
> > >> accept & payout
> > > [1]  TRUE FALSE  TRUE  TRUE  # The second entry is FALSE because of
> > > the second entry in 'accept.'
> > >
> > > Based on the inner ifelse() expression, the original loss numbers
> > > become : 1.401663, 2.570620, 2.068667, 2.718488, respectively (which
> > > is fine and what I wanted).
> > >
> > > Because the second entry in 'accept & payout' is FALSE, the second
> > > altered loss number (2.570620) becomes 0, making sum(...) equal
> > > 6.188817.  Unfortunately this is _not_ what I want, and I apologize
> > > for not being clear in the first place.  What I want is: for any FALSE
> > > entry, the original loss number is unaltered, as opposed to become 0.
> > > So in the example above, the four numbers that should have been added
> > > are: 1.401663, 4.570620, 2.068667, 2.718488, yielding 10.759438
> > > instead of 6.188817.
> > >
> > > Any further suggestions would be greatly appreciated.
> >
> > I'm sorry, but from an anonymous poster that's not a reasonable request.
> >  Just work it out yourself.
> >
> > Duncan Murdoch
> >
> > >
> > > On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> > >> On 4/26/2007 2:31 PM, xpRt.wannabe wrote:
> > >>> Just to be sure, is what I have below the right intepretation of your
> > >>> suggestion:
> > >> Yes, that's what I suggested.
> > >>
> > >> Duncan Murdoch
> > >>
> > >>> deductible <- 15
> > >>> coverage.limit <- 75
> > >>> insurance.threshold <- deductible + coverage.limit
> > >>>
> > >>> tmpf <- function() {
> > >>> loss <- rlnorm(rpois(1, 3), 2, 5)
> > >>> n <- length(loss)
> > >>> accept <- runif(n) < 0.8
> > >>> payout <- runif(n) < 0.999
> > >>> sum(ifelse(accept & payout, ifelse(loss > insurance.threshold, loss -
> > >>> coverage.limit, pmin(loss, deductible)), 0))
> > >>> }
> > >>> net <- replicate(100, tmpf())
> > >>>
> > >>> On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> >  On 4/26/2007 12:48 PM, xpRt.wannabe wrote:
> > > Dear List,
> > >
> > > Below is a simple, standard loss model that takes into account the
> > > terms of an insurance policy:
> > >
> > > deductible <- 15
> > > coverage.limit <- 75
> > > insurance.threshold <- deductible + coverage.limit
> > >
> > > tmpf <- function() {
> > > loss <- rlnorm(rpois(1, 3), 2, 5)
> > > sum(ifelse(loss > insurance.threshold, loss - coverage.limit,
> > > pmin(loss, deductible)))
> > > }
> > > net <- replicate(100, tmpf())
> > >
> > > Now, I would like to enhance the model by incorporating the following
> > > two probabilities:
> > >
> > > 1. Probability of claim being accepted by the insurance company, say, 
> > > 0.8
> > > 2. Probability of payout by the insurance company, say, 0.999
> > >
> > > Could anyone suggest how one might do this?
> >  A general way to generate events with probability p is runif(n) < p.  
> >  So
> >  I'd add
> > 
> >  n <- length(loss)
> >  accept <- runif(n) < 0.8
> >  payout <- runif(n) < 0.999
> > 
> >  and then require "accept & payout"  before any payment at all, e.g.
> > 
> >  sum(ifelse(accept & payout, [ your old ifelse expression ], 0))
> > 
> >  There are a lot of implicit independence assumptions here; they may 

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-27 Thread xpRt.wannabe
Is this an ad hominem comment or a comment of brevity?  Unless my eyes
are playing tricks on me, I can't seem to find any language in the
Posting Guide on what is considered a reasonable vs. unreasonable
request from an anonymous poster.  Kindly point me to it if it exists.

In any case, thanks for your time and suggestion.

On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> On 4/26/2007 5:21 PM, xpRt.wannabe wrote:
> > I made a few slight modifications to the original model in an effort
> > to see the inner workings of the code:
> >
> > deductible <- 1
> > coverage.limit <- 2
> > insurance.threshold <- deductible + coverage.limit
> >
> > 
> >
> > set.seed(123)
> > loss <- abs(rnorm(rpois(1, 5), 1, 3))
> > n <- length(loss)
> > accept <- runif(n) < 0.8
> > payout <- runif(n) < 0.999
> > sum(ifelse(accept & payout, ifelse(loss > insurance.threshold,
> > loss - coverage.limit, pmin(loss, deductible)), 0))
> >
> > [1] 6.188817
> >
> > 
> >
> > To tease out the data as well as to see the effect of 'accept &
> > payout', I did the following:
> >
> >> loss
> > [1] 3.401663 4.570620 4.068667 4.718488
> >> accept
> > [1]  TRUE FALSE  TRUE  TRUE  # The second loss claim is NOT accepted
> > by the insurance company.
> >> payout
> > [1] TRUE TRUE TRUE TRUE
> >> accept & payout
> > [1]  TRUE FALSE  TRUE  TRUE  # The second entry is FALSE because of
> > the second entry in 'accept.'
> >
> > Based on the inner ifelse() expression, the original loss numbers
> > become : 1.401663, 2.570620, 2.068667, 2.718488, respectively (which
> > is fine and what I wanted).
> >
> > Because the second entry in 'accept & payout' is FALSE, the second
> > altered loss number (2.570620) becomes 0, making sum(...) equal
> > 6.188817.  Unfortunately this is _not_ what I want, and I apologize
> > for not being clear in the first place.  What I want is: for any FALSE
> > entry, the original loss number is unaltered, as opposed to become 0.
> > So in the example above, the four numbers that should have been added
> > are: 1.401663, 4.570620, 2.068667, 2.718488, yielding 10.759438
> > instead of 6.188817.
> >
> > Any further suggestions would be greatly appreciated.
>
> I'm sorry, but from an anonymous poster that's not a reasonable request.
>  Just work it out yourself.
>
> Duncan Murdoch
>
> >
> > On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> >> On 4/26/2007 2:31 PM, xpRt.wannabe wrote:
> >>> Just to be sure, is what I have below the right intepretation of your
> >>> suggestion:
> >> Yes, that's what I suggested.
> >>
> >> Duncan Murdoch
> >>
> >>> deductible <- 15
> >>> coverage.limit <- 75
> >>> insurance.threshold <- deductible + coverage.limit
> >>>
> >>> tmpf <- function() {
> >>> loss <- rlnorm(rpois(1, 3), 2, 5)
> >>> n <- length(loss)
> >>> accept <- runif(n) < 0.8
> >>> payout <- runif(n) < 0.999
> >>> sum(ifelse(accept & payout, ifelse(loss > insurance.threshold, loss -
> >>> coverage.limit, pmin(loss, deductible)), 0))
> >>> }
> >>> net <- replicate(100, tmpf())
> >>>
> >>> On 4/26/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>  On 4/26/2007 12:48 PM, xpRt.wannabe wrote:
> > Dear List,
> >
> > Below is a simple, standard loss model that takes into account the
> > terms of an insurance policy:
> >
> > deductible <- 15
> > coverage.limit <- 75
> > insurance.threshold <- deductible + coverage.limit
> >
> > tmpf <- function() {
> > loss <- rlnorm(rpois(1, 3), 2, 5)
> > sum(ifelse(loss > insurance.threshold, loss - coverage.limit,
> > pmin(loss, deductible)))
> > }
> > net <- replicate(100, tmpf())
> >
> > Now, I would like to enhance the model by incorporating the following
> > two probabilities:
> >
> > 1. Probability of claim being accepted by the insurance company, say, 
> > 0.8
> > 2. Probability of payout by the insurance company, say, 0.999
> >
> > Could anyone suggest how one might do this?
>  A general way to generate events with probability p is runif(n) < p.  So
>  I'd add
> 
>  n <- length(loss)
>  accept <- runif(n) < 0.8
>  payout <- runif(n) < 0.999
> 
>  and then require "accept & payout"  before any payment at all, e.g.
> 
>  sum(ifelse(accept & payout, [ your old ifelse expression ], 0))
> 
>  There are a lot of implicit independence assumptions here; they may not
>  be very realistic.
> 
>  Duncan Murdoch
> 
> >>> __
> >>> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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 prov

[R] [ANN:] new package xlsReadWrite*Pro*: announce + update.

2007-04-27 Thread Hans-Peter
I am happy to announce that a new version of xlsReadWritePro is available.

xlsReadWritePro natively reads and writes Excel files (v97 - 2003) on
Windows. The pro version is more powerful than the free version but,
beeing a small company, we ask you to support our development and
maintenance effort.

The following capabilities have been added (compared to xlsReadWrite):

• in-memory objects (compose reports, append)
• better sheet handling (select/ins/copy/del/...)
• data area subsets (rows/cols/from/to/area)
• use (named) ranges and pick individual cells
• insert images, hyperlinks, work with formulas
• oledatetime type and many helper functions
• get information about an Excelfile.

Browse the (shortened) help files: http://treetron.googlepages.com/00Index.html
Download a brochure:
http://treetron.googlepages.com/xlsReadWrite_Pro_Datasheet.pdf

Download the package: http://treetron.googlepages.com/xlsReadWritePro_1.2.1.zip
Download Test-/Demoscripts:
http://treetron.googlepages.com/xlsReadWritePro_TestData_1.2.1.zip

The pro version can be tested by everyone during a free trial of 30
days. If you don't like/need the pro version, you can always go back
to the free xlsReadWrite. The interfaces are very similar.

For more info please see http://treetron.googlepages.com (or download
the brochure).


Below is the update message for the new version:

o Changes from xlsReadWritePro 1.0.1 to 1.2.1

  - new argument "stringsAsFactors = default.stringsAsFactors()"
(proposed by Peter Cock)
Remark: this is a potentially code breaking change. Until now
strings have been
retrieved as characters. The new default behaviour is more in line
with read.table

  - new argument "checkNames = TRUE"
(proposed by Peter Cock)

  - new colClasses argument "link" to write hyperlinks.
(motivated by Mark W. Kimpel)

  - new colClasses argument "mixed" (and: "mixedCharacter", "mixedFactor")
to write character or factor vectors which contains numbers. The
numbers become
real numbers in Excel and not strings (with conversion hint). See
details in ?write.xls.
(motivated by Mark W. Kimpel)

  - new argument "formulasAsValues = TRUE". This high level setting can
be overriden by the (new) colClasses argument formula.
  - (read.xls/write.xls) new colClasses argument "formula" to read and
write formulas.
Will be auto-determined from Exceldata and
(motivated by Jeff Laake)

  - argument "cells" extended to accept character vector for
*named ranges* and a numeric R1C1R2C2 range vector.
  - "xls.range" to retrieve information about named ranges.
(motivated by Michael Clifford)

  - "xls.images" to add an image into an Excel spreadsheet
(motivated by Mark W. Kimpel and Michael Clifford)

  - "useOleDateTime" has been changed to "dateTimeAs". This argument is used to
decide how Excel date and time values should be handled if no
explicit "colClasses"
argument has been given. Possible values are:
- "numeric" (numeric value)
- "oledatetime" (numeric value of class oleDate, oleTime or
oleDateTime which triggers
 formatting as date/time string).
- "isodatetime" (character value)

  - factors now handled in the Delphi code by a call to the R function as.factor
  - fixed NA factors bug (thanks to Mark W. Kimpel!)
  - range checks disabled again (flexcel needs this)
  - other small fixes


o Functions (declarations) as per v1.2.1

  - "read.xls" <-
function( file = if (!is.na( keep )) NA,
  colNames = if (is.na( keep ) && !is.integer( file )) TRUE else FALSE,
  sheet = if (is.na( keep ) && !is.integer( file )) NA else NULL,
  type = "data.frame",
  from = NA, to = NA, rows = NA, cols = NA, cells = NA,
  rowNames = NA, colClasses = NA, checkNames = TRUE,
  dateTimeAs = "oledatetime",
  stringsAsFactors = default.stringsAsFactors(),
  formulasAsValues = TRUE,
  keep = NA )

  - "write.xls" <-
 function( x, file = if (!is.na( keep )) NA,
  colNames = if (is.na( keep ) && !is.integer( file )) TRUE else FALSE,
  sheet = if (is.na( keep ) && !is.integer( file )) NA else NULL,
  from = NA, to = NA, rows = NA, cols = NA, cells = NA,
  rowNames = NA, colClasses = NA,
  dateTimeAs = "oledatetime",
  keep = NA,
  append = FALSE )

  - xls.info, xls.sheet, xls.range, xls.image, xls.new, xls.open,
xls.save, xls.cancel, xls.close

  - languagesAndLCID, dateTimeToStr, dateTimeToIsoStr, strToDate,
strToDateTime, strToTime, isoStrToDateTime, shortDateFormat,
longTimeFormat, encodeDateTime, encodeDate, encodeTime, decodeDateTime

  - dateOf, timeOf, isInLeapYear, isPM, weeksInYear, daysInYear,
daysInMonth, now, today, isToday, yesterday, tomorrow, yearOf,
monthOf, weekOf, dayOf, hourOf, minuteOf, secondOf, milliSecondOf,
startOfTheYear, endOfTheYear, startOfTheMonth, endOfTheMonth,
startOfTheWeek, endOfTheWeek, st

Re: [R] select if + other questions

2007-04-27 Thread Natalie O'Toole
Hi,

Does anyone know how to skip variables (or columns) in R. Say, for example 
i had PUMFID position1 and Y_Q10A position 33 and i do not want to include 
all the variables in between. Is there a way to do this in R when you are 
extracting variables from a large .txt file with many, many variables?

Thanks,

Nat

__


Yes but I believe it will vary depending on what
package you're using.  I don't deal with weigthed data
so I'm not a good source

Have a look at help for something like lm in the stats
  package (part of the base installation) for an
example.
 
?lm 

weight is the fourth argument down.

However for more information try
http://finzi.psych.upenn.edu/search.html and type in
weight.

As Brian Ripley says in a reply to a question about
weights:
 "Almost all methods I know of do: logistic
regression, neural nets, classification trees, PPR
 "


--- Natalie O'Toole <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> Thank-you for the response!! That worked great!! Is
> there any way to apply 
> a weight variable to your file similar to what you
> can do in SPSS? So that 
> all of your other variables will be weighted by the
> weight variable?
> 
> Thanks,
> 
> Nat
> 
> __
> 
> 
> Hi, 
> 
> i am trying to read a .txt file, do a couple of
> select if statements on my 
> data, and then finally use the ?table function to
> get frequency counts on 
> the data. Specifically, i am looking at answering
> the following question: 
> 
> What is the frequency of Grade 7 students in the
> province of Alberta who 
> are smokers? 
> 
> I am having some problems: 
> 
> 1)i cannot get the column names to show up when
> print to screen 
> 
> 2)I cannot seem to skip variables properly when i
> choose certain other 
> variables 
> 
> 3)i cannot get the combination of Select If
> statements to work to produce 
> a different table with my new criteria
> 
> Here are the variables 
> 
> PUMFID position1 length 5 
> PROV position 6 length 2 
> GRADE position 9 length 2 
> Y_Q10A position 33 length 1 
> 
> 
> Y_Q10A has the following 1=yes 
>2=no
>   9=skip 
> 
> all the others have no skipped or missing values 
> 
> Here is my code: 
> 
> myfile<-("c:/test2.txt") 
> myVariableNames<-c("PUMFID","PROV","GRADE","Y_Q10A")
> 
> myVariableWidths<-c(5,2,2,1) 
> 
> 
>  mydata<-read.fwf( 
> file=myfile, 
> width=myVariableWidths, 
> col.names=myVariableNames, 
> row.names="PUMFID", 
> fill=TRUE, 
> strip.white=TRUE) 
> 
> 
> print(mydata) 
> 
> print( mydata [which(PROV=="AB" & GRADE==7 &
> Y_Q10A<9), ] ) 
> 
> 
> 
> Any help would be greatly appreciated!! 
> 
> Thank-you, 
> 
> Nat 
> 
>

> 
> 
> This communication is intended for the use of the
> recipient to which it is 
> addressed, and may
> contain confidential, personal, and or privileged
> information. Please 
> contact the sender
> immediately if you are not the intended recipient of
> this communication, 
> and do not copy,
> distribute, or take action relying on it. Any
> communication received in 
> error, or subsequent
> reply, should be deleted or destroyed. 
>

> 
> 
> This communication is intended for the use of the
> recipient to which it is 
> addressed, and may
> contain confidential, personal, and or privileged
> information. Please 
> contact the sender
> immediately if you are not the intended recipient of
> this communication, 
> and do not copy,
> distribute, or take action relying on it. Any
> communication received in 
> error, or subsequent
> reply, should be deleted or destroyed.
>[[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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.
> 



  Be smarter than spam. See how smart SpamGuard is at giving junk 
email the boot with the All-new Yahoo! Mail at 
http://mrd.mail.yahoo.com/try_beta?.intl=ca



 

This communication is intended for the use of the recipient to which it is 
addressed, and may
contain confidential, personal, and or privileged information. Please 
contact the sender
immediately if you are not the intended recipient of this communication, 
and do not copy,
distribute, or take action relying on it. Any communication received in 
error, or subsequent
reply, should be deleted or destroyed.
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https:

[R] R-2.5.0:BioCv2install

2007-04-27 Thread Anna Lobley
I am receiving the following errors when trying to install
gcrma and a number of other Bioconductor packages when
the installWithVers flag is set to be TRUE.

>source("http://www.bioconductor.org/getBioC.R";);
>getBioC("gcrma", installWithVers=T);
Running biocinstall version 2.0.7 with R version 2.5.0
Your version of R requires version 2.0 of Bioconductor.

Loading required package: affy
Loading required package: Biobase
Loading required package: affy
Loading required package: Biobase
Loading required package: affy
Loading required package: Biobase
Loading required package: affy
Loading required package: Biobase
Loading required package: affy
Loading required package: Biobase
Loading required package: affy
Loading required package: Biobase etc etc.

Error: evaluation nested too deeply: infinite recursion / 
options(expressions=)?
Execution halted
ERROR: lazy loading failed for package 'gcrma'
** Removing 'R-2.5.0/library/gcrma_2.8.0'


Session Info below:
R version 2.5.0 (2007-04-23)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C

any help appreciated..
Anna
---
Research Student
Bioinformatics Unit
Department of Computing
University College London

__
R-help@stat.math.ethz.ch 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] SweaveInput and absolute paths

2007-04-27 Thread Kevin R. Coombes
The path is correct, and the file exists.  Here is a transcript of the R 
session:

-
 > sessionInfo()
R version 2.4.0 (2006-10-03)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] "methods"   "stats" "graphics"  "grDevices" "utils"  "datasets"
[7] "base"
 > getwd()
[1] "G:/Working/Fidler-Nakamura-Periphery"
 > dir("M:/Resources/Affymetrix")
  [1] "affyExample.Rnw" "affyExample.tex" "affyplots.Rnw"  "chkMiame.Rnw"
  [5] "fnp.Rnw" "libLoad.Rnw" "readCel.Rnw""rma.Rnw"
  [9] "rnadeg.Rnw"  "simpleQC.Rnw"
 > Sweave("affyExample.Rnw")
Writing to file affyExample.tex
Processing code chunks ...
Error in SweaveReadFile(c(ifile, file), syntax) :
 no Sweave file with name 
'./M:/Resources/Affymetrix/libLoad.Rnw' found
In addition: Warning message:
list.files: './M:/Resources/Affymetrix' is not a readable directory
-

Dieter Menne writes:
 > Kevin R. Coombes  mdacc.tmc.edu> writes:
 >
 > >
 > > Is there a way to turn off the automatic inclusion of "./" at the
 > > beginning of a path specified in an \SweaveInput{} instruction?
 > >
 >
 > Giving a full file path name works for me (Windows, R 2.4.1)
 >
 > \SweaveInput{C:/tmp/MyTitle.rnw}
 >
 > Note the if the path does not exist, e.g
 >
 > \SweaveInput{C:/tmpnotexist/MyTitle.rnw},
 >
 > the error message refert to  "./C:/tmpnotexist/MyTitle.rnw", so it
 > could be that the path you chose had been incorrectly entered.
 >
 > Dieter

__
R-help@stat.math.ethz.ch 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] Write text in the

2007-04-27 Thread Matthew Neilson
Hey Felix,

So basically what you want is a figure containing a block of four plots, with a 
main title for the figure? If that's the case then something like this should 
work:

# BEGIN CODE #

par(oma=c(0,0,1,0), mfrow=c(2,2))
for(i in 1:4){
plot(NA,xlim=range(0,10),ylim=range(-5,5))
title(paste("Plot ",i,sep=""))
}

par(mfrow=c(1,1), oma=c(0,0,1,0))
mtext("Main Title", 3, outer = TRUE, cex = par("cex.main"))

# END CODE #

You can play about with the margins, but I think that's the general idea. Is 
this what you're after?


-Matt



On Fri Apr 27 15:34 , Felix Wave <[EMAIL PROTECTED]> sent:

>Hello,
>I started a graphic device:
>>par(oma = c(2,0,0,0), mfrow=c(2,2) )
>
>in the cols and rows are three "image"s.
>Now I want to write a text in the "device region", it's the
>main title of the graphic device. But when I use "mtext()" I can
>only write in the "figure region" of my four plots.
>
>Has anybody an idea?
>
>Thanks a lot.
>
>Felix
>
>
>
>My R Code:
>--
>par(oma = c(2,0,0,0), mfrow=c(2,2) )
>
>mtext("Main title", side = 3, line = 0)
>
>image(zDIV)
>image(zMEDIAN )  
>image(zMEAN) 
>image(zSD)  
>dev.off() 
>
>
>
>graphic:   
>
>---
>|  MAIN TITLE   device region 
>---
>|   figure region|   figure region|
>|  --||
>|  |   |||  ||
>|  |   |||  ||
>|  |   |||  ||
>|  |   |||  ||
>|  -- |
>||   
>---
>|   figure region|   figure region|
>|  --||
>|  |   |||  ||
>|  |   |||  ||
>|  |   |||  ||
>|  |   |||  ||
>|  -- |
>||
>
>__
>R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Write text in the "device region" of a graphic device

2007-04-27 Thread Felix Wave
Hello,
I started a graphic device:
>par(oma = c(2,0,0,0), mfrow=c(2,2) )

in the cols and rows are three "image"s.
Now I want to write a text in the "device region", it's the
main title of the graphic device. But when I use "mtext()" I can
only write in the "figure region" of my four plots.

Has anybody an idea?

Thanks a lot.

Felix



My R Code:
--
par(oma = c(2,0,0,0), mfrow=c(2,2) )

mtext("Main title", side = 3, line = 0)

image(zDIV)
image(zMEDIAN )  
image(zMEAN) 
image(zSD)  
dev.off() 



graphic:   

---
|   MAIN TITLE   device region 
---
|   figure region|   figure region|
|  --||
|  ||||  ||
|  ||||  ||
|  ||||  ||
|  ||||  ||
|  -- |
| |   
---
|   figure region|   figure region|
|  --||
|  ||||  ||
|  ||||  ||
|  ||||  ||
|  ||||  ||
|  -- |
| |

__
R-help@stat.math.ethz.ch 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] [R-pkgs] Hmisc Version 3.3-2 is now in CRAN repository

2007-04-27 Thread Charles Dupont
Hmisc Version 3.3-2 has been posted to the CRAN repository.

Change Log

3.3-2 4/26/2007
   Fixed bug with combine<- function not handling NULL values.

3.3-1 3/29/2007
   Created functions trunc.POSIXt, ceil.POSIXt, round.POSIXt to do
   those ops on POSIXt objects.  Removed chron versions of these
   functions.

   Placed Hmisc in a namespace

   Factored out category levels that are identical (and in the same
   order) for multiple variables.  Changed print and html methods
   accordingly, and made new default for html output,
   levelType='list'.

   new argument levelType in html.contents.data.frame

   enhanced html.data.frame to set column headings in h2

   added curtail option (default: FALSE) for type='regression' to
   set imputed values to the boundaries of real data if outside

   added datadensity argument to plot.aregImpute

   fixed bug with curtail, added datadensity argument to
   plot.aregImpute

   fixed typo related to bass argument

   fixed bug in latex.describe to translate underscores in variable
   names when listing those with all NAs

   fixed inmChoice by unclassing first argument when pasting

   handled underscore in dataset name in latex.describe by calling
   latexTranslate

   Finished addition of listunique and listnchar, handled listing
   of character values in latex.describe.*

   listunique and listnchar

   For listunique option ignored multiple white spaces, leading and
   trailing white spaces, and case in tabulating character strings.

   For listunique ignored leading and trailing white space,
   multiple white spaces, and case when tabulating character
   strings. Carriage returns without new lines are changed to a
   single space.

   Modified 'extracolheads' such that when cgroup and n.cgroup are
   used in a latex.summary.formula.reverse statement the extra N=
   columns line up correctly.

   added boot.method argument to implement approximate Bayesian
   bootstrap when group is not used

   'R/inc-dec.s' created 2 new functions 'inc<-' and 'dec<-'. 
'inc<-' increments
   'x' by value assigned to it.  'dec<-' does the same thing but 
decrements 'x'.

   'R/responseSummary.s' changed 'responseSummary' 'FUN' argument
   so that is it run on each row of the response instead of the
   whole of the response.

   'R/latexObject.s' changed names of constant escapes.

   'R/combine.s' functions to perform element wise combination.

   'R/print.char.list.s'  various code simplifications.

   Corrected extra escapes in latexSN function.  fixes #10.

3.2-1 1/25/2007:
   Hmisc function 'ecdf' has been renamed 'Ecdf' to deconflict it
   with the existing 'ecdf' function in base.

   Fixed Bug in format.df that would create numbers with many
   trailing zeros.

   Added arguments 'math.row.names' and 'math.col.names' to
   indicate that the row or col names should be wrapped in the
   latex math environment.

   Fixed problem with 'histbackback' function.

-- 
Charles Dupont  Computer System Analyst School of Medicine
Department of Biostatistics Vanderbilt University

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@stat.math.ethz.ch 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] (no subject)

2007-04-27 Thread Matthew Neilson
Hey,

The syntax is:

if(condition){
  #COMMANDS_A
} else{
  #COMMANDS_B
}

Hope this helps,


-Matt




On Fri Apr 27 15:07 , elyakhlifi mustapha <[EMAIL PROTECTED]> sent:

>hi,
>I don't understand my error when I submit this program 
>
>> for(k in LR) {
>+ donRep[[k]] 
>+ M[[193]] 
>+ for(k in LR) {
>+
>if(length(as.numeric(as.character(donRep[[k]][,1]))) == min(C)) {
>+ M[[193]][,k] 
>+ }
>+  else  M[[193]][,k] 
>+}
>+ }
>> if (subset(donParCara, Id_Cara == 308 , select = Ana_C) == "AV") {
>+  
> print(cor(M[[308]], method = "pearson"))
>+  
>}
>> else print(cor(M[[193]], method = "spearman"))
>Erreur : erreur de syntaxe dans "else"
>
>Can you help me please?
>
>
>  
>___
>
>
>
>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] (no subject)

2007-04-27 Thread elyakhlifi mustapha
hi,
I don't understand my error when I submit this program 

> for(k in LR) {
+ donRep[[k]] <- subset(don2, Id_Essai == 1006961 & 
Id_Cara == 193 & Id_Rep == k , select = Val_O)
+ M[[193]] <- matrix(rep(1, 3*min(C)), nrow = min(C), 
ncol = 3)
+ for(k in LR) {
+
if(length(as.numeric(as.character(donRep[[k]][,1]))) == min(C)) {
+ M[[193]][,k] <- as.numeric(as.character(donRep[[k]][,1]))
+ }
+  else  M[[193]][,k] <- 
as.numeric(as.character(donRep[[k]][,1]))[(length(as.numeric(as.character(donRep[[k]][,1])))
 - min(C) + 1):length(as.numeric(as.character(donRep[[k]][,1])))]
+}
+ }
> if (subset(donParCara, Id_Cara == 308 , select = Ana_C) == "AV") {
+   
print(cor(M[[308]], method = "pearson"))
+   
   }
> else print(cor(M[[193]], method = "spearman"))
Erreur : erreur de syntaxe dans "else"

Can you help me please?


  
___





[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] how to be clever with princomp?

2007-04-27 Thread Gavin Simpson
On Fri, 2007-04-27 at 12:58 +0100, Simon Pickett wrote:
> Hi all,
> 
> I have been using princomp() recently, its very useful indeed, but I have
> a question about how to specify the rows of data you want it to choose.
> 
> I have a set of variables relating to bird characteristics and I have been
> using princomp to produce PC scores from these.
> 
> However since I have multiple duplicate entries per individual (each bird
> had a varying number of chicks), I only want princomp to treat each
> individual bird as the sample and not include all the duplicates. Then I
> want to replicate the pc scores for all the duplicated rows for that
> individual.
> 
> Any idea how to do this?

## example data using the vegan package
require(vegan)
data(varespec)
## duplicate some rows
vare2 <- varespec
vare2 <- rbind(vare2, varespec[sample(nrow(varespec), 50, replace =
TRUE), ])
## build the model using prcomp - it is better - on the original data
## without duplicates
mod <- prcomp(varespec, centre = TRUE, scale. = TRUE)
## predict for full matrix inc duplicated rows
pred <- predict(mod, vare2)

Takes 0.005 seconds on my machine. So get a subset of your data without
the duplicates, then use the predict method for prcomp.
See ?predict.prcomp.

Is that what you wanted?

G

> 
> Up to now I have been using princomp to only select the entries which are
> not duplicated which is easy, but the difficult bit is the programming to
> duplicate the pc scores across the entries for each individual.
> 
> (I developed something that worked but it takes about 5 minutes to run!)
> 
> Thanks for all your help,
> 
> very much appreciated,
> 
> Simon.
> 
> 
> 
> 
> Simon Pickett
> PhD student
> Centre For Ecology and Conservation
> Tremough Campus
> University of Exeter in Cornwall
> TR109EZ
> Tel 01326371852
> 
> __
> R-help@stat.math.ethz.ch 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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] Update of xlsReadWrite package

2007-04-27 Thread Hans-Peter
The (*windows only*) xlsReadWrite package has been updated and the new
version is available on CRAN.

xlsReadWrite natively reads and writes Excel files (v97 - 2003).


o Changes from v1.1.1 to v1.3.3 (versions between never really published)

  - ROWNAMES-support also for matrices (not only for data.frame)
  - explicit rowNames argument in interface.
(stimulated by email Adrian Dusa)

  - support for DATE and TIME values: Excel date and/or time values can
be retrieved as ISO-8601 format string.
- Either explicitly with the colClasses entries:
  - "isodate" as "-MM-DD"
  - "isotime" as "hh:mm:ss"
  - "isodatetime"as "-MM-DD hh:mm:ss"
- Or for data.frame an eventual date/time type can be automatically
  determined from the value(s) of the first Excel row (determined from
  the cell formatting as there are no real date types in Excel)

   - There are four DATE CONVERSION ROUTINES (taken from pro) which enable
 you to work with Excel date/times values:
 - dateTimeToStr converts an ole datetime value to a string
 - strToDateTime vice versa (depends on local settings)
 - dateTimeToIsoStr  }
 - isoStrToDateTime  } independent of local settings
(date/time support stimulated by an email of Gabor Grothendiek)

  - new argument "stringsAsFactors = default.stringsAsFactors()"
(proposed by Peter Cock)
Remark: this is a *potentially code breaking change*.
Until now strings have been retrieved as characters.

  - new argument "checkNames = TRUE"
(proposed by Peter Cock)

  - colClasses entries modified:
- "numeric" and "factor added,
- "rowname" removed (is now a proper argument)
- scalar values will be recycled (proposed by David Kinniburgh)
  - if explicit colClasses have not been given, the colClasses will
be determined from the first 16 Excelrows)
(stimulated by email David Kinniburgh)

  - empty cells for double columns come now as NA (before it was 0)

  - factors now handled in the Delphi (calls R function as.factor)
  - matrix output-type otFactor removed (not used)
  - fixed NA factors bug (thanks to Mark W. Kimpel)
  - range checks disabled again (flexcel needs this)
  - some other small fixes


o Function declarations as per v1.3.2
  - read.xls( file,
  colNames = TRUE,
  sheet = 1,
  type = "data.frame",
  from = 1,
  rowNames = NA, colClasses = NA, checkNames = TRUE,
  dateTimeAs = "numeric",
  stringsAsFactors = default.stringsAsFactors() )

  - write.xls( x, file,
   colNames = TRUE,
   sheet = 1,
   from = 1,
   rowNames = NA )

  - dateTimeToStr( odate, format = "" )
  - strToDateTime( sdate )
  - dateTimeToIsoStr( odate, isoformat = "-MM-DD hh:mm:ss" )
  - isoStrToDateTime( sdate )


o Download

  - CRAN (v1.3.2; from within RGui) or
  - http://treetron.googlepages.com/ (v1.3.3)
- direct link to package:
http://treetron.googlepages.com/xlsReadWrite_1.3.3.zip
- direct link to test-/demoscripts:
http://treetron.googlepages.com/xlsReadWrite_TestData_1.3.3.zip

  - the testscript is used for our internal "unittests". It will show
you many examples of how to use the package.


Comments and suggestions are welcome.
Hope you enjoy using xlsReadWrite!


-- 
Regards,
Hans-Peter

__
R-help@stat.math.ethz.ch 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] error returned by "make check" in R-2.5.0

2007-04-27 Thread Eric Thompson
Today I tried to install the R-2.5.0 (currently running R-2.4.1) on
Mandriva Linux. The ./configure and make commands seem to run fine,
but "make check" gives the following messages:

running regression tests
make[3]: Entering directory `/home/ethomp04/R-2.5.0/tests'
running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1
make[3]: Leaving directory `/home/ethomp04/R-2.5.0/tests'
make[2]: *** [test-Reg] Error 2
make[2]: Leaving directory `/home/ethomp04/R-2.5.0/tests'
make[1]: *** [test-all-basics] Error 1
make[1]: Leaving directory `/home/ethomp04/R-2.5.0/tests'
make: *** [check] Error 2

Regarding "make check", the R-admin.html page says "Failures are not
necessarily problems as they might be caused by missing
functionality..."

So, looking at the "reg-tests-1.Rout.fail" file, I see that the error
occurs here:

> ## eigen
> Meps <- .Machine$double.eps
> set.seed(321, kind = "default")# force a particular seed
> m <- matrix(round(rnorm(25),3), 5,5)
> sm <- m + t(m) #- symmetric matrix
> em <- eigen(sm); V <- em$vect
> print(lam <- em$values) # ordered DEcreasingly
[1]  5.1738946  3.1585064  0.6849974 -1.6299494 -2.5074489
>
> stopifnot(
+  abs(sm %*% V - V %*% diag(lam))< 60*Meps,
+  abs(sm - V %*% diag(lam) %*% t(V)) < 60*Meps)
>
> ##--- Symmetric = FALSE:  -- different to above : ---
>
> em <- eigen(sm, symmetric = FALSE); V2 <- em$vect
> print(lam2 <- em$values) # ordered decreasingly in ABSolute value !
[1]  5.1738946  3.1585064 -2.5074489 -1.6299494  0.6849974
> print(i <- rev(order(lam2)))
[1] 1 2 5 4 3
> stopifnot(abs(lam - lam2[i]) < 60 * Meps)
Error: abs(lam - lam2[i]) < 60 * Meps is not all TRUE
Execution halted


Interestingly, running these same tests on R-2.4.1 on the same system
does not give an error:

> Meps <- .Machine$double.eps
> set.seed(321, kind = "default") # force a particular seed
> m <- matrix(round(rnorm(25),3), 5,5)
> sm <- m + t(m) #- symmetric matrix
> em <- eigen(sm); V <- em$vect
> print(lam <- em$values) # ordered DEcreasingly
[1]  5.17389456321  3.15850637323  0.68499738238 -1.62994940108 -2.50744891774
> stopifnot(
+  abs(sm %*% V - V %*% diag(lam))  < 60*Meps,
+  abs(sm  - V %*% diag(lam) %*% t(V)) < 60*Meps)
>
> ##--- Symmetric = FALSE:  -- different to above : ---
>
> em <- eigen(sm, symmetric = FALSE); V2 <- em$vect
> print(lam2 <- em$values) # ordered decreasingly in ABSolute value !
[1]  5.17389456321  3.15850637323 -2.50744891774 -1.62994940108  0.68499738238
> print(i <- rev(order(lam2)))
[1] 1 2 5 4 3
> stopifnot(abs(lam - lam2[i]) < 60 * Meps)
> abs(lam - lam2[i]) < 60 * Meps
[1] TRUE TRUE TRUE TRUE TRUE

I'm not sure what to do next, or how serious of a problem this might
be. I would appreciate any suggestions or advice. I thought maybe this
was due to something about how my system is setup, but since I don't
get the error in R-2.4.1, that seems to imply to me that there is
something different in R-2.5.0 that is causing it.

Thanks.

Eric Thompson
Tufts University
Civil & Environmental Engineering

> sessionInfo()
R version 2.4.1 (2006-12-18)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "datasets"  "utils" "stats" "graphics"  "grDevices" "methods"
[7] "base"

other attached packages:
MASS
"7.2-31"

__
R-help@stat.math.ethz.ch 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] partitioning variation using the Vegan CCA routine?

2007-04-27 Thread Gavin Simpson
On Fri, 2007-04-27 at 16:03 +1000, Matthew McArthur wrote:
> Hello
> I am using Jari Oksanen's CCA routine from the Vegan package on some estuary
> data, following a technique applied in (Anderson, M.J. & Gribble, N.A.,
> 1998, Partitioning the variation among spatial, temporal and environmental
> components in a multivariate data set, Australian Journal of Ecology 23,
> 158-167).
> Some steps in the process require that the dependent matrix be constrained
> by one independent matrix, given the affect of another independent matrix.
> 
> eg: CCA of species matrix, constrained by the environmental matrix, with
> spatial variables treated as covariables
> or:  CCA of species matrix, constrained by the temporal matrix, with
> environmental and spatial variables treated as covariables
> 
> Does anyone know of a partitioning routine able to perform this feat or have
> suggestions on how I might approach the problem from scratch?

If you can survive with using RDA ( rda() ), then vegan has function
varpart() to do this automagically for you. If you really need CCA, then
perhaps try a standardisation of the raw data so that when you use rda()
via varpart(), what you get is close to something that cca() would
return or is a good compromise for species data - see ?decostand with
method == "chi.square" or "method = "hellinger" in vegan and the cited
reference to see what I'm talking about here.

If you want to do things by hand the old fashioned way, then look at
using Condition(var_x) in your formula:

res <- cca(spp ~ var1 + var2 + Condition(spatial.vars), data = my.data)

see ?cca

HTH

G

> 
> Cheers
> Matt
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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] Randomising matrices

2007-04-27 Thread Gavin Simpson
On Fri, 2007-04-27 at 09:45 +0100, Nick Cutler wrote:

Hi Nick

(Been meaning to reply to your private email to me but I've been away on
vacation and at meeting for several weeks)

> I would like to be able to randomise presence-absence (i.e. binary) 
> matrices whilst keeping both the row and column totals constant. Is 
> there a function in R that would allow me to do this?

I thought r2dtable() would suffice, but this doesn't return binary
matrices.

There appears to be a lot of literature on this - Zaman and Simberloff
(2002, Environmental and Ecological Statistics 9, 405--421) discuss many
previous attempts to do this and present another approach.

I've been interested in this for a little while so cooked up one of
their reviewed methods this morning. It works by choosing at random 2
rows and 2 columns of your matrix, leading to a 2x2 sub matrix of your
original matrix.

If this matrix is:

1 0
0 1

or 

0 1
1 0

then you can swap the 0s and 1s and you haven't altered the row or
column sums any. You do this swap many times as a "burn in" period, and
then you can sample a random matrix by making one further swap.

The problem with this method is that it might not faithfully represent
the full universe of possible matrices (with row column constraints), in
that you might end up sampling only a string of matrices from a small
region of all possible matrices. One way to get round this is that
following the burn in, you then take a matrix only after the k+1th swap
- i.e. you make k swaps and then draw the matrix, rather than draw after
each swap. Whether you need the skip is debatable (Manly 1995, Ecology
76, 1109-1115).

The appended rBinMat() function implements this method (it is after
Roberts and Stone, 1990, Oecologia 83, 560--567), using a burn in period
of 1000 and a skip step of 100 as defaults that you can change. I have
no idea if these default are sufficient as I've not read 

An example usage is:
> set.seed(1234)
> dat <- matrix(sample(c(0,1), 100, replace = TRUE), ncol = 10)
> system.time(ran.mat <- rBinMat(dat))
   user  system elapsed 
  0.923   0.002   0.953 
> ran.mat
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]100101001 0
 [2,]100111001 0
 [3,]100000100 0
 [4,]111010110 1
 [5,]000010000 0
 [6,]111111111 1
 [7,]010010000 0
 [8,]101001000 0
 [9,]011000010 0
[10,]100111111 1
> identical(rowSums(dat), rowSums(ran.mat))
[1] TRUE
> identical(colSums(dat), colSums(ran.mat))
[1] TRUE

The size of the matrix is not an issue, but rather the burn in required.
With larger matrices you need to do longer burn in, and make larger
skips perhaps. The 56 species by 28 islands example in Roberts and Stone
(1990), using a burn in of 100 000 (as per their paper), 56 seconds is
needed to get the first matrix and then 0.5 seconds to do the
recommended 1000 skips to get the next matrix. Subsequent matrices take
0.5 seconds to generate on my machine (see below).

rBinMat() returns a single matrix, so if you want to draw n random
matrices you need to run the function n times. But this is wasteful if
you do the burn in each time. So, generate the first matrix as such:

dat <- matrix(sample(c(0,1), 100, replace = TRUE), ncol = 10)
mat <- rBinMat(dat, burn.in = 1000, skip = 100)

then in your loop to generate stats on the NULL models, start from mat
and set burn.in to 0, e.g.

nit <- 1000
for(i in 1:nit) {
   mat2 <- rBinMat(mat, burn.in = 0, skip = 100)
   ### other stats here on the null model
}

Note that there are other ways to do this and the paper Stéphane Dray
pointed you to plus the Zaman & Simberloff one I cite above look at
these in more detail.

HTH

G

Here is the function - some of it is a bit clunky, and can surely be
improved.

rBinMat <- function(x, burn.in = 1, skip = 1000) {
  ## number rows/cols
  n.col <- ncol(x)
  n.row <- nrow(x)
  ## function to draw at random 2 rows and colums
  ## just returns the indices required
  randDraw <- function(x, nr, nc) {
ran.row <- sample(nr, 2)
ran.col <- sample(nc, 2)
return(c(ran.row, ran.col))
  }
  ## is the 2x2 matrix diagonal or anti-diagonal
  isDiag <- function(x) {
X <- as.vector(x)
Diag <- aDiag <- FALSE
if(identical(X, c(1,0,0,1)))
  return(TRUE)
else if(identical(X, c(0,1,1,0)))
  return(TRUE)
else
  return(FALSE)
  }
  changed <- 0
  ## do the burn in changes, then skip, then an extra change,
  ## this is then the first random matrix we want to draw
  while(changed <= (burn.in + skip + 1)) {
want <- randDraw(x, n.row, n.col)
X <- x[want[1:2], want[3:4]]
if(isDiag(X)) {
  x[want

Re: [R] Randomising matrices

2007-04-27 Thread Gabor Grothendieck
Try

?r2dtable

On 4/27/07, Nick Cutler <[EMAIL PROTECTED]> wrote:
> I would like to be able to randomise presence-absence (i.e. binary)
> matrices whilst keeping both the row and column totals constant. Is
> there a function in R that would allow me to do this?
>
> I'm working with vegetation presence-absence matrices based on field
> observations. The matrices are formatted to have sites as rows and
> species as columns. The presence of a species on a site is indicated
> with a 1 (absence is obviously indicated with a 0).
>
> I would like to randomise the matrices many times in order to construct
> null models. However, I cannot identify a function in R to do this, and
> the programming looks tricky for someone of my limited skills.
>
> Can anybody help me out?
>
> Many thanks,
>
> Nick Cutler
>
> Institute of Geography
> School of Geosciences
> University of Edinburgh
> Drummond Street
> Edinburgh EH8 9XP
> United Kingdom
>
> Tel: 0131 650 2532
> Web: http://www.geos.ed.ac.uk/homes/s0455078
>
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] proportional sampling

2007-04-27 Thread Ted Harding
On 27-Apr-07 12:15:29, [EMAIL PROTECTED] wrote:
> Dear All,
> 
> I wonder if you could help me.
> 
> I have a table with a series of sites that I would like to
> sample from.
> The table has 5 columns:
> 
> ID
> X Coordinate
> Y Coordinate
> Value
> Factor
> 
> 
> The conditions are that each site can be selected more than
> once and the probability of it being selected (or sampled)
> is proportional to a factor located in column 'Factor'
> 
> I am novice in terms of R, and am not entirely sure how to
> do the proportional sampling.
> 
> Any help would be appreciated
> Thanks
> Tibi

Since you want each site to be able to appear more than once
in the sample, there should be no problems in using sample():

  ID.sample <- sample(ID, N, replace=TRUE, prob=Factor)

where N is the sample size you want. (You do not need to make
Factor sum to 1: sample() looks after that).

Or, if you want an index which you can use to identify whole
rows (especially if, e.g., values of ID are repeated in the
table):

  ix <- sample((1:R), N, replace=TRUE, prob=Factor)

where R is the number of rows in the table. Then your sample
is the subset

  Table[ix,]

of rows of the table (where "Table" stands for the name of your table).

There are more complicated issues which can arise if you are
sampling without replacement with probability proportional to
some variable. Have a look at the packages 'pps' and 'sampfling'
for an indication of methods.

Hoping this helps,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 27-Apr-07   Time: 14:07:03
-- XFMail --

__
R-help@stat.math.ethz.ch 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] partitioning variation using the Vegan CCA routine?

2007-04-27 Thread Matthew McArthur
Hello
I am using Jari Oksanen's CCA routine from the Vegan package on some estuary
data, following a technique applied in (Anderson, M.J. & Gribble, N.A.,
1998, Partitioning the variation among spatial, temporal and environmental
components in a multivariate data set, Australian Journal of Ecology 23,
158-167).
Some steps in the process require that the dependent matrix be constrained
by one independent matrix, given the affect of another independent matrix.

eg: CCA of species matrix, constrained by the environmental matrix, with
spatial variables treated as covariables
or:  CCA of species matrix, constrained by the temporal matrix, with
environmental and spatial variables treated as covariables

Does anyone know of a partitioning routine able to perform this feat or have
suggestions on how I might approach the problem from scratch?

Cheers
Matt

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Randomising matrices

2007-04-27 Thread Finny Kuruvilla

Stephanie Dray's comments are absolutely correct.  This method will
only work with small matrics.  The below modification is much faster
than the first version that I wrote, but still slow on large
matrices.

shuffle_matrix <- function(x) {
  nrow = dim(x)[1]
  ncol = dim(x)[2]
  cmargins <- apply(x,2,sum)
  shuffled = array(length(x),dim=c(nrow,ncol))

  while(1) {
for(k in 1:nrow) {
  shuffled[k,] = sample(x[k,],ncol)
}
if(all(apply(shuffled,2,sum) == cmargins)) {
  break
}
  }
  shuffled
}


On Fri, 27 Apr 2007, Stéphane Dray wrote:


Your solution is not suitable for quite large matrices.

There are several papers on the subject :

e.g. :
@ARTICLE{SD751,
author = {Gotelli, N.J. and Entsminger, G.L.},
title = {Swap and fill algorithms in null model analysis:rethinking the 
knight's

  tour},
journal = {Oecologia},
year = {2001},
volume = {129},
pages = {281-291},
endnotereftype = {Journal Article},
keywords = {null model},
pdf = {/home/stephane/Biblio/Articles/SD751.pdf},
shorttitle = {Swap and fill algorithms in null model analysis:rethinking the 
knight's

  tour}
}

There are different algorithms to solve the question but I am really not sure 
that they are implemented in R.


Sincerely,


Finny Kuruvilla wrote:

Hi Nick,

This way isn't the most elegant but works well, especially if the
matrices aren't too large:

# This function works on 2x2 arrays, randomizing them, but
# preserving row and column totals
shuffle_matrix <- function(x) {
   nrow = dim(x)[1]
   ncol = dim(x)[2]
   rmargins <- apply(x,1,sum)
   cmargins <- apply(x,2,sum)

   while(1) {
 shuffled <- array(sample(x,length(x),replace=TRUE),dim=c(nrow,ncol))
 if(all(apply(shuffled,1,sum) == rmargins)) {
   if(all(apply(shuffled,2,sum) == cmargins)) {
 break
   }
 }
   }
   shuffled
}

Example:



a=array(sample(c(0,1),10,replace=TRUE),dim=c(5,2))
a


  [,1] [,2]
[1,]01
[2,]11
[3,]01
[4,]01
[5,]10


shuffle_matrix(a)


  [,1] [,2]
[1,]01
[2,]11
[3,]10
[4,]01
[5,]01

Best,
Finny Kuruvilla

*
Finny Kuruvilla, MD, PhD
Harvard Medical School Fellowship Program in Transfusion Medicine
Broad Institute of MIT and Harvard
Homepage: http://www.people.fas.harvard.edu/~kuruvill/home/


On Fri, 27 Apr 2007, Nick Cutler wrote:



I would like to be able to randomise presence-absence (i.e. binary)
matrices whilst keeping both the row and column totals constant. Is
there a function in R that would allow me to do this?

I'm working with vegetation presence-absence matrices based on field
observations. The matrices are formatted to have sites as rows and
species as columns. The presence of a species on a site is indicated
with a 1 (absence is obviously indicated with a 0).

I would like to randomise the matrices many times in order to construct
null models. However, I cannot identify a function in R to do this, and
the programming looks tricky for someone of my limited skills.

Can anybody help me out?

Many thanks,

Nick Cutler

Institute of Geography
School of Geosciences
University of Edinburgh
Drummond Street
Edinburgh EH8 9XP
United Kingdom

Tel: 0131 650 2532
Web: http://www.geos.ed.ac.uk/homes/s0455078

__
R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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.






--
Stéphane DRAY ([EMAIL PROTECTED] )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/



*
Finny Kuruvilla, MD, PhD
Harvard Medical School Fellowship Program in Transfusion Medicine
Broad Institute of MIT and Harvard
Homepage: http://www.people.fas.harvard.edu/~kuruvill/home/__
R-help@stat.math.ethz.ch 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] Unwanted white borders on semi-transparent polygons?

2007-04-27 Thread Matthew Neilson
Hi Brian,

Terribly sorry if I accidentally broke a rule. sessionInfo() produces the 
following:

> sessionInfo()
R version 2.2.1, 2005-12-20, powerpc-apple-darwin7.9.0 

attached base packages:
[1] "methods"   "stats" "graphics"  "grDevices" "utils" "datasets" 
[7] "base" 

I cannot upgrade to the latest version of R, since I'm using OS X 10.3.9 
(Panther) and the latest builds require 10.4.4 (Tiger) or greater. It's 
interesting to know that R version 2.4.0 
contains a transparency bug, though - I'll ask IT Services to install the 
latest version of R on the G5 and see if that helps.

Many thanks for all your help,


-Matt



On Fri Apr 27 12:58 , Prof Brian Ripley <[EMAIL PROTECTED]> sent:

>The posting guide says
>
>   For questions about unexpected behavior or a possible bug, you should,
>   at a minimum, copy and paste the output from sessionInfo() into your 
> message.
>
>   If you are using an old version of R and think it does not work
>   properly, upgrade to the latest version and try that, before posting.
>
>[There is a known bug in 2.4.0 related to semi-transparency, fixed in 
>2.4.0.  I would not have attempted to answer a question about 2.1.1, and 
>we do rely on people seeking free technical assistance doing their bit.]
>
>
>On Fri, 27 Apr 2007, Matthew Neilson wrote:
>
>> Thanks for your fast response.
>>
>> I'm using R version 2.1.1 on OS X 10.3.9 to create the pdfs. I have tried 
>> viewing the pdf output in both Acrobat 6 and 7 (both display a white border 
>> around each polygon) as well 
as
>> Preview (displays fine). I have emailed the pdf file to some correspondents 
>> running Windows, and they also see white borders when viewing with Acrobat 
>> (version unspecified).
>>
>> I have tried using R version 2.4.0 on a G5 machine (which I can access 
>> remotely) running OS X 10.4.8, but the resulting pdf renders incorrectly 
>> (i.e. with a white border around 
each
>> polygon) in both Acrobat *and* Preview. So it would appear that the 
>> combination of R 2.1.1 and OS X 10.3.9 gives slightly better results - 
>> although plots still appear incorrect 
when
>> printed or viewed in Acrobat.
>>
>> Unfortunately, I don't have access to a Windows machine to test this out. 
>> Even if I did, many of my scripts include various Unix system calls so I 
>> don't think that would be a viable
>> solution. Could this be a bug in the OS X pdf driver?
>
>The R pdf() device is the same on all platforms.
>
>> Many thanks,
>>
>>
>> -Matt
>>
>>
>>
>> On 27 Apr 2007, at 06:42, Prof Brian Ripley wrote:
>>
>>> What version of R, what OS, what version of Acrobat?
>>>
>>> I don't see this in 2.5.0 on Windows (using Acrobat 7: Acrobat does not
>>> exist on Linux, AFAIK).  And reading the PDF produced shows no sign of an
>>> extra object for the border.
>>>
>>> On Fri, 27 Apr 2007, Matthew Neilson wrote:
>>>
 Hey all,

 I'm trying to create a plot of two semi-transparent regions. The reason 
 they need to be partially transparent is so that I can see if there's any 
 overlap. Here's some example 
code:

 # BEGIN

 pdf(file="test.pdf",version="1.4")
 plot(0,0,type="l",ylim=range(-3,3),xlim=range(-1,5))
 polygon(c(0,1,2,3,4,3,2,1,0), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(1,0,0,0.5),
 border=NA)
 polygon(c(1,2,3,4,5,4,3,2,1), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(0,0,1,0.5),
 border=NA)
 dev.off()

 # END

 The problem with this is that, despite setting "border = NA", I get a
 big white border surrounding each polygon!! Funnily enough, setting the
 alpha channel equal to 1 (as opposed to 0.5) *doesn't* give the border,
 but an alpha channel of 1 produces an opaque polygon! :S

 I have read the FAQ, and (unfortunately) turning off line-art smoothing
 does not give the desired effect. Furthermore, my pdfs print with a
 white border surrounding each transparent polygon.

 Now, here comes the really bizarre part. Whilst Adobe Acrobat displays
 the unwanted white border, Apple Preview respects the "border=NA"
 argument and shows the two diamonds as they are intended. However,
 opening up the pdf in Illustrator CS reveals that there is in fact a
 transparent (according to Illustrator) border *on top* of each diamond.
 Deleting these two borders (one for each polygon) and re-saving the pdf
 appears to correct the issue. So the obvious question is: how did the
 surrounding borders get there in the first place? A bug in the polygon
 function, perhaps?

 Does anyone have any ideas for preventing these unwanted borders around
 semi-transparent polygons (without having to resort to Illustrator)? Has
 anyone else even come across this problem?

 Many thanks,


 -Matt

>>>
>>> --
>>> Brian D. Ripley,  [EMAIL PROTECTED]
>>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>>> University of Oxford, T

Re: [R] proportional sampling

2007-04-27 Thread jim holtman
sample(df$ID, numOfTime, replace=TRUE, prob=df$Factor)

On 4/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I wonder if you could help me.
>
> I have a table with a series of sites that I would like to sample from.
> The table has 5 columns:
>
> ID
> X Coordinate
> Y Coordinate
> Value
> Factor
>
>
> The conditions are that each site can be selected more than once and the
> probability of it being selected (or sampled) is proportional to a factor
> located in column 'Factor'
>
> I am novice in terms of R, and am not entirely sure how to do the
> proportional sampling.
>
> Any help would be appreciated
> Thanks
> Tibi
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@stat.math.ethz.ch 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] Randomising matrices

2007-04-27 Thread Stéphane Dray
Your solution is not suitable for quite large matrices.

There are several papers on the subject :

e.g. :
@ARTICLE{SD751,
  author = {Gotelli, N.J. and Entsminger, G.L.},
  title = {Swap and fill algorithms in null model analysis:rethinking 
the knight's
tour},
  journal = {Oecologia},
  year = {2001},
  volume = {129},
  pages = {281-291},
  endnotereftype = {Journal Article},
  keywords = {null model},
  pdf = {/home/stephane/Biblio/Articles/SD751.pdf},
  shorttitle = {Swap and fill algorithms in null model 
analysis:rethinking the knight's
tour}
}

There are different algorithms to solve the question but I am really not 
sure that they are implemented in R.

Sincerely,


Finny Kuruvilla wrote:
> Hi Nick,
>
> This way isn't the most elegant but works well, especially if the
> matrices aren't too large:
>
> # This function works on 2x2 arrays, randomizing them, but
> # preserving row and column totals
> shuffle_matrix <- function(x) {
>nrow = dim(x)[1]
>ncol = dim(x)[2]
>rmargins <- apply(x,1,sum)
>cmargins <- apply(x,2,sum)
>
>while(1) {
>  shuffled <- array(sample(x,length(x),replace=TRUE),dim=c(nrow,ncol))
>  if(all(apply(shuffled,1,sum) == rmargins)) {
>if(all(apply(shuffled,2,sum) == cmargins)) {
>  break
>}
>  }
>}
>shuffled
> }
>
> Example:
>
>   
>> a=array(sample(c(0,1),10,replace=TRUE),dim=c(5,2))
>> a
>> 
>   [,1] [,2]
> [1,]01
> [2,]11
> [3,]01
> [4,]01
> [5,]10
>   
>> shuffle_matrix(a)
>> 
>   [,1] [,2]
> [1,]01
> [2,]11
> [3,]10
> [4,]01
> [5,]01
>
> Best,
> Finny Kuruvilla
>
> *
> Finny Kuruvilla, MD, PhD
> Harvard Medical School Fellowship Program in Transfusion Medicine
> Broad Institute of MIT and Harvard
> Homepage: http://www.people.fas.harvard.edu/~kuruvill/home/
>
>
> On Fri, 27 Apr 2007, Nick Cutler wrote:
>
>   
>> I would like to be able to randomise presence-absence (i.e. binary)
>> matrices whilst keeping both the row and column totals constant. Is
>> there a function in R that would allow me to do this?
>>
>> I'm working with vegetation presence-absence matrices based on field
>> observations. The matrices are formatted to have sites as rows and
>> species as columns. The presence of a species on a site is indicated
>> with a 1 (absence is obviously indicated with a 0).
>>
>> I would like to randomise the matrices many times in order to construct
>> null models. However, I cannot identify a function in R to do this, and
>> the programming looks tricky for someone of my limited skills.
>>
>> Can anybody help me out?
>>
>> Many thanks,
>>
>> Nick Cutler
>>
>> Institute of Geography
>> School of Geosciences
>> University of Edinburgh
>> Drummond Street
>> Edinburgh EH8 9XP
>> United Kingdom
>>
>> Tel: 0131 650 2532
>> Web: http://www.geos.ed.ac.uk/homes/s0455078
>>
>> __
>> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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.
>
>
>   


-- 
Stéphane DRAY ([EMAIL PROTECTED] )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/

__
R-help@stat.math.ethz.ch 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] proportional sampling

2007-04-27 Thread tibi . codilean
Dear All,

I wonder if you could help me.

I have a table with a series of sites that I would like to sample from.
The table has 5 columns:

ID
X Coordinate
Y Coordinate
Value
Factor


The conditions are that each site can be selected more than once and the
probability of it being selected (or sampled) is proportional to a factor
located in column 'Factor'

I am novice in terms of R, and am not entirely sure how to do the
proportional sampling.

Any help would be appreciated
Thanks
Tibi

__
R-help@stat.math.ethz.ch 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] how to be clever with princomp?

2007-04-27 Thread Simon Pickett
Hi all,

I have been using princomp() recently, its very useful indeed, but I have
a question about how to specify the rows of data you want it to choose.

I have a set of variables relating to bird characteristics and I have been
using princomp to produce PC scores from these.

However since I have multiple duplicate entries per individual (each bird
had a varying number of chicks), I only want princomp to treat each
individual bird as the sample and not include all the duplicates. Then I
want to replicate the pc scores for all the duplicated rows for that
individual.

Any idea how to do this?

Up to now I have been using princomp to only select the entries which are
not duplicated which is easy, but the difficult bit is the programming to
duplicate the pc scores across the entries for each individual.

(I developed something that worked but it takes about 5 minutes to run!)

Thanks for all your help,

very much appreciated,

Simon.




Simon Pickett
PhD student
Centre For Ecology and Conservation
Tremough Campus
University of Exeter in Cornwall
TR109EZ
Tel 01326371852

__
R-help@stat.math.ethz.ch 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] Jarque-Bera and rnorm()

2007-04-27 Thread Martin Becker
Murali Menon schrieb:
> Folks,
>
> I'm a bit puzzled by the fact that if I generate 100,000 standard 
> normal variates using rnorm() and perform the Jarque-Bera on the 
> resulting vector, I get p-values that vary drastically from run to 
> run. Is this expected? 
Yes.
> Surely the p-val should be close to 1 for each test?
No. The p-value should rather be uniformly distributed on [0;1]. You can try

library(lawstat)
ttt<-numeric(1000)
for (i in 1:length(ttt)) ttt[i]<-rjb.test(rnorm(1))$p.value
hist(ttt)

to confirm that the combination of rnorm and rjb.test seems to behave 
correctly here.

Regards,

  Martin

>
> Are 100,000 variates sufficient for this test?
>

[...]

> Please advise. Thanks,
>
> Murali
>
> _
> MSN is giving away a trip to Vegas to see Elton John.  Enter to win 
> today.
>
> 
>
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Randomising matrices

2007-04-27 Thread Finny Kuruvilla
Hi Nick,

This way isn't the most elegant but works well, especially if the
matrices aren't too large:

# This function works on 2x2 arrays, randomizing them, but
# preserving row and column totals
shuffle_matrix <- function(x) {
   nrow = dim(x)[1]
   ncol = dim(x)[2]
   rmargins <- apply(x,1,sum)
   cmargins <- apply(x,2,sum)

   while(1) {
 shuffled <- array(sample(x,length(x),replace=TRUE),dim=c(nrow,ncol))
 if(all(apply(shuffled,1,sum) == rmargins)) {
   if(all(apply(shuffled,2,sum) == cmargins)) {
 break
   }
 }
   }
   shuffled
}

Example:

> a=array(sample(c(0,1),10,replace=TRUE),dim=c(5,2))
> a
  [,1] [,2]
[1,]01
[2,]11
[3,]01
[4,]01
[5,]10
> shuffle_matrix(a)
  [,1] [,2]
[1,]01
[2,]11
[3,]10
[4,]01
[5,]01

Best,
Finny Kuruvilla

*
Finny Kuruvilla, MD, PhD
Harvard Medical School Fellowship Program in Transfusion Medicine
Broad Institute of MIT and Harvard
Homepage: http://www.people.fas.harvard.edu/~kuruvill/home/


On Fri, 27 Apr 2007, Nick Cutler wrote:

> I would like to be able to randomise presence-absence (i.e. binary)
> matrices whilst keeping both the row and column totals constant. Is
> there a function in R that would allow me to do this?
>
> I'm working with vegetation presence-absence matrices based on field
> observations. The matrices are formatted to have sites as rows and
> species as columns. The presence of a species on a site is indicated
> with a 1 (absence is obviously indicated with a 0).
>
> I would like to randomise the matrices many times in order to construct
> null models. However, I cannot identify a function in R to do this, and
> the programming looks tricky for someone of my limited skills.
>
> Can anybody help me out?
>
> Many thanks,
>
> Nick Cutler
>
> Institute of Geography
> School of Geosciences
> University of Edinburgh
> Drummond Street
> Edinburgh EH8 9XP
> United Kingdom
>
> Tel: 0131 650 2532
> Web: http://www.geos.ed.ac.uk/homes/s0455078
>
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Unwanted white borders on semi-transparent polygons?

2007-04-27 Thread Prof Brian Ripley
The posting guide says

   For questions about unexpected behavior or a possible bug, you should,
   at a minimum, copy and paste the output from sessionInfo() into your message.

   If you are using an old version of R and think it does not work
   properly, upgrade to the latest version and try that, before posting.

[There is a known bug in 2.4.0 related to semi-transparency, fixed in 
2.4.0.  I would not have attempted to answer a question about 2.1.1, and 
we do rely on people seeking free technical assistance doing their bit.]


On Fri, 27 Apr 2007, Matthew Neilson wrote:

> Thanks for your fast response.
>
> I'm using R version 2.1.1 on OS X 10.3.9 to create the pdfs. I have tried 
> viewing the pdf output in both Acrobat 6 and 7 (both display a white border 
> around each polygon) as well as
> Preview (displays fine). I have emailed the pdf file to some correspondents 
> running Windows, and they also see white borders when viewing with Acrobat 
> (version unspecified).
>
> I have tried using R version 2.4.0 on a G5 machine (which I can access 
> remotely) running OS X 10.4.8, but the resulting pdf renders incorrectly 
> (i.e. with a white border around each
> polygon) in both Acrobat *and* Preview. So it would appear that the 
> combination of R 2.1.1 and OS X 10.3.9 gives slightly better results - 
> although plots still appear incorrect when
> printed or viewed in Acrobat.
>
> Unfortunately, I don't have access to a Windows machine to test this out. 
> Even if I did, many of my scripts include various Unix system calls so I 
> don't think that would be a viable
> solution. Could this be a bug in the OS X pdf driver?

The R pdf() device is the same on all platforms.

> Many thanks,
>
>
> -Matt
>
>
>
> On 27 Apr 2007, at 06:42, Prof Brian Ripley wrote:
>
>> What version of R, what OS, what version of Acrobat?
>>
>> I don't see this in 2.5.0 on Windows (using Acrobat 7: Acrobat does not
>> exist on Linux, AFAIK).  And reading the PDF produced shows no sign of an
>> extra object for the border.
>>
>> On Fri, 27 Apr 2007, Matthew Neilson wrote:
>>
>>> Hey all,
>>>
>>> I'm trying to create a plot of two semi-transparent regions. The reason 
>>> they need to be partially transparent is so that I can see if there's any 
>>> overlap. Here's some example code:
>>>
>>> # BEGIN
>>>
>>> pdf(file="test.pdf",version="1.4")
>>> plot(0,0,type="l",ylim=range(-3,3),xlim=range(-1,5))
>>> polygon(c(0,1,2,3,4,3,2,1,0), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(1,0,0,0.5),
>>> border=NA)
>>> polygon(c(1,2,3,4,5,4,3,2,1), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(0,0,1,0.5),
>>> border=NA)
>>> dev.off()
>>>
>>> # END
>>>
>>> The problem with this is that, despite setting "border = NA", I get a
>>> big white border surrounding each polygon!! Funnily enough, setting the
>>> alpha channel equal to 1 (as opposed to 0.5) *doesn't* give the border,
>>> but an alpha channel of 1 produces an opaque polygon! :S
>>>
>>> I have read the FAQ, and (unfortunately) turning off line-art smoothing
>>> does not give the desired effect. Furthermore, my pdfs print with a
>>> white border surrounding each transparent polygon.
>>>
>>> Now, here comes the really bizarre part. Whilst Adobe Acrobat displays
>>> the unwanted white border, Apple Preview respects the "border=NA"
>>> argument and shows the two diamonds as they are intended. However,
>>> opening up the pdf in Illustrator CS reveals that there is in fact a
>>> transparent (according to Illustrator) border *on top* of each diamond.
>>> Deleting these two borders (one for each polygon) and re-saving the pdf
>>> appears to correct the issue. So the obvious question is: how did the
>>> surrounding borders get there in the first place? A bug in the polygon
>>> function, perhaps?
>>>
>>> Does anyone have any ideas for preventing these unwanted borders around
>>> semi-transparent polygons (without having to resort to Illustrator)? Has
>>> anyone else even come across this problem?
>>>
>>> Many thanks,
>>>
>>>
>>> -Matt
>>>
>>
>> --
>> Brian D. Ripley,  [EMAIL PROTECTED]
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford, Tel:  +44 1865 272861 (self)
>> 1 South Parks Road, +44 1865 272866 (PA)
>> Oxford OX1 3TG, UKFax:  +44 1865 272595
>
> __
> R-help@stat.math.ethz.ch 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.
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch mailing lis

Re: [R] Unwanted white borders on semi-transparent polygons?

2007-04-27 Thread Matthew Neilson
Hi Roger,

Yes, that's the FAQ to which I was referring in my original email. 
Unfortunately, turning off smoothing for line art (as suggested in the FAQ) did 
not work for me.

Many thanks,


-Matt



On Fri Apr 27 12:32 , Roger Bivand <[EMAIL PROTECTED]> sent:

>Matt:
>
>Is this by any chance a version of FAQ 7.36, which turned out to be the 
>smooth line art flag in Adobe Reader?
>
>Roger
>
>
>
>On Fri, 27 Apr 2007, Matthew Neilson wrote:
>
>> Thanks for your fast response.
>> 
>> I'm using R version 2.1.1 on OS X 10.3.9 to create the pdfs. I have tried 
>> viewing the pdf output in both Acrobat 6 and 7 (both display a white border 
>> around each polygon) as well 
as 
>> Preview (displays fine). I have emailed the pdf file to some correspondents 
>> running Windows, and they also see white borders when viewing with Acrobat 
>> (version unspecified).
>> 
>> I have tried using R version 2.4.0 on a G5 machine (which I can access 
>> remotely) running OS X 10.4.8, but the resulting pdf renders incorrectly 
>> (i.e. with a white border around 
each 
>> polygon) in both Acrobat *and* Preview. So it would appear that the 
>> combination of R 2.1.1 and OS X 10.3.9 gives slightly better results - 
>> although plots still appear incorrect 
when 
>> printed or viewed in Acrobat.
>> 
>> Unfortunately, I don't have access to a Windows machine to test this out. 
>> Even if I did, many of my scripts include various Unix system calls so I 
>> don't think that would be a viable 
>> solution. Could this be a bug in the OS X pdf driver?
>> 
>> Many thanks,
>> 
>> 
>> -Matt
>> 
>> 
>> 
>> On 27 Apr 2007, at 06:42, Prof Brian Ripley wrote:
>> 
>> >What version of R, what OS, what version of Acrobat?
>> >
>> >I don't see this in 2.5.0 on Windows (using Acrobat 7: Acrobat does not 
>> >exist on Linux, AFAIK).  And reading the PDF produced shows no sign of an 
>> >extra object for the border.
>> >
>> >On Fri, 27 Apr 2007, Matthew Neilson wrote:
>> >
>> >> Hey all,
>> >>
>> >> I'm trying to create a plot of two semi-transparent regions. The reason 
>> >> they need to be partially transparent is so that I can see if there's any 
>> >> overlap. Here's some example 
code:
>> >>
>> >> # BEGIN
>> >>
>> >> pdf(file="test.pdf",version="1.4")
>> >> plot(0,0,type="l",ylim=range(-3,3),xlim=range(-1,5))
>> >> polygon(c(0,1,2,3,4,3,2,1,0), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(1,0,0,0.5),
>> >> border=NA)
>> >> polygon(c(1,2,3,4,5,4,3,2,1), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(0,0,1,0.5),
>> >> border=NA)
>> >> dev.off()
>> >>
>> >> # END
>> >>
>> >> The problem with this is that, despite setting "border = NA", I get a 
>> >> big white border surrounding each polygon!! Funnily enough, setting the 
>> >> alpha channel equal to 1 (as opposed to 0.5) *doesn't* give the border, 
>> >> but an alpha channel of 1 produces an opaque polygon! :S
>> >>
>> >> I have read the FAQ, and (unfortunately) turning off line-art smoothing 
>> >> does not give the desired effect. Furthermore, my pdfs print with a 
>> >> white border surrounding each transparent polygon.
>> >>
>> >> Now, here comes the really bizarre part. Whilst Adobe Acrobat displays 
>> >> the unwanted white border, Apple Preview respects the "border=NA" 
>> >> argument and shows the two diamonds as they are intended. However, 
>> >> opening up the pdf in Illustrator CS reveals that there is in fact a 
>> >> transparent (according to Illustrator) border *on top* of each diamond. 
>> >> Deleting these two borders (one for each polygon) and re-saving the pdf 
>> >> appears to correct the issue. So the obvious question is: how did the 
>> >> surrounding borders get there in the first place? A bug in the polygon 
>> >> function, perhaps?
>> >>
>> >> Does anyone have any ideas for preventing these unwanted borders around 
>> >> semi-transparent polygons (without having to resort to Illustrator)? Has 
>> >> anyone else even come across this problem?
>> >>
>> >> Many thanks,
>> >>
>> >>
>> >> -Matt
>> >>
>> >
>> >-- 
>> >Brian D. Ripley,  [EMAIL PROTECTED]
>> >Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> >University of Oxford, Tel:  +44 1865 272861 (self)
>> >1 South Parks Road, +44 1865 272866 (PA)
>> >Oxford OX1 3TG, UKFax:  +44 1865 272595
>> 
>> __
>> R-help@stat.math.ethz.ch 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.
>> 
>
>-- 
>Roger Bivand
>Economic Geography Section, Department of Economics, Norwegian School of
>Economics and Business Administration, Helleveien 30, N-5045 Bergen,
>Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
>e-mail: [EMAIL PROTECTED]
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do re

Re: [R] Inflate/Expand/Resize an array

2007-04-27 Thread Robin Hankin
[replying to myself]

it might be better to use

sweep(f,(1:6)[-2],m,"+")

instead.




On 27 Apr 2007, at 11:56, Robin Hankin wrote:

> Hi
>
>
>   f.dims <- c(10,25,1,1,1,14)
>   m.dims <- c(10, 1,1,1,1,14)
>   f <- array(1:prod(f.dims),f.dims)
>   m <- array(1:prod(m.dims),m.dims)
>   jj <- do.call(abind,c(rep(list(m),25),along=2))
>
>
> Then
>
> f + jj
>
> will give you what you want.
>
>
> The more general problem is a bit harder, as you say
>
>
> HTH
>
> rksh
>
>
> On 27 Apr 2007, at 10:41, Mark Payne wrote:
>
>> Gudday,
>>
>> I've had a good look everywhere trying to figure out how to do
>> this, but
>> I'm afraid I can seem to find an answer anywhere - maybe its
>> because I'm
>> not using the right terms, or maybe its because I'm a dummy. But
>> unfortunately, I am not completely and utterly stuck. Here's the
>> problem:
>>
>> I have two large, six dimensional arrays that I would like to add
>> together. Lets call them f and m. Their dimensions are respectively:
>>
>>> dim(f)
>> [1] 10  25  1  1  1 14
>>> dim(m)
>> [1] 10 1 1 1 1 14
>>
>> You can see that they're pretty close in size, but not identical.
>> What I
>> would like to do is expand or inflate m along its second dimension so
>> that it ends up with dimension 10 25 1 1 1 14, so that I can then add
>> the two together - the new values created along that second dimension
>> would simply be copies of the first value..
>>
>> What's the fastest way to do this? Is there a dedicated function?
>> Ideally I envisage something that you feed the input array, and the
>> desired dimensions, and it does the rest for you. Please also bear in
>> mind that this is a specific problem - the more general case is
>> where I
>> don't know which dimensions are "out of shape", so to speak...
>>
>> I hope that's clear, and that someone can me out here...
>>
>> Cheers,
>>
>> Mark
>>
>> __
>> R-help@stat.math.ethz.ch 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.
>
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>   tel  023-8059-7743
>
> __
> R-help@stat.math.ethz.ch 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.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@stat.math.ethz.ch 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 arrows to barchart with groups

2007-04-27 Thread GOUACHE David
Hello Rhelpers,

I am trying to represent the following data (hereafter named donnees) in a 
barchart with a grouping variable :


sitetraitement  dates   res
1   NT  17/10/2005  normal  76.2
1   T   17/10/2005  normal  103.2
1   NT  23/11/2005  tardif  81.6
1   T   23/11/2005  tardif  98
2   NT  15/10/2005  normal  72.71
2   T   15/10/2005  normal  94.47
2   NT  15/11/2005  tardif  79.65
2   T   15/11/2005  tardif  94.7

barchart(res~s|site,groups=traitement,data=donnees)

What I'd like to do is for each site represent with an arrow the difference in 
value of variable res between normal and tardif values of variable s.
I've found one way of doing it:


trellis.focus("panel",1,1)
xx<-trellis.panelArgs()$x
yy<-trellis.panelArgs()$y
panel.arrows(as.numeric(xx)[c(1,3)]-0.1,yy[c(1,3)],as.numeric(xx)[c(1,3)]-0.1,yy[c(2,4)],lwd=2,code=3)
panel.text(as.numeric(xx)[c(1,3)]-0.35,c(87,87),paste(yy[c(2,4)]-yy[c(1,3)],"\nq/ha"),font=2)
trellis.focus("panel",2,1)
xx<-trellis.panelArgs()$x
yy<-trellis.panelArgs()$y
panel.arrows(as.numeric(xx)[c(1,3)]-0.1,yy[c(1,3)],as.numeric(xx)[c(1,3)]-0.1,yy[c(2,4)],lwd=2,code=3)
panel.text(as.numeric(xx)[c(1,3)]-0.35,c(87,87),paste(yy[c(2,4)]-yy[c(1,3)],"\nq/ha"),font=2)
trellis.unfocus()

But I would prefer doing this within a custom panel function so I can apply it 
more generally, and I haven't been able to figure out how...
Could anyone give me a hand?
Thanks in advance.

David Gouache
Arvalis - Institut du Végétal

__
R-help@stat.math.ethz.ch 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] Issues with Sweave and inclusion of graphics from nlme

2007-04-27 Thread Duncan Murdoch
On 4/27/2007 5:39 AM, [EMAIL PROTECTED] wrote:
> Dear all,
> I'm using the nlme package. I would like to introduce the plot of my
> groupedData object in my latex report using Sweave but it doesn't work. 
> I have no error message in R (Sweave(my.file_Rnw)) and the plot is
> generated in R, but when I want to see the pdf (I'm using TexnicCenter) of
> my report, there is an error message and no pdf file is generated. It seems
> that the plot generated by plot.nmGroupedData is not found by TexnicCenter.
> Does anyone have an idea on how to solve this problem?

If the dot in the filename is real, I'd guess that's your problem. To 
confirm, take a look at the .tex file produced by Sweave.  Find the line 
corresponding to this figure.  It will be an \includegraphics call, 
something like

\includegraphics{my.file_Rnw-fig}

Your TeX is probably interpreting this as the file my.file_Rnw-fig 
rather than automatically adding the .pdf file extension, because it 
thinks you've specified the extension to be file_Rnw-fig.

Duncan Murdoch

__
R-help@stat.math.ethz.ch 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] Unwanted white borders on semi-transparent polygons?

2007-04-27 Thread Matthew Neilson
Thanks for your fast response.

I'm using R version 2.1.1 on OS X 10.3.9 to create the pdfs. I have tried 
viewing the pdf output in both Acrobat 6 and 7 (both display a white border 
around each polygon) as well as 
Preview (displays fine). I have emailed the pdf file to some correspondents 
running Windows, and they also see white borders when viewing with Acrobat 
(version unspecified).

I have tried using R version 2.4.0 on a G5 machine (which I can access 
remotely) running OS X 10.4.8, but the resulting pdf renders incorrectly (i.e. 
with a white border around each 
polygon) in both Acrobat *and* Preview. So it would appear that the combination 
of R 2.1.1 and OS X 10.3.9 gives slightly better results - although plots still 
appear incorrect when 
printed or viewed in Acrobat.

Unfortunately, I don't have access to a Windows machine to test this out. Even 
if I did, many of my scripts include various Unix system calls so I don't think 
that would be a viable 
solution. Could this be a bug in the OS X pdf driver?

Many thanks,


-Matt



On 27 Apr 2007, at 06:42, Prof Brian Ripley wrote:

>What version of R, what OS, what version of Acrobat?
>
>I don't see this in 2.5.0 on Windows (using Acrobat 7: Acrobat does not 
>exist on Linux, AFAIK).  And reading the PDF produced shows no sign of an 
>extra object for the border.
>
>On Fri, 27 Apr 2007, Matthew Neilson wrote:
>
>> Hey all,
>>
>> I'm trying to create a plot of two semi-transparent regions. The reason they 
>> need to be partially transparent is so that I can see if there's any 
>> overlap. Here's some example code:
>>
>> # BEGIN
>>
>> pdf(file="test.pdf",version="1.4")
>> plot(0,0,type="l",ylim=range(-3,3),xlim=range(-1,5))
>> polygon(c(0,1,2,3,4,3,2,1,0), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(1,0,0,0.5),
>> border=NA)
>> polygon(c(1,2,3,4,5,4,3,2,1), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(0,0,1,0.5),
>> border=NA)
>> dev.off()
>>
>> # END
>>
>> The problem with this is that, despite setting "border = NA", I get a 
>> big white border surrounding each polygon!! Funnily enough, setting the 
>> alpha channel equal to 1 (as opposed to 0.5) *doesn't* give the border, 
>> but an alpha channel of 1 produces an opaque polygon! :S
>>
>> I have read the FAQ, and (unfortunately) turning off line-art smoothing 
>> does not give the desired effect. Furthermore, my pdfs print with a 
>> white border surrounding each transparent polygon.
>>
>> Now, here comes the really bizarre part. Whilst Adobe Acrobat displays 
>> the unwanted white border, Apple Preview respects the "border=NA" 
>> argument and shows the two diamonds as they are intended. However, 
>> opening up the pdf in Illustrator CS reveals that there is in fact a 
>> transparent (according to Illustrator) border *on top* of each diamond. 
>> Deleting these two borders (one for each polygon) and re-saving the pdf 
>> appears to correct the issue. So the obvious question is: how did the 
>> surrounding borders get there in the first place? A bug in the polygon 
>> function, perhaps?
>>
>> Does anyone have any ideas for preventing these unwanted borders around 
>> semi-transparent polygons (without having to resort to Illustrator)? Has 
>> anyone else even come across this problem?
>>
>> Many thanks,
>>
>>
>> -Matt
>>
>
>-- 
>Brian D. Ripley,  [EMAIL PROTECTED]
>Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>University of Oxford, Tel:  +44 1865 272861 (self)
>1 South Parks Road, +44 1865 272866 (PA)
>Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch 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] Inflate/Expand/Resize an array

2007-04-27 Thread Robin Hankin
Hi


  f.dims <- c(10,25,1,1,1,14)
  m.dims <- c(10, 1,1,1,1,14)
  f <- array(1:prod(f.dims),f.dims)
  m <- array(1:prod(m.dims),m.dims)
  jj <- do.call(abind,c(rep(list(m),25),along=2))


Then

f + jj

will give you what you want.


The more general problem is a bit harder, as you say


HTH

rksh


On 27 Apr 2007, at 10:41, Mark Payne wrote:

> Gudday,
>
> I've had a good look everywhere trying to figure out how to do  
> this, but
> I'm afraid I can seem to find an answer anywhere - maybe its  
> because I'm
> not using the right terms, or maybe its because I'm a dummy. But
> unfortunately, I am not completely and utterly stuck. Here's the
> problem:
>
> I have two large, six dimensional arrays that I would like to add
> together. Lets call them f and m. Their dimensions are respectively:
>
>> dim(f)
> [1] 10  25  1  1  1 14
>> dim(m)
> [1] 10 1 1 1 1 14
>
> You can see that they're pretty close in size, but not identical.  
> What I
> would like to do is expand or inflate m along its second dimension so
> that it ends up with dimension 10 25 1 1 1 14, so that I can then add
> the two together - the new values created along that second dimension
> would simply be copies of the first value..
>
> What's the fastest way to do this? Is there a dedicated function?
> Ideally I envisage something that you feed the input array, and the
> desired dimensions, and it does the rest for you. Please also bear in
> mind that this is a specific problem - the more general case is  
> where I
> don't know which dimensions are "out of shape", so to speak...
>
> I hope that's clear, and that someone can me out here...
>
> Cheers,
>
> Mark
>
> __
> R-help@stat.math.ethz.ch 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.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@stat.math.ethz.ch 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] Help with saptial analysis (cluster)

2007-04-27 Thread Roger Bivand
ONKELINX, Thierry  inbo.be> writes:

> 
> Dear Fransico,
> 
> The distance matrix would be 102000 x 102000. So it would contain 1040400 
values. If you need one bit for
> each value, this would requier 9,7 GB. So the distance matrix won't fit in 
the RAM of your computer.

Perhaps you could make progress by using a 2D kernel density - there are 
functions among others in the MASS and splancs packages, or by binning - 
Bioconductor's hexbin package comes to mind. Then you would be looking for 
areas of increased density on the grid (in points per unit area or equivalently 
counts per bin) rather than at the interpoint distances. The kernel2d() 
function in splancs handles a data set of your size with no problems.

Roger

(with apologies for pruning, gmane is very dictatorial)

> 
> Cheers,
> 
> Thierry
>

__
R-help@stat.math.ethz.ch 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] bootstrap

2007-04-27 Thread Marc Bernard
Dear All,
   
  I would like to use a nonparametric bootstrap to calculate the confidence 
intervals for the 5% and 95% quantiles using boot.ci. As you know, boot.ci 
requires the use of boot to generate bootstrap replicates for my statistic. 
However this last function  doesn't work in my case because I am missing 
something. Here is an example
   
  y <- rnorm(100)
  Quantile <- function(df)
{
quantile(df,  probs=c(0.05,0.95))
  }
  boot.out <- boot(y,Quantile, R=999, sim="ordinary")
   
  Error in statistic(data, original, ...) : unused argument(s) (c(1, 2, 3, 4, 
5, 6, 7, 8
   
  I think  that it's due to another parameter (stype) that I have not  included 
but I don't know what this paremeter represents. 
   
  Many thanks for any suggestion.
   
  Bernard
   

 
-

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] correlation tab

2007-04-27 Thread Ted Harding
On 27-Apr-07 09:38:55, elyakhlifi mustapha wrote:
> hello,
> I know how to use the function "cor" to do correlation frame
> but it remains a problem because  I wanna calculate correlation
> between vector with differents dimensions it is possible?
>  for exemple my data :
> 
>> V
> [[1]]
>  [1]  97 104 103  98  99  92  99  99  98  87  95 101  91 104
>   98  96  84  97  92 104  97
> [[2]]
>  [1] 102 100  82 106  85  97 101  99  90 101  97  93 100  99
>   92  90 102  94  99 104
> [[3]]
>  [1]  98  95 104  96 104  86 100  91  94  95  99 100  95  95
>  104  98  97  99  94 100  94
> 
> length(V[[1]]) =  length(V[[3]]) = 21 but length(V[[2]]) = 20

Correlation only makes sense in a context where each element of
one vector used in the correlation is associated with a single
corresponding element of the other vector (think in terms of
simulataneous observations of different variables on an item:
so for instance V1[1] would be the obversevation of variable V1
on item 1, V2[1] the observation of variable V2 on item 1, etc.;
so V1[i], V2[i] and V3[i] are the observations of variables
V1, V2, V3 on item i).

So now it is up to you to identify what the association is
between the elements of your V[[1]], V[[2]] and V[[3]].

It may be that your "short" vector V[[2]] is simply missing
an observation on one item. In which case, the simplest approach
is to omit the corresponding element from V[[1]] and V[[3]],
and calculate the correlation from the remainder, assuming of
course that their elements are indeed associated in the way
described above.

Hoping this helps,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 27-Apr-07   Time: 11:19:40
-- XFMail --

__
R-help@stat.math.ethz.ch 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] Inflate/Expand/Resize an array

2007-04-27 Thread Mark Payne
Gudday,

I've had a good look everywhere trying to figure out how to do this, but
I'm afraid I can seem to find an answer anywhere - maybe its because I'm
not using the right terms, or maybe its because I'm a dummy. But
unfortunately, I am not completely and utterly stuck. Here's the
problem:

I have two large, six dimensional arrays that I would like to add
together. Lets call them f and m. Their dimensions are respectively:

> dim(f)
[1] 10  25  1  1  1 14
> dim(m)
[1] 10 1 1 1 1 14

You can see that they're pretty close in size, but not identical. What I
would like to do is expand or inflate m along its second dimension so
that it ends up with dimension 10 25 1 1 1 14, so that I can then add
the two together - the new values created along that second dimension
would simply be copies of the first value..

What's the fastest way to do this? Is there a dedicated function?
Ideally I envisage something that you feed the input array, and the
desired dimensions, and it does the rest for you. Please also bear in
mind that this is a specific problem - the more general case is where I
don't know which dimensions are "out of shape", so to speak...

I hope that's clear, and that someone can me out here...

Cheers,

Mark

__
R-help@stat.math.ethz.ch 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] Issues with Sweave and inclusion of graphics from nlme

2007-04-27 Thread caroline.truntzer
Dear all,
I'm using the nlme package. I would like to introduce the plot of my
groupedData object in my latex report using Sweave but it doesn't work. 
I have no error message in R (Sweave(my.file_Rnw)) and the plot is
generated in R, but when I want to see the pdf (I'm using TexnicCenter) of
my report, there is an error message and no pdf file is generated. It seems
that the plot generated by plot.nmGroupedData is not found by TexnicCenter.
Does anyone have an idea on how to solve this problem?
Thank you,
Caroline

__
R-help@stat.math.ethz.ch 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] Can a hyperlink be placed, thorugh R programming, on a graph?

2007-04-27 Thread Jim Lemon
Aldi Kraja wrote:
> Hi,
> If I use 
> 
> x<-1:10
>  y<-rnorm(10,0,1)
> ### pdf(file="c:\\aldi\\test.pdf")
>  plot(x,y)
>  segments(x,y,x+2,y+2)
>  segments(x,y,x+0.5,y+0.5,col=3)
> ### dev.off()
> ### q()
> 
> Is there a way that I can imbed in the graph plot for each point defined 
> by x to x+0.5 and y to y+0.5 (and colored in green) a different hyperlink?
> 
> For example point one (together with the green tail) will have the 
> hyperlink: www.r-project.org; point 2 with the link www.google.com; 
> point 3 with the link www.yahoo.com etc.
> 
> So in general, can the graph be manupulated within R?
> 
Hi Aldi,
In HTML, the way to do this is usually known as an image map. Here is 
one way to accomplish this.

png("aldi.png")
plot(x,y)
segments(x,y,x+2,y+2)
segments(x,y,x+0.5,y+0.5,col=3)
dev.off()

After generating the image in a format that will display on an HTML 
page, create the page.


  
   HTML image map demo
  
  
   Click on one of the points to go to another URL
   
   
http://www.r-project.org";>
http://www.google.com";>
http://www.yahoo.com";>
   
  


Now if you point your browser at that HTML page, you should be able to 
click on the first three points and be transferred to the URLs in your 
example. Doing this in PDF should be pretty similar, but I don't know 
how to write PDF code.

However, if you look at the code in either the R2HTML package or the 
prettyR package, you can see how this could all be generated in R.

Jim

__
R-help@stat.math.ethz.ch 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] correlation tab

2007-04-27 Thread elyakhlifi mustapha
hello,
I know how to use the function "cor" to do correlation frame but it remains a 
problem because  I wanna calculate correlation between vector with differents 
dimensions it is possible?
 for exemple my data :

> V
[[1]]
 [1]  97 104 103  98  99  92  99  99  98  87  95 101  91 104  98  96  84  97  
92 104  97
[[2]]
 [1] 102 100  82 106  85  97 101  99  90 101  97  93 100  99  92  90 102  94  
99 104
[[3]]
 [1]  98  95 104  96 104  86 100  91  94  95  99 100  95  95 104  98  97  99  
94 100  94

length(V[[1]]) =  length(V[[3]]) = 21 but length(V[[2]]) = 20


  
___





[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Jarque-Bera and rnorm()

2007-04-27 Thread Andrew Robinson

On Fri, April 27, 2007 7:02 pm, Murali Menon wrote:
> Folks,
>
> I'm a bit puzzled by the fact that if I generate 100,000 standard normal
> variates using rnorm() and perform the Jarque-Bera on the resulting
> vector,
> I get p-values that vary drastically from run to run. Is this expected?
> Surely the p-val should be close to 1 for each test?

No.  Under the null hypothesis, the p-value is a uniformly-distributed
random variable, with range 0 to 1.

Cheers,

Andrew



> Are 100,000 variates sufficient for this test?
>
> Or is it that rnorm() is not a robust random number generator? I looked at
> the skewness and excess kurtosis, and the former seems to be unstable,
> which
> leads me to think that is why JB is failing.
>
> Here are my outputs from successive runs of rjb.test (the robust Jarque
> Bera
> from the lawstat package).
>
>
>>set.seed(100)
>
>>y <- rnorm(10);rjb.test(y);skewness(y)[1];kurtosis(y)[1]
>
> Robust Jarque Bera Test
>
> data:  y
> X-squared = 1.753, df = 2, p-value = 0.4162
>
> [1] -0.01025744
> [1] 0.0008213325
>
>>y <- rnorm(10);rjb.test(y);skewness(y)[1];kurtosis(y)[1]
>
> Robust Jarque Bera Test
>
> data:  y
> X-squared = 0.1359, df = 2, p-value = 0.9343
>
> [1] -0.001833042
> [1] -0.002603599
>
>>y <- rnorm(10);rjb.test(y);skewness(y)[1];kurtosis(y)[1]
>
> Robust Jarque Bera Test
>
> data:  y
> X-squared = 4.6438, df = 2, p-value = 0.09809
>
> [1] -0.01620776
> [1] -0.005762349
>
>
> Please advise. Thanks,
>
> Murali
>
> _
> MSN is giving away a trip to Vegas to see Elton John.  Enter to win today.
>
> __
> R-help@stat.math.ethz.ch 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.
>


Andrew Robinson
Senior Lecturer in Statistics   Tel: +61-3-8344-9763
Department of Mathematics and StatisticsFax: +61-3-8344 4599
University of Melbourne, VIC 3010 Australia
Email: [EMAIL PROTECTED]Website: http://www.ms.unimelb.edu.au

__
R-help@stat.math.ethz.ch 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] Jarque-Bera and rnorm()

2007-04-27 Thread Murali Menon

Folks,

I'm a bit puzzled by the fact that if I generate 100,000 standard normal 
variates using rnorm() and perform the Jarque-Bera on the resulting vector, 
I get p-values that vary drastically from run to run. Is this expected? 
Surely the p-val should be close to 1 for each test?


Are 100,000 variates sufficient for this test?

Or is it that rnorm() is not a robust random number generator? I looked at 
the skewness and excess kurtosis, and the former seems to be unstable, which 
leads me to think that is why JB is failing.


Here are my outputs from successive runs of rjb.test (the robust Jarque Bera 
from the lawstat package).




set.seed(100)



y <- rnorm(10);rjb.test(y);skewness(y)[1];kurtosis(y)[1]


   Robust Jarque Bera Test

data:  y
X-squared = 1.753, df = 2, p-value = 0.4162

[1] -0.01025744
[1] 0.0008213325


y <- rnorm(10);rjb.test(y);skewness(y)[1];kurtosis(y)[1]


   Robust Jarque Bera Test

data:  y
X-squared = 0.1359, df = 2, p-value = 0.9343

[1] -0.001833042
[1] -0.002603599


y <- rnorm(10);rjb.test(y);skewness(y)[1];kurtosis(y)[1]


   Robust Jarque Bera Test

data:  y
X-squared = 4.6438, df = 2, p-value = 0.09809

[1] -0.01620776
[1] -0.005762349


Please advise. Thanks,

Murali

_
MSN is giving away a trip to Vegas to see Elton John.  Enter to win today.

__
R-help@stat.math.ethz.ch 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.


  1   2   >