Re: [R] how to stop without error message?

2008-11-10 Thread Henrik Bengtsson
I've also been looking for solutions to similar problems, but I never
found a good solution.  However, I think that if it would be possible
to send an interrupt signal/condition by code (cf. user press Ctrl-C)
one could achieve plenty of things with and without tryCatch().  See
Thread 'New simpleExit() condition (Was: Re: Can example() code stop
the example without generating an error?)' on March 16, 2006:

  http://tolstoy.newcastle.edu.au/R/devel/06/03/4524.html

So, maybe someone else know how to signal an interrupt in a script?

/Henrik

On Mon, Nov 10, 2008 at 6:01 PM, John Fox <[EMAIL PROTECTED]> wrote:
> Dear Mark,
>
> I see what you mean. Clearly the problem is with try(), since if you
> eliminate that, the message disappears.
>
> On the other hand, if you use try( f.inner(), silent=TRUE), the message is
> also suppressed.
>
> Does that help?
>
> John
>
>
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: November-10-08 8:22 PM
>> To: [EMAIL PROTECTED]; R-help@r-project.org
>> Subject: RE: [R] how to stop without error message?
>>
>> Hi John
>>
>> Using 'on.exit' to reset the "show.error.messages" option should work, but
> it
>> doesn't quite... and I'm not sure why.
>>
>> It breaks down with, for want of a better phrase, "nested" calls to stop,
>> inside 'try' statements. For some reason, the inner 'stop' calls *do* lead
> to
>> messages, although the outermost one is suppressed.
>>
>> test> f.inner <- function() {
>> +   opt.inner <- options( show.error.messages=FALSE)
>> +   on.exit( options( opt.inner))
>> +   stop( 'leaving f.inner')
>> + }
>> test>
>> test> f.outer <- function() {
>> +   try( f.inner())
>> +   opt.outer <- options( show.error.messages=FALSE)
>> +   on.exit( options( opt.outer))
>> +   stop( 'leaving f.outer')
>> + }
>> test> f.outer()
>> Error in f.inner() : leaving f.inner
>> test>
>>
>> bye
>> Mark
>>
>>
>>
>>
>> --
>> Mark Bravington
>> CSIRO Mathematical & Information Sciences
>> Marine Laboratory
>> Castray Esplanade
>> Hobart 7001
>> TAS
>>
>> ph (+61) 3 6232 5118
>> fax (+61) 3 6232 5012
>> mob (+61) 438 315 623
>>
>> -Original Message-
>> From: John Fox [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, 11 November 2008 10:35 AM
>> To: Bravington, Mark (CMIS, Hobart); R-help@r-project.org
>> Subject: RE: [R] how to stop without error message?
>>
>> Dear Mark,
>>
>> How about something like this?
>>
>> > f <- function(x){
>> +   if (x < 0){
>> + opt <- options(show.error.messages=FALSE)
>> + on.exit(options(opt))
>> + stop()
>> + }
>> +   sqrt(x)
>> +   }
>> >
>> > f(2)
>> [1] 1.414214
>> > f(-2)
>> >
>>
>> I hope this helps,
>>  John
>>
>> --
>> John Fox, Professor
>> Department of Sociology
>> McMaster University
>> Hamilton, Ontario, Canada
>> web: socserv.mcmaster.ca/jfox
>>
>>
>> > -Original Message-
>> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> On
>> > Behalf Of [EMAIL PROTECTED]
>> > Sent: November-10-08 5:42 PM
>> > To: R-help@r-project.org
>> > Cc: [EMAIL PROTECTED]
>> > Subject: [R] how to stop without error message?
>> >
>> > Dear list
>> >
>> > Can anyone suggest a simple way to abort execution like stop(...) does,
>> but
>> > without issuing an "Error: ..." message?
>> >
>> > I don't want to set 'options( show.error.messages=TRUE)' because I want
>> > normal behaviour to resume after this particular stop.
>> >
>> > (Please reply personally as well as to the list, as I'm not subscribed
> to
>> R-
>> > help)
>> >
>> > Thanks
>> > Mark
>> >
>> > --
>> > Mark Bravington
>> > CSIRO Mathematical & Information Sciences
>> > Marine Laboratory
>> > Castray Esplanade
>> > Hobart 7001
>> > TAS
>> >
>> > ph (+61) 3 6232 5118
>> > fax (+61) 3 6232 5012
>> > mob (+61) 438 315 623
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] question about contrast in R for multi-factor linear regression models?

2008-11-10 Thread Mark Difford

Hi losemind,

>> What's wrong?

What's wrong is probably that you never read the help page for dummy.coef
properly. But that is a wild guess, since I have no idea what your yy is.
And one is strongly inclined to say, "Why, oh why?"

Your first posting on this subject has your linear model fit, which is the
object that the help page for dummy.coef says should be given to it, as zz:

> zz=lm(formula = (dd$Y) ~ dd$A * dd$B) 
> summary(zz)

It is also, by the way, a courtesy to address the list, since you are asking
its members for help. And perhaps also to thank them.

I do hope that helps,
Mark.


losemind wrote:
> 
>> Yes, it is possible to lose your mind on this (so perhaps get a real
>> name).
>> A good friend here is
>>
>> ?dummy.coef
> 
> 
> When I use it, it complained:
> 
>> dummy.coef(yy)
> Error in dd$A1 : $ operator is invalid for atomic vectors
> 
> What's wrong?
> 
>>
>> In your case (i.e. treatment contrasts), your reference level for the
>> interaction terms are the reference levels of the factors themselves. In
>> your example, these seem to be A1 and b1. Assuming they are, the
>> coefficient
>> for, say, dd$AA3:dd$Bb2 is worked out relative to them.
>>
> 
> dd$AA3:dd$Bb2 is relative to
> 
> dd$AA1 only, or
> dd$Bb1 only , or
> dd$AA1 + dd$Bb1, or
> dd$AA1 : dd$Bb1, or
> dd$AA1 * dd$Bb1
> 
> That's exactly where I was not sure about!
> 
>>> Call:
>>> lm(formula = dd$Y~ dd$A * dd$B)
>>>
>>> Residuals:
>>>  Min   1Q   Median   3Q  Max
>>> -1.68582 -0.42469 -0.02536  0.20012  3.50798
>>>
>>> Coefficients:
>>>   Estimate Std. Error t value Pr(>|t|)
>>> (Intercept)4.408420.40295  10.940 5.34e-13 ***
>>> dd$AA2 0.115750.56986   0.203   0.8402
>>> dd$AA3 0.013120.56986   0.023   0.9818
>>> dd$AA4-0.066750.56986  -0.117   0.9074
>>> dd$AA5 0.106350.56986   0.187   0.8530
>>> dd$AA6 0.115070.56986   0.202   0.8411
>>> dd$Bb2-0.588810.56986  -1.033   0.3084
>>> c  0.264650.80590   0.328   0.7445
>>> dd$AA3:dd$Bb2  0.409840.80590   0.509   0.6142
>>> dd$AA4:dd$Bb2 -0.029180.80590  -0.036   0.9713
>>> dd$AA5:dd$Bb2  0.355740.80590   0.441   0.6616
>>> dd$AA6:dd$Bb2  1.554240.80590   1.929   0.0617 .
>>> ---
>>> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>>>
>>> Residual standard error: 0.8059 on 36 degrees of freedom
>>> Multiple R-squared: 0.2642, Adjusted R-squared: 0.03934
>>> F-statistic: 1.175 on 11 and 36 DF,  p-value: 0.3378
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/question-about-contrast-in-R-for-multi-factor-linear-regression-models--tp20413510p20416877.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/question-about-contrast-in-R-for-multi-factor-linear-regression-models--tp20413510p20434736.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] thickness of boxplots

2008-11-10 Thread Deepayan Sarkar
On 11/10/08, Kenneth Roy Cabrera Torres <[EMAIL PROTECTED]> wrote:
> Hi R users:
>
>  How can I obtain with bwplot boxplots with bwplot whose box width
>  will vary acording to other variable.
>
>  bwplot(categ1~continuos|categ2,box.ratio=continuos2,data=data.base)
>
>  But it doesn't work as I expected.

I'm not really sure what you expected. The best I would have expected
is that 'box.ratio' in panel.bwplot is vectorized, and that seems to
be true; so you can do

bwplot(gl(4, 1, 100) ~ rnorm(100), box.ratio = 1:4)

or more directly

bwplot(gl(4, 1, 100) ~ rnorm(100), box.width = (4:1)/4)

If you want the widths to be controlled by another variable, you will
need to write your own panel function that calls panel.bwplot with a
suitable 'box.width' argument. I don't see any obvious rule, since the
number of individual box-and-whisker plots is smaller than the number
of observations.

-Deepayan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re : Regarding lme functions

2008-11-10 Thread Dieter Menne
ratna ghosal  yahoo.com> writes:

> But then how to interpret the rows and columns

When lost, use str:

library(nlme)
fm1Orth.lme = lme(distance ~ I(age-11), data = Orthodont,
 random = ~ I(age-11) | Subject)
ints = intervals(fm1Orth.lme)
str(ints)
# $ fixed   : num [1:2, 1:3] 23.168 0.518 24.023 0.66 24.878 ...
#  ..- attr(*, "dimnames")=List of 2
# Estimate of slope 
ints$fixed[2,2]


Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Manipulation in timeSeries object:how to use the function "applySeries" by daily?

2008-11-10 Thread tedzzx

Hi all 
I have some tick-by-tick data and I have calculated the intraday returns. I
want to sum up the intraday squared returns to calculate the daily
volatility(or daily variance). I know that the s-plus FinMerics has the
function aggregateSeries function that can be apply to daily data:
aggregateSeries(x, Fun, by="daily"), but the counterpart function in
R:applySeries can not be apply to daily data. This function has the argument
by=c("monthly", "quartly"). 
Can we find some way to mimic the aggregateSeries function in s-plus?

Thanks in advance

Ted
-- 
View this message in context: 
http://www.nabble.com/Manipulation-in-timeSeries-object%3Ahow-to-use-the-function-%22applySeries%22-by-daily--tp20432658p20432658.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread Mark.Bravington
> > Dear list
> >
> > Can anyone suggest a simple way to abort execution like stop(...) does, but 
> > without issuing an "Error: ..." message?
> >
> > I don't want to set 'options( show.error.messages=TRUE)' because I want 
> > normal behaviour to resume after this particular stop.
>
> What's wrong with return() ?
>
> Hadley

I should have been clearer, sorry-- I'm trying to exit from an "inner" function 
which might be several levels deep, returning straight to the R prompt. To be 
specific, I'm trying to clean up the "No Error in..." message in my 'debug' 
package-- the "No " prefix being my original workaround to avoid an 
unnecessarily alarming message.

bye
Mark


--
Mark Bravington
CSIRO Mathematical & Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R User Group mailing list

2008-11-10 Thread John C Nash
Here in Canada's capital we have set up the Ottawa-Gatineau R Users 
Group (OGRUG) and are wondering how we can get a special interest group 
(sig) mailing list established linked to the R-project site. We 
understand that there may be other RUGs out there, so maybe such a list 
should be something like R-rug-Ottawa, allowing for similar names for 
other lists around the world. This could help to advertise that there 
are users of R in different locations and bring folk into the community. 
We don't anticipate a lot of traffic, but want to allow people to add 
their names to receive announcements of meetings etc. We're looking at 
about four events a year, with some announcements of sister activities 
by local statistical or similar groups.


Essentially the query is "Who do I contact?" to set this up. We are, of 
course, happy to offer to administer such a RUG list, and hopefully help 
by being among the leading "rug-rats" with suggestions and documentation 
on ideas that have worked in getting our group going.


Cheers,

John Nash

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread Mark.Bravington
Hi John

Using 'on.exit' to reset the "show.error.messages" option should work, but it 
doesn't quite... and I'm not sure why.

It breaks down with, for want of a better phrase, "nested" calls to stop, 
inside 'try' statements. For some reason, the inner 'stop' calls *do* lead to 
messages, although the outermost one is suppressed.

test> f.inner <- function() {
+   opt.inner <- options( show.error.messages=FALSE)
+   on.exit( options( opt.inner))
+   stop( 'leaving f.inner')
+ }
test>
test> f.outer <- function() {
+   try( f.inner())
+   opt.outer <- options( show.error.messages=FALSE)
+   on.exit( options( opt.outer))
+   stop( 'leaving f.outer')
+ }
test> f.outer()
Error in f.inner() : leaving f.inner
test>

bye
Mark




--
Mark Bravington
CSIRO Mathematical & Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623

-Original Message-
From: John Fox [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 11 November 2008 10:35 AM
To: Bravington, Mark (CMIS, Hobart); R-help@r-project.org
Subject: RE: [R] how to stop without error message?

Dear Mark,

How about something like this?

> f <- function(x){
+   if (x < 0){
+ opt <- options(show.error.messages=FALSE)
+ on.exit(options(opt))
+ stop()
+ }
+   sqrt(x)
+   }
>
> f(2)
[1] 1.414214
> f(-2)
>

I hope this helps,
 John

--
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
> Behalf Of [EMAIL PROTECTED]
> Sent: November-10-08 5:42 PM
> To: R-help@r-project.org
> Cc: [EMAIL PROTECTED]
> Subject: [R] how to stop without error message?
>
> Dear list
>
> Can anyone suggest a simple way to abort execution like stop(...) does,
but
> without issuing an "Error: ..." message?
>
> I don't want to set 'options( show.error.messages=TRUE)' because I want
> normal behaviour to resume after this particular stop.
>
> (Please reply personally as well as to the list, as I'm not subscribed to
R-
> help)
>
> Thanks
> Mark
>
> --
> Mark Bravington
> CSIRO Mathematical & Information Sciences
> Marine Laboratory
> Castray Esplanade
> Hobart 7001
> TAS
>
> ph (+61) 3 6232 5118
> fax (+61) 3 6232 5012
> mob (+61) 438 315 623
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread Mark.Bravington
Thank you Hadley & John

Hadley's approach below is the kind of thing I was expecting-- I'd just never 
managed to figure out how to use tryCatch. John has also made me think that I 
could probably patch things up by modifying my calls to 'try'-- because 
sometimes I do want to print the error messages from the 'try's, it just 
depends on what they are. On balance, it's probably time for me to get to get 
to grips with 'tryCatch'.

Thanks again

mark




--
Mark Bravington
CSIRO Mathematical & Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623

-Original Message-
From: hadley wickham [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 11 November 2008 2:20 PM
To: Bravington, Mark (CMIS, Hobart)
Cc: R-help@r-project.org
Subject: Re: [R] how to stop without error message?

>
> I should have been clearer, sorry-- I'm trying to exit from an "inner" 
> function which might be several levels deep, returning straight to the R 
> prompt. To be specific, I'm trying to clean up the "No Error in..." message 
> in my 'debug' package-- the "No " prefix being my original workaround to 
> avoid an unnecessarily alarming message.

Ah, ok.  How about signalling custom condition then?

f <- function() {
  print("a")
  g()
  print("d")
}

g <- function() {
  print("b")
  error <- simpleError("")
  class(error) <- c("myerror", class(error))
  signalCondition(error)
  print("c")
}

f()
tryCatch(f(), myerror = function(...) print("stopped!"))

Hadley


--
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] thickness of boxplots

2008-11-10 Thread Kenneth Roy Cabrera Torres
Hi R users:

How can I obtain with bwplot boxplots with bwplot whose box width
will vary acording to other variable.

bwplot(categ1~continuos|categ2,box.ratio=continuos2,data=data.base)

But it doesn't work as I expected.

Thank you for your help.

Kenneth

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread Gabor Grothendieck
Not sure if this qualifies as simple but you can use callCC to force an
exit from within an inner call.  In this example we call f which calls f1
which calls f2 and then f2 exits right out to the top level returning 0.
Note that f2 must know about g:

f <- function(g) {
f1 <- function() {
cat("A\n")
f2()
cat("B\n")
}

f2 <- function() {
cat("a\n")
g(0)
cat("b\n")
}
f1()
}

callCC(f)


On Mon, Nov 10, 2008 at 5:42 PM,  <[EMAIL PROTECTED]> wrote:
> Dear list
>
> Can anyone suggest a simple way to abort execution like stop(...) does, but 
> without issuing an "Error: ..." message?
>
> I don't want to set 'options( show.error.messages=TRUE)' because I want 
> normal behaviour to resume after this particular stop.
>
> (Please reply personally as well as to the list, as I'm not subscribed to 
> R-help)
>
> Thanks
> Mark
>
> --
> Mark Bravington
> CSIRO Mathematical & Information Sciences
> Marine Laboratory
> Castray Esplanade
> Hobart 7001
> TAS
>
> ph (+61) 3 6232 5118
> fax (+61) 3 6232 5012
> mob (+61) 438 315 623
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Apology RE:interpreting output from predict.blackboost

2008-11-10 Thread Kirsten Barrett
I apologize for multiple postings of the question below.  My email
responded with error messages each time I attempted to post and the
postings did not appear in my sent messages. I was not aware (until
notified) that multiple copies had been sent.

Kirsten Barrett

On Mon, Nov 10, 2008 at 4:02 PM, Kirsten Barrett <[EMAIL PROTECTED]> wrote:
> I would like to use blackboost on a training data set, then use the
> output to predict a testing dataset, and finally evaluate the errors.
> An example of the code I have written is the following:
>
> train <- read.csv ("train.csv")
> test <- read.csv ("test.csv")
>
> boost <- blackboost (ogred ~ elev + slope + aspect, data = train)
> pred <- predict (boost, newdata = test)
>
> pred yields the following matrix:
>
>  [1] 2.697689 3.551352 2.761541 3.271642 2.313459 2.207247 1.591521 3.752257
>  [9] 2.976793 2.522219 1.988676 2.092666 3.550917 2.134925 2.534842 2.922136
> [17] 2.277653 2.922136 2.922136 4.593132 2.922136 3.773274 4.647789 3.773274
> [25] 4.647789 2.369810 2.645859 2.344808 1.760087 2.918108 2.714825 2.972284
> [33] 3.466973 2.001098 1.706958 1.749830 1.960923 1.960923 2.451370 2.835255
> [41] 2.443585 3.392883 3.164294 2.615430
>
> I would like to know how to use this output to classify data the
> testing dataset. Any advice is much appreciated.
>
> Thank you,
> Kirsten
>
> --
> Kirsten Barrett
> Mendenhall Postdoctoral Fellow, USGS
> Alaska Science Center
> 4210 University Drive
> Anchorage, AK
>
> phone (907) 786 7419
> fax (907) 786 7401
>
> [EMAIL PROTECTED]
>

-- 
Kirsten Barrett
Mendenhall Postdoctoral Fellow, USGS
Alaska Science Center
4210 University Drive
Anchorage, AK

phone (907) 786 7419
fax (907) 786 7401

[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread hadley wickham
>
> I should have been clearer, sorry-- I'm trying to exit from an "inner" 
> function which might be several levels deep, returning straight to the R 
> prompt. To be specific, I'm trying to clean up the "No Error in..." message 
> in my 'debug' package-- the "No " prefix being my original workaround to 
> avoid an unnecessarily alarming message.

Ah, ok.  How about signalling custom condition then?

f <- function() {
  print("a")
  g()
  print("d")
}

g <- function() {
  print("b")
  error <- simpleError("")
  class(error) <- c("myerror", class(error))
  signalCondition(error)
  print("c")
}

f()
tryCatch(f(), myerror = function(...) print("stopped!"))

Hadley


-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Preparing data for display

2008-11-10 Thread jim holtman
Have you tried 'do.call(rbind,)'?  You did not provide a subset of
data, so it is hard to create an example.

On Mon, Nov 10, 2008 at 4:28 PM, Stavros Macrakis <[EMAIL PROTECTED]> wrote:
> I have a dataset of about 10^6 rows, each consisting of a timestamp,
> several factors, a string, some integers, and some floats.
>
> I'd like to graph this data in various ways, including straightforward
> ones (how many events per week over the past year for each of 4 values
> of some factor), some less straightforward.  I've managed to do this
> by brute force, but I'd like to learn how to do it in more elegant,
> more R-like code.
>
> Consider for example the following, which graphs the 25th, 50th, and
> 75th percentile values per day of data$x
>
> perc <- function(code,data)
> { # select the part of the data with factor value
>  slice <- data[data$factor == code,];
>  # calc quartiles for each day
>  quarts <- tapply(slice$x,
> slice$day,
> function(x) quantile(x,c(.25,.50,.75)));
> # returns a tagged list of tagged vectors
> # list("2008-10-07" = c("25%" = .05, "50%" = .47,
> ... ) , ...)
># convert to a data frame -- is there some mapping function to do this?
>   fr <- data.frame( day = to.time(names(quarts)),   # strings
> back to dates (!)
>   "25%" = sapply(quarts, function(x)
> x[[1]] ),   # !!
>   "50%" = sapply(quarts, function(x) x[[2]] ),
>   "75%" = sapply(quarts, function(x) x[[3]] ) );
> # columns are now labelled "X25." etc. (!)
>for (i in 2:4) { plot( fr$day, res[[2]], type="l", ylim= c( 0,
> max(pmax(fr[[1]],fr[[2]],fr[[3]] )) ));
>  par(new=TRUE); }
>par(new=FALSE);
>}
>
> This works, but is pretty ugly in a variety of ways.  What is the
> right way to do this?
>
> Thanks,
>
>   -s
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread hadley wickham
On Mon, Nov 10, 2008 at 4:42 PM,  <[EMAIL PROTECTED]> wrote:
> Dear list
>
> Can anyone suggest a simple way to abort execution like stop(...) does, but 
> without issuing an "Error: ..." message?
>
> I don't want to set 'options( show.error.messages=TRUE)' because I want 
> normal behaviour to resume after this particular stop.

What's wrong with return() ?

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] question about contrast in R for multi-factor linear regression models?

2008-11-10 Thread Michael
> Yes, it is possible to lose your mind on this (so perhaps get a real name).
> A good friend here is
>
> ?dummy.coef


When I use it, it complained:

> dummy.coef(yy)
Error in dd$A1 : $ operator is invalid for atomic vectors

What's wrong?

>
> In your case (i.e. treatment contrasts), your reference level for the
> interaction terms are the reference levels of the factors themselves. In
> your example, these seem to be A1 and b1. Assuming they are, the coefficient
> for, say, dd$AA3:dd$Bb2 is worked out relative to them.
>

dd$AA3:dd$Bb2 is relative to

dd$AA1 only, or
dd$Bb1 only , or
dd$AA1 + dd$Bb1, or
dd$AA1 : dd$Bb1, or
dd$AA1 * dd$Bb1

That's exactly where I was not sure about!

>> Call:
>> lm(formula = dd$Y~ dd$A * dd$B)
>>
>> Residuals:
>>  Min   1Q   Median   3Q  Max
>> -1.68582 -0.42469 -0.02536  0.20012  3.50798
>>
>> Coefficients:
>>   Estimate Std. Error t value Pr(>|t|)
>> (Intercept)4.408420.40295  10.940 5.34e-13 ***
>> dd$AA2 0.115750.56986   0.203   0.8402
>> dd$AA3 0.013120.56986   0.023   0.9818
>> dd$AA4-0.066750.56986  -0.117   0.9074
>> dd$AA5 0.106350.56986   0.187   0.8530
>> dd$AA6 0.115070.56986   0.202   0.8411
>> dd$Bb2-0.588810.56986  -1.033   0.3084
>> c  0.264650.80590   0.328   0.7445
>> dd$AA3:dd$Bb2  0.409840.80590   0.509   0.6142
>> dd$AA4:dd$Bb2 -0.029180.80590  -0.036   0.9713
>> dd$AA5:dd$Bb2  0.355740.80590   0.441   0.6616
>> dd$AA6:dd$Bb2  1.554240.80590   1.929   0.0617 .
>> ---
>> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>>
>> Residual standard error: 0.8059 on 36 degrees of freedom
>> Multiple R-squared: 0.2642, Adjusted R-squared: 0.03934
>> F-statistic: 1.175 on 11 and 36 DF,  p-value: 0.3378
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/question-about-contrast-in-R-for-multi-factor-linear-regression-models--tp20413510p20416877.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread John Fox
Dear Mark,

I see what you mean. Clearly the problem is with try(), since if you
eliminate that, the message disappears.

On the other hand, if you use try( f.inner(), silent=TRUE), the message is
also suppressed.

Does that help?

John


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: November-10-08 8:22 PM
> To: [EMAIL PROTECTED]; R-help@r-project.org
> Subject: RE: [R] how to stop without error message?
> 
> Hi John
> 
> Using 'on.exit' to reset the "show.error.messages" option should work, but
it
> doesn't quite... and I'm not sure why.
> 
> It breaks down with, for want of a better phrase, "nested" calls to stop,
> inside 'try' statements. For some reason, the inner 'stop' calls *do* lead
to
> messages, although the outermost one is suppressed.
> 
> test> f.inner <- function() {
> +   opt.inner <- options( show.error.messages=FALSE)
> +   on.exit( options( opt.inner))
> +   stop( 'leaving f.inner')
> + }
> test>
> test> f.outer <- function() {
> +   try( f.inner())
> +   opt.outer <- options( show.error.messages=FALSE)
> +   on.exit( options( opt.outer))
> +   stop( 'leaving f.outer')
> + }
> test> f.outer()
> Error in f.inner() : leaving f.inner
> test>
> 
> bye
> Mark
> 
> 
> 
> 
> --
> Mark Bravington
> CSIRO Mathematical & Information Sciences
> Marine Laboratory
> Castray Esplanade
> Hobart 7001
> TAS
> 
> ph (+61) 3 6232 5118
> fax (+61) 3 6232 5012
> mob (+61) 438 315 623
> 
> -Original Message-
> From: John Fox [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 11 November 2008 10:35 AM
> To: Bravington, Mark (CMIS, Hobart); R-help@r-project.org
> Subject: RE: [R] how to stop without error message?
> 
> Dear Mark,
> 
> How about something like this?
> 
> > f <- function(x){
> +   if (x < 0){
> + opt <- options(show.error.messages=FALSE)
> + on.exit(options(opt))
> + stop()
> + }
> +   sqrt(x)
> +   }
> >
> > f(2)
> [1] 1.414214
> > f(-2)
> >
> 
> I hope this helps,
>  John
> 
> --
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> web: socserv.mcmaster.ca/jfox
> 
> 
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On
> > Behalf Of [EMAIL PROTECTED]
> > Sent: November-10-08 5:42 PM
> > To: R-help@r-project.org
> > Cc: [EMAIL PROTECTED]
> > Subject: [R] how to stop without error message?
> >
> > Dear list
> >
> > Can anyone suggest a simple way to abort execution like stop(...) does,
> but
> > without issuing an "Error: ..." message?
> >
> > I don't want to set 'options( show.error.messages=TRUE)' because I want
> > normal behaviour to resume after this particular stop.
> >
> > (Please reply personally as well as to the list, as I'm not subscribed
to
> R-
> > help)
> >
> > Thanks
> > Mark
> >
> > --
> > Mark Bravington
> > CSIRO Mathematical & Information Sciences
> > Marine Laboratory
> > Castray Esplanade
> > Hobart 7001
> > TAS
> >
> > ph (+61) 3 6232 5118
> > fax (+61) 3 6232 5012
> > mob (+61) 438 315 623
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] using newdata in survfit with categorical variable

2008-11-10 Thread Bill.Venables
This is a bit tricky, but you need to specify the full set of possible levels 
for the factor in newdata.  Try this

temp <- data.frame(gender = factor("Male", levels = levels(wlwsn1$gender)))
wlwsn1curve <- survfit(fit, newdata=temp)

(Warning: untested code.)

Bill Venables
http://www.cmis.csiro.au/bill.venables/


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zhixin Liu
Sent: Tuesday, 11 November 2008 10:58 AM
To: r-help@r-project.org
Subject: [R] using newdata in survfit with categorical variable

Hi R-helpers,

I was trying to put gender='Male'  in newdata to create a expected survival 
curve for a pseudo cohort by using survfit based on Cox regression. My codes 
are shown below:

fit<- coxph(Surv(end, status2)~gender, data=wlwsn1)
Summary(fit)
 coef exp(coef) se(coef)z p
genderMale 0.204  1.23   0.0912 2.23 0.025

temp<-data.frame(gender='Male)
wlwsn1curve<-survfit(fit, newdata=temp)
Then I got error message:
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
  contrasts can be applied only to factors with 2 or more levels

I do not know what this error message indicates, do I have to recode gender to 
0,1 to get it through?

Many thanks

Zhixin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] interpreting output from predict.blackboost

2008-11-10 Thread Kirsten Barrett
I would like to use blackboost on a training data set, then use the
output to predict a testing dataset, and finally evaluate the errors.
An example of the code I have written is the following:

train <- read.csv ("train.csv")
test <- read.csv ("test.csv")

boost <- blackboost (ogred ~ elev + slope + aspect, data = train)
pred <- predict (boost, newdata = test)

pred yields the following matrix:

 [1] 2.697689 3.551352 2.761541 3.271642 2.313459 2.207247 1.591521 3.752257
 [9] 2.976793 2.522219 1.988676 2.092666 3.550917 2.134925 2.534842 2.922136
[17] 2.277653 2.922136 2.922136 4.593132 2.922136 3.773274 4.647789 3.773274
[25] 4.647789 2.369810 2.645859 2.344808 1.760087 2.918108 2.714825 2.972284
[33] 3.466973 2.001098 1.706958 1.749830 1.960923 1.960923 2.451370 2.835255
[41] 2.443585 3.392883 3.164294 2.615430

I would like to know how to use this output to classify data the
testing dataset. Any advice is much appreciated.

Thank you,
Kirsten

-- 
Kirsten Barrett
Mendenhall Postdoctoral Fellow, USGS
Alaska Science Center
4210 University Drive
Anchorage, AK

phone (907) 786 7419
fax (907) 786 7401

[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] using newdata in survfit with categorical variable

2008-11-10 Thread Zhixin Liu
Hi R-helpers,

I was trying to put gender='Male'  in newdata to create a expected survival 
curve for a pseudo cohort by using survfit based on Cox regression. My codes 
are shown below: 

fit<- coxph(Surv(end, status2)~gender, data=wlwsn1)
Summary(fit) 
 coef exp(coef) se(coef)z p
genderMale 0.204  1.23   0.0912 2.23 0.025

temp<-data.frame(gender='Male)
wlwsn1curve<-survfit(fit, newdata=temp)
Then I got error message: 
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : 
  contrasts can be applied only to factors with 2 or more levels

I do not know what this error message indicates, do I have to recode gender to 
0,1 to get it through?

Many thanks

Zhixin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] comparing rows - a possible solution

2008-11-10 Thread markleeds
Hi Oliver: if I understood Chris's email correctly , he wanted to 
compare all possible row ( row1 with the other 4 rows of the other 
matrix,
row 2 with the 4 rows of the other matrix, etc, etc, ) combinations of 
the two matrices, not the individual elements of the matrix. That's just 
my interpretation ?
If he did want to compare elements, then I agree with your solution, 
as.vector(testmat1 == testmat2).




On Mon, Nov 10, 2008 at  5:15 PM, Oliver Bandel wrote:


Hello,

sorry for posting this independently of the original thread, but it is
not that easy to answer to mails, when receiving the r-help as
digest...

...


The question was:


I compare each row of a matrix with each row of another matrix.

testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)


and it was asked for a compaison of the both matrix-objects and the
result should be a vetor with boolean results.

I would use this one:

   as.vector( testmat1 == testmat2 )

or maybe

  as.vector( t(testmat1) == t(testmat2) )

but the result as a matrix might also be interesting,
so as.vector() could be thrown out, and one would get
a matrix of results.

If you want just to know if a complete row is matching or not,
you could sum up the rows:

rowSums(testmat1 == testmat2 )

and when you compare it with the length,
you get a column-based match-boolean:


  rowSums(testmat1 == testmat2 ) == nrow(testmat1)

or if you need the negation of it:

  !rowSums(testmat1 == testmat2 ) == nrow(testmat1)

and as functions:

  matcolcomp <-function(m1,m2) { rowSums(m1 == m2) == nrow(m1) }

or

  matcolcomp <-function(m1,m2) { ! ( rowSums(m1 == m2) == nrow(m1) ) }


Ciao,
   Oliver

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] interpreting output from predict.blackboost

2008-11-10 Thread Kirsten Barrett
I would like to use blackboost on a training data set, then use the
output to predict a testing dataset, and finally evaluate the errors.
An example of the code I have written is the following:

train <- read.csv ("train.csv")
test <- read.csv ("test.csv")

boost <- blackboost (ogred ~ elev + slope + aspect, data = train)
pred <- predict (boost, newdata = test)

pred yields the following matrix:

 [1] 2.697689 3.551352 2.761541 3.271642 2.313459 2.207247 1.591521 3.752257
 [9] 2.976793 2.522219 1.988676 2.092666 3.550917 2.134925 2.534842 2.922136
[17] 2.277653 2.922136 2.922136 4.593132 2.922136 3.773274 4.647789 3.773274
[25] 4.647789 2.369810 2.645859 2.344808 1.760087 2.918108 2.714825 2.972284
[33] 3.466973 2.001098 1.706958 1.749830 1.960923 1.960923 2.451370 2.835255
[41] 2.443585 3.392883 3.164294 2.615430

I would like to know how to use this output to classify data the
testing dataset. Any advice is much appreciated.

Thank you,
Kirsten


-- 
Kirsten Barrett
Mendenhall Postdoctoral Fellow, USGS
Alaska Science Center
4210 University Drive
Anchorage, AK

phone (907) 786 7419
fax (907) 786 7401

[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem of unix package installation, following code no response: install.packages("packagename", dependecise=TRUE)

2008-11-10 Thread Yong Wang
Dear list

I am trying installing a package under unix, the command as below
works in some case but not some other cases, the primary
syndrome is R will stop there  with a message: (say I am trying to
install the package SASxport)

###
Warning in install.packages("SASxport", dependencies = TRUE) :
  argument 'lib' is missing: using
'/usr/home/d/068/wangyong/R/x86_64-unknown-linux-gnu-library/2.7'
Warning: unable to access index for repository
http://lib.stat.cmu.edu/R/CRAN/src/contrib
#

My internet connection has no problem, why this happen?
or can you suggest some more options or examples to follow for package
installation under unix?


Thank you

will

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to stop without error message?

2008-11-10 Thread John Fox
Dear Mark,

How about something like this?

> f <- function(x){
+   if (x < 0){
+ opt <- options(show.error.messages=FALSE)
+ on.exit(options(opt))
+ stop()
+ }
+   sqrt(x)
+   }
> 
> f(2)
[1] 1.414214
> f(-2)
>

I hope this helps,
 John

--
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
> Behalf Of [EMAIL PROTECTED]
> Sent: November-10-08 5:42 PM
> To: R-help@r-project.org
> Cc: [EMAIL PROTECTED]
> Subject: [R] how to stop without error message?
> 
> Dear list
> 
> Can anyone suggest a simple way to abort execution like stop(...) does,
but
> without issuing an "Error: ..." message?
> 
> I don't want to set 'options( show.error.messages=TRUE)' because I want
> normal behaviour to resume after this particular stop.
> 
> (Please reply personally as well as to the list, as I'm not subscribed to
R-
> help)
> 
> Thanks
> Mark
> 
> --
> Mark Bravington
> CSIRO Mathematical & Information Sciences
> Marine Laboratory
> Castray Esplanade
> Hobart 7001
> TAS
> 
> ph (+61) 3 6232 5118
> fax (+61) 3 6232 5012
> mob (+61) 438 315 623
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] interpreting output from predict.blackboost

2008-11-10 Thread Kirsten Barrett
I would like to use blackboost on a training data set, then use the
output to predict a testing dataset, and finally evaluate the errors.
An example of the code I have written is the following:

train <- read.csv ("train.csv")
test <- read.csv ("test.csv")

boost <- blackboost (ogred ~ elev + slope + aspect, data = train)
pred <- predict (boost, newdata = test)

pred yields the following matrix:

 [1] 2.697689 3.551352 2.761541 3.271642 2.313459 2.207247 1.591521 3.752257
 [9] 2.976793 2.522219 1.988676 2.092666 3.550917 2.134925 2.534842 2.922136
[17] 2.277653 2.922136 2.922136 4.593132 2.922136 3.773274 4.647789 3.773274
[25] 4.647789 2.369810 2.645859 2.344808 1.760087 2.918108 2.714825 2.972284
[33] 3.466973 2.001098 1.706958 1.749830 1.960923 1.960923 2.451370 2.835255
[41] 2.443585 3.392883 3.164294 2.615430

I would like to know how to use this output to classify data the
testing dataset. Any advice is much appreciated.

Thank you,
Kirsten

-- 
Kirsten Barrett
Mendenhall Postdoctoral Fellow, USGS
Alaska Science Center
4210 University Drive
Anchorage, AK

phone (907) 786 7419
fax (907) 786 7401

[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re order matrix columns

2008-11-10 Thread mentor_

Hi,

found a quite simple solution:

test
 a  b  c  d  e
[1,] 1 11 21 31 41
[2,] 2 12 22 32 42
[3,] 3 13 23 33 43
[4,] 4 14 24 34 44
[5,] 5 15 25 35 45

list <- c("b", "c", "a", "e", "d")

test[,list]




mentor_ wrote:
> 
> Hi,
> 
> I have found the following thread to reorder a data.frame.
> I would like to do same regarding a matrix:
> 
> https://stat.ethz.ch/pipermail/r-help/2008-February/154138.html
> 
> I achieved this with a for loop and cbind but I think using 'is.element'
> is much more
> appropriate. Can anyone help?
> 
> Cheers
> 

-- 
View this message in context: 
http://www.nabble.com/Reorder-matrix-columns-tp20428678p20428869.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Re order matrix columns

2008-11-10 Thread mentor_

Hi,

I have found the following thread to reorder a data.frame.
I would like to do same regarding a matrix:

https://stat.ethz.ch/pipermail/r-help/2008-February/154138.html

I achieved this with a for loop and cbind but I think using 'is.element' is
much more
appropriate. Can anyone help?

Cheers
-- 
View this message in context: 
http://www.nabble.com/Reorder-matrix-columns-tp20428678p20428678.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to stop without error message?

2008-11-10 Thread Mark.Bravington
Dear list

Can anyone suggest a simple way to abort execution like stop(...) does, but 
without issuing an "Error: ..." message?

I don't want to set 'options( show.error.messages=TRUE)' because I want normal 
behaviour to resume after this particular stop.

(Please reply personally as well as to the list, as I'm not subscribed to 
R-help)

Thanks
Mark

--
Mark Bravington
CSIRO Mathematical & Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] maptools sunrise sunset function

2008-11-10 Thread stephen sefick
try tz="America/Los_Angeles"  it was three hours before tz="America/New_York"

On Mon, Nov 10, 2008 at 4:25 PM, Sebastian P. Luque <[EMAIL PROTECTED]> wrote:
> On Mon, 10 Nov 2008 15:27:52 -0500,
> "stephen sefick" <[EMAIL PROTECTED]> wrote:
>
>> library(maptools) sunrise.set <- function(lat, long, date,
>> timezone="UTC", num.days=1){ #this needs to be long lat# lat.long <-
>> matrix(c(long, lat), nrow=1) day <- as.POSIXct(date, tz=timezone)
>> sequence <- seq(from=day, length.out=num.days , by="days") sunrise <-
>> sunriset(lat.long, sequence, direction="sunrise", POSIXct=TRUE) sunset
>> <- sunriset(lat.long, sequence, direction="sunset", POSIXct=TRUE) ss
>> <- data.frame(sunrise, sunset) ss <- ss[,-c(1,3)]
>> colnames(ss)<-c("sunrise", "sunset") return(ss)
>> }
>
>> I believe that he is refering to the code that I wrote above, which
>> relies heavily on map tools (to say the least).
>
> So what's the problem?  You specified timezone="UTC" so that's what
> you're getting.  WRT the warnings I do not get them, but the string
> passed may be wrong or some definitions as missing from his system.
> Sorry I cannot help with that.
>
>
> --
> Seb
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ttda and text-mining

2008-11-10 Thread Hans W. Borchers
LE PAPE Gilles  neuf.fr> writes:

> 
> The "ttda" package was devoted to text-mining. It seems to be no more
> available. Did the name change ? Are other packages devoted to text-mining?

The 'ttda' package is deprecated as is noted on the Task View "Natural Language
Processing". The old code is still available if you follow the link. Still I
would propose to convert to 'tm' instead. Another possibility is the 'ReadMe'
package at  for automated content analysis.

Hans Werner Borchers

> Many thanks
> 
> Gilles
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help  r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ttda and text-mining

2008-11-10 Thread Gabor Grothendieck
On Mon, Nov 10, 2008 at 1:18 PM, LE PAPE Gilles <[EMAIL PROTECTED]> wrote:
> The "ttda" package was devoted to text-mining. It seems to be no more 
> available. Did the name change ? Are other packages devoted to text-mining ?
>

There is a Natural Language Processing CRAN Task View.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ttda and text-mining

2008-11-10 Thread Erik Iverson
I don't know the history of the 'ttda' package, so can't comment. 
However, there is an article on text mining in R using the 'tm' package 
in the latest issue of R News.


LE PAPE Gilles wrote:

The "ttda" package was devoted to text-mining. It seems to be no more 
available. Did the name change ? Are other packages devoted to text-mining ?

 


Many thanks

Gilles

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ttda and text-mining

2008-11-10 Thread LE PAPE Gilles
The "ttda" package was devoted to text-mining. It seems to be no more 
available. Did the name change ? Are other packages devoted to text-mining ?

 

Many thanks

Gilles

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Non-parametric pairwise comparisons between related series

2008-11-10 Thread LE PAPE Gilles
How to perform non-parametric pairwise comparisons after a Friedman test 
performed in Rcmdr, i.e. with series in columns, either to compare different 
columns to a control or to perform all pairwise comparisons ?

Example

 J1 J2 J3 J4

11 12 22 41

40 41 42 48

15 22 20 20

54 59 63 68

23 29 24 22

63 63 63 67

27 30 31 40

30 32 30 29

49 51 60 71

 

Many thanks

Gilles

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] comparing rows - a possible solution

2008-11-10 Thread Oliver Bandel
Hello,

sorry for posting this independently of the original thread, but it is
not that easy to answer to mails, when receiving the r-help as
digest...

...


The question was:

> I compare each row of a matrix with each row of another matrix.
>
> testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
> testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)

and it was asked for a compaison of the both matrix-objects and the
result should be a vetor with boolean results.

I would use this one:

   as.vector( testmat1 == testmat2 )

or maybe

  as.vector( t(testmat1) == t(testmat2) )

but the result as a matrix might also be interesting,
so as.vector() could be thrown out, and one would get
a matrix of results.

If you want just to know if a complete row is matching or not,
you could sum up the rows:

rowSums(testmat1 == testmat2 )

and when you compare it with the length,
you get a column-based match-boolean:


  rowSums(testmat1 == testmat2 ) == nrow(testmat1)

or if you need the negation of it:

  !rowSums(testmat1 == testmat2 ) == nrow(testmat1)

and as functions:

  matcolcomp <-function(m1,m2) { rowSums(m1 == m2) == nrow(m1) }

or

  matcolcomp <-function(m1,m2) { ! ( rowSums(m1 == m2) == nrow(m1) ) }


Ciao,
   Oliver

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
On Mon, Nov 10, 2008 at 4:17 PM, Wacek Kusnierczyk
<[EMAIL PROTECTED]> wrote:
> Gabor Grothendieck wrote:
>> Certainly this has been recognized as a potential problem:
>>
>> http://developer.r-project.org/nonstandard-eval.pdf
>>
>> however, it is convenient when you are performing
>> an analysis and entering commands directly as opposed
>> to writing a program although possibly the potential ambiguities
>> overshadow the convenience.
>>
>
> in most cases, i do not see why one could not use a string literal
> passed by value instead of having an expression deparsed within the
> function, which may lead to confusing behaviour.  this would give much
> more consistent and predictable code.  this has nothing to do with the
> evaluation mechanism, which can still be lazy.
>
>
>
> in the case of subset, i do not really see how this design might be
> helpful, but it's easy to see how it can be harmful, examples have just

I think the thrust of your comments were already made by reference.

Regarding the convenience it occurs in expressions like this:

   iris2 <- subset(iris, select = - Species)

to create a data frame without the Species column.

Perhaps this would have better been done by allowing an optional
formula for the select clause:

   iris2 <- subset(iris, select = ~ - Species)

but I think R is stuck with what it has due to compatibility and the large
base of users yet its still possible to add functions in packages or new
functions to R so a new variant of subset would be possible in which
case one could decide to use the new function in place of the old one.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Remove Columns by Name from zoo object

2008-11-10 Thread Sean Carmody
Perfect, works like a charm. Thanks Gabor.
Sean.

On Mon, Nov 10, 2008 at 11:35 PM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> On Mon, Nov 10, 2008 at 12:31 AM, Sean Carmody <[EMAIL PROTECTED]> wrote:
>> The tricks for removing columns specified by name from data frames such as
>>
>> x$mycol <- NULL
>
> That only works for data frames since they are based on
> lists but not for objects like matrix, ts and zoo which are not
> based on lists.  Try this:
>
> library(zoo)
> z <- zoo(cbind(a = 1:2, b = 3:4, c = 5:6))
> # all but b
> z <- z[, colnames(z) != "b"]
> z
>
> z <- zoo(cbind(a = 1:2, b = 3:4, c = 5:6))
> # all but b and c
> z <- z[, ! colnames(z) %in% c("b", "c")]
> z
>



-- 
Sean Carmody

The Stubborn Mule
http://www.stubbornmule.net
http://twitter.com/seancarmody

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Preparing data for display

2008-11-10 Thread Stavros Macrakis
I have a dataset of about 10^6 rows, each consisting of a timestamp,
several factors, a string, some integers, and some floats.

I'd like to graph this data in various ways, including straightforward
ones (how many events per week over the past year for each of 4 values
of some factor), some less straightforward.  I've managed to do this
by brute force, but I'd like to learn how to do it in more elegant,
more R-like code.

Consider for example the following, which graphs the 25th, 50th, and
75th percentile values per day of data$x

perc <- function(code,data)
{ # select the part of the data with factor value
  slice <- data[data$factor == code,];
  # calc quartiles for each day
  quarts <- tapply(slice$x,
 slice$day,
 function(x) quantile(x,c(.25,.50,.75)));
 # returns a tagged list of tagged vectors
 # list("2008-10-07" = c("25%" = .05, "50%" = .47,
... ) , ...)
# convert to a data frame -- is there some mapping function to do this?
   fr <- data.frame( day = to.time(names(quarts)),   # strings
back to dates (!)
   "25%" = sapply(quarts, function(x)
x[[1]] ),   # !!
   "50%" = sapply(quarts, function(x) x[[2]] ),
   "75%" = sapply(quarts, function(x) x[[3]] ) );
 # columns are now labelled "X25." etc. (!)
for (i in 2:4) { plot( fr$day, res[[2]], type="l", ylim= c( 0,
max(pmax(fr[[1]],fr[[2]],fr[[3]] )) ));
  par(new=TRUE); }
par(new=FALSE);
}

This works, but is pretty ugly in a variety of ways.  What is the
right way to do this?

Thanks,

   -s

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] maptools sunrise sunset function

2008-11-10 Thread Sebastian P. Luque
On Mon, 10 Nov 2008 15:27:52 -0500,
"stephen sefick" <[EMAIL PROTECTED]> wrote:

> library(maptools) sunrise.set <- function(lat, long, date,
> timezone="UTC", num.days=1){ #this needs to be long lat# lat.long <-
> matrix(c(long, lat), nrow=1) day <- as.POSIXct(date, tz=timezone)
> sequence <- seq(from=day, length.out=num.days , by="days") sunrise <-
> sunriset(lat.long, sequence, direction="sunrise", POSIXct=TRUE) sunset
> <- sunriset(lat.long, sequence, direction="sunset", POSIXct=TRUE) ss
> <- data.frame(sunrise, sunset) ss <- ss[,-c(1,3)]
> colnames(ss)<-c("sunrise", "sunset") return(ss)
> }

> I believe that he is refering to the code that I wrote above, which
> relies heavily on map tools (to say the least).

So what's the problem?  You specified timezone="UTC" so that's what
you're getting.  WRT the warnings I do not get them, but the string
passed may be wrong or some definitions as missing from his system.
Sorry I cannot help with that.


-- 
Seb

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] TimeZone Help - Finding TimeZone codes

2008-11-10 Thread Prof Brian Ripley

See ?Sys.timezone, which help.search("timezone") points you to.

On Mon, 10 Nov 2008, stephen sefick wrote:


I have looked at
?as.POSIXct


That also links to Sys.timezone from the 'tz' argument.


?POSIXct
and many of the references that are on those pages.

I am bewildered with timezones.  Is there a way to get what would go
into tz="" for making a function that uses POSIXct to be able to be
used in all of the timezones in just the united states?  This is for
both windows and mac...


There are rather a lot of timezones in the United States (sic), down to 
individual counties.


For both Windows (sic) and Mac OS (sic) R uses the Olsen database, and so 
timezones are best specfied by "America/" for city names, plus 
"America/Kentucky/{Louisville,Monticello}"




this is the function that I am wanting to use it with

library(maptools)
sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
  #this needs to be long lat#
  lat.long <- matrix(c(long, lat), nrow=1)
  day <- as.POSIXct(date, tz=timezone)
  sequence <- seq(from=day, length.out=num.days , by="days")
  sunrise <- sunriset(lat.long, sequence, direction="sunrise",
POSIXct=TRUE)
  sunset <- sunriset(lat.long, sequence, direction="sunset", POSIXct=TRUE)
  ss <- data.frame(sunrise, sunset)
  ss <- ss[,-c(1,3)]
  colnames(ss)<-c("sunrise", "sunset")
  return(ss)
}



thanks in advance,

--
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] in R when I get negative adjusted R^2 using "lm", what might be the problem?

2008-11-10 Thread Tom Backer Johnsen

Greg Snow wrote:

No problem, adjusted R-squared can be negative.  If there truly is no 
relationship, then the adjusted R-squared should average to 0, so sometimes it 
must be negative.  All of your R-squared and adjusted R-squared values suggest 
that there is not much of a relationship (less without the transform).


Nevertheless, there remains the logical problem of a negative squared 
value.


In any case, given the relatively large difference between the R-square 
and the adjusted value, he probably has a relative large number of 
independent variables compared to the number of rows in the data set. 
And the dependent variable is probably quite skewed as well.


Tom

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote:
> Certainly this has been recognized as a potential problem:
>
> http://developer.r-project.org/nonstandard-eval.pdf
>
> however, it is convenient when you are performing
> an analysis and entering commands directly as opposed
> to writing a program although possibly the potential ambiguities
> overshadow the convenience.
>   

in most cases, i do not see why one could not use a string literal
passed by value instead of having an expression deparsed within the
function, which may lead to confusing behaviour.  this would give much
more consistent and predictable code.  this has nothing to do with the
evaluation mechanism, which can still be lazy. 



in the case of subset, i do not really see how this design might be
helpful, but it's easy to see how it can be harmful, examples have just
been given.  the convenience here is at most up to being able to omit
quotes, at the risk of having columns selected where they should not,
and vice versa.  the worst thing is that it destroys the benefit of
lexical scoping:

subset(d, select=group)

did the programmer intend to select the column named 'group'?  or the
columns whose names appear in the vector group?  is d supposed not to
have a column named 'group', should one change the identifier if d does
have such a column, to avoid selecting that column instead of whatever
else would be selected?  etc.  could this not be written as

subset(d, select="group") 

(two extra characters), and have it cleanly and always mean 'pick the
one column named 'group''? 

so there are actually three problems here:
- one that a programmer may be unaware that her own code not do what she
wants;
- another that a user may unaware of that the code she uses performs
this way;
- another that a user may not be sure whether the code may be reused as
is, or must be modified so as not to interfere with the particular data.

the dependence of subset's behaviour on the particular data it is
applied to is confusing.  and here's an example of how it breaks its own
smart semantics:

d = data.frame(a=1)
d$`c(a,b)` = 2
d
# no problem, two columns
names(d)
# one named 'c(a,b)'

subset(d, select=c(a,b))
# so what?  the expression given to select certainly is a valid and
actual name of a column in d, but subset complains there's no such
column (well, it actually says object "b" not found, by which it
probably means that object b, i.e., object named 'b', has not been
found.  not only uninformative as a message in this situation, but also
revealing the pervasive confusion of the name and the named, as the
object "b" -- a one-character string -- has not been mentioned here at
all.  what a mess.)

this can't possibly be considered good design, can it?  the dubious
benefit is heavily outweighed by the drawbacks.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] maptools sunrise sunset function

2008-11-10 Thread Prof Brian Ripley

On Mon, 10 Nov 2008, Farley, Robert wrote:


I have a time zone problem.

Running the code provided I get the result in UTC, and a lot of warnings
like this:
28: In as.POSIXlt.POSIXct(x, tz) ... : unknwon timezone 'PST'





sunrise.set(34.11583, -118.18719, "2008-11-14")

  sunrise  sunset
newlon 2008-11-14 14:25:02 2008-11-15 00:49:09


Sys.timezone()

[1] "PST"



The result is equivalent to 06:25:02 16:49:09 {PST = UTC-8}
The "correct" values from another source show 06:25 16:50 which agree to
beyond the accuracy of prediction due to atmospheric uncertainty.


How SHOULD I specify the TZ?  I would think that PST is a pretty
"standard" ;-) time zone.


Your thoughts are misinformed: PST8PDT is a name of a standard timezone, 
but PST is not.  See ?Sys.timezone for fuller details. See also the 
posting guide: you failed to tell us your OS, which matters here.




Yes, I steal a lot of code snippets.  I justify it by telling myself it
helps me learn R.


Robert Farley
Metro
www.Metro.net

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of stephen sefick
Sent: Saturday, November 08, 2008 17:09
To: R-help
Subject: Re: [R] maptools sunrise sunset function

Nevermind, when one puts in the proper coordinates in decimal degrees
everything works just fine.
thanks for you patience,

Stephen

On Sat, Nov 8, 2008 at 7:40 PM, stephen sefick <[EMAIL PROTECTED]>
wrote:

##This is a function that I am trying to write to calculate sunrise
and sunset and works "mostly", but returns nonsensical values.  What
am I #missing?  Thanks in advance.

###remember to include maptools as dependence###
library(maptools)
sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
   #this needs to be long lat#
   lat.long <- matrix(c(long, lat), nrow=1)
   day <- as.POSIXct(date, tz=timezone)
   sequence <- seq(from=day, length.out=num.days , by="days")
   sunrise <- sunriset(lat.long, sequence, direction="sunrise",

POSIXct=TRUE)

   sunset <- sunriset(lat.long, sequence, direction="sunset",

POSIXct=TRUE)

   ss <- data.frame(sunrise, sunset)
   ss <- ss[,-c(1,3)]
   colnames(ss)<-c("sunrise", "sunset")
   return(ss)
}

#This doesn't make any sense
sunrise.set(33.46, 84.25, "2008-11-08", timezone="EST")


--
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy


--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
Forgot the name part.  Try:

TestFunc2 <- function(DF, group) names(DF[group])
TestFunc3 <- function(...) names(subset(..., subset = TRUE))
TestFunc4 <- function(...) eval.parent(names(subset(..., subset = TRUE)))

# e.g.
df1 <- data.frame(group = "G1", visit = "V1", value = 0.9)
TestFunc2(df1, c("group", "visit"))
TestFunc3(df1, c("group", "visit"))
TestFunc4(df1, c("group", "visit"))
TestFunc4(df1, c(group, visit)) # this works too

On Mon, Nov 10, 2008 at 10:43 AM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> Here are a few things to try:
>
> TestFunc1 <- get("[")
>
> TestFunc2 <- function(DF, group) DF[group]
>
> TestFunc3 <- function(...) subset(..., subset = TRUE)
>
>
>
> On Mon, Nov 10, 2008 at 10:18 AM, Karl Knoblick <[EMAIL PROTECTED]> wrote:
>> Hello!
>>
>> I have the problem that in my function the passed variable is not used, but 
>> the variable name of the dataframe itself - difficult to explain, but an 
>> easy example:
>>
>> TestFunc<-function(df, group) {
>> print(names(subset(df, select=group)))
>> }
>> df1<-data.frame(group="G1", visit="V1", value=0.9)
>> TestFunc(df1, c("group", "visit"))
>>
>> Result:
>> [1] "group"
>>
>> But I expected and want to have [1] "group" "visit" as result! Does anybody 
>> know how to get this result?
>>
>> Thanks!
>> Karl
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Labeling points with xYplot

2008-11-10 Thread John Poulsen

That did it!  Thanks for the help!!! -- John

David Winsemius wrote:

See if this does what you are expecting.

 xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
  panel=function(x,y,...){
panel.xYplot(x,y,subscripts=x,...)
panel.superpose(x,y, subscripts=x, groups=x,...)
ltext(x=list(1,2,3,4),
  y=list(13,14,15,16),
  labels=list("A","B","C","D"), pos=2)})


---

David Winsemius, MD
Heritage Labs
comes with the usual warrantee... if it breaks you get to keep the parts


On Nov 10, 2008, at 11:26 AM, John Poulsen wrote:


Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but 
then I lose the error bars.  I suspect that I should be using 
panel.xYplot rather than panel.xyplot, but that didn't work either...


Can anybody help me out?  Example code is below.  First xYplot has 
error bars, second tries to label the points and the bars disappear.


Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
  ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
  panel=function(x,y,...){
panel.xyplot(x,y,...)
ltext(x=list(1,2,3,4),
  y=list(13,14,15,16),
  labels=list("A","B","C","D"), pos=2)})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Labeling points with xYplot

2008-11-10 Thread David Winsemius

See if this does what you are expecting.

 xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
  panel=function(x,y,...){
panel.xYplot(x,y,subscripts=x,...)
panel.superpose(x,y, subscripts=x, groups=x,...)
ltext(x=list(1,2,3,4),
  y=list(13,14,15,16),
  labels=list("A","B","C","D"), pos=2)})


---

David Winsemius, MD
Heritage Labs
comes with the usual warrantee... if it breaks you get to keep the parts


On Nov 10, 2008, at 11:26 AM, John Poulsen wrote:


Hello R-Users,

I am trying to label points on an xYplot.  I can label the points,  
but then I lose the error bars.  I suspect that I should be using  
panel.xYplot rather than panel.xyplot, but that didn't work either...


Can anybody help me out?  Example code is below.  First xYplot has  
error bars, second tries to label the points and the bars disappear.


Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
  ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
  panel=function(x,y,...){
panel.xyplot(x,y,...)
ltext(x=list(1,2,3,4),
  y=list(13,14,15,16),
  labels=list("A","B","C","D"), pos=2)})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] maptools sunrise sunset function

2008-11-10 Thread stephen sefick
library(maptools)
sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
   #this needs to be long lat#
   lat.long <- matrix(c(long, lat), nrow=1)
   day <- as.POSIXct(date, tz=timezone)
   sequence <- seq(from=day, length.out=num.days , by="days")
   sunrise <- sunriset(lat.long, sequence, direction="sunrise",
POSIXct=TRUE)
   sunset <- sunriset(lat.long, sequence, direction="sunset", POSIXct=TRUE)
   ss <- data.frame(sunrise, sunset)
   ss <- ss[,-c(1,3)]
   colnames(ss)<-c("sunrise", "sunset")
   return(ss)
}

I believe that he is refering to the code that I wrote above, which
relies heavily on map tools (to say the least).


On Mon, Nov 10, 2008 at 3:21 PM, Sebastian P. Luque <[EMAIL PROTECTED]> wrote:
> On Mon, 10 Nov 2008 11:20:03 -0800,
> "Farley, Robert" <[EMAIL PROTECTED]> wrote:
>
>> I have a time zone problem.  Running the code provided I get the
>> result in UTC, and a lot of warnings like this: 28: In
>> as.POSIXlt.POSIXct(x, tz) ... : unknwon timezone 'PST'
>
>>> sunrise.set(34.11583, -118.18719, "2008-11-14")
>>sunrise sunset newlon 2008-11-14 14:25:02
>> 2008-11-15 00:49:09
>
> That function doesn't exist in maptools, but I guess you're referring to
> sunriset().  Even with that assumption, I get:
>
> ---<---cut here---start-->---
> R> sunriset(34.11583, -118.18719, "2008-11-14")
> Error in function (classes, fdef, mtable)  :
>  unable to find an inherited method for function "sunriset", for signature 
> "numeric", "numeric"
> ---<---cut here---end>---
>
> Doesn't look like a time zone issue at all.  Can you show something we
> can all run on our systems as per the posting guide?  That would save us
> lots of time.
>
>
> --
> Seb
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] maptools sunrise sunset function

2008-11-10 Thread Sebastian P. Luque
On Mon, 10 Nov 2008 11:20:03 -0800,
"Farley, Robert" <[EMAIL PROTECTED]> wrote:

> I have a time zone problem.  Running the code provided I get the
> result in UTC, and a lot of warnings like this: 28: In
> as.POSIXlt.POSIXct(x, tz) ... : unknwon timezone 'PST'

>> sunrise.set(34.11583, -118.18719, "2008-11-14")
>sunrise sunset newlon 2008-11-14 14:25:02
> 2008-11-15 00:49:09

That function doesn't exist in maptools, but I guess you're referring to
sunriset().  Even with that assumption, I get:

---<---cut here---start-->---
R> sunriset(34.11583, -118.18719, "2008-11-14")
Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function "sunriset", for signature 
"numeric", "numeric"
---<---cut here---end>---

Doesn't look like a time zone issue at all.  Can you show something we
can all run on our systems as per the posting guide?  That would save us
lots of time.


-- 
Seb

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] TimeZone Help - Finding TimeZone codes

2008-11-10 Thread stephen sefick
I have looked at
?as.POSIXct
?POSIXct
and many of the references that are on those pages.

I am bewildered with timezones.  Is there a way to get what would go
into tz="" for making a function that uses POSIXct to be able to be
used in all of the timezones in just the united states?  This is for
both windows and mac...
this is the function that I am wanting to use it with

library(maptools)
sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
   #this needs to be long lat#
   lat.long <- matrix(c(long, lat), nrow=1)
   day <- as.POSIXct(date, tz=timezone)
   sequence <- seq(from=day, length.out=num.days , by="days")
   sunrise <- sunriset(lat.long, sequence, direction="sunrise",
POSIXct=TRUE)
   sunset <- sunriset(lat.long, sequence, direction="sunset", POSIXct=TRUE)
   ss <- data.frame(sunrise, sunset)
   ss <- ss[,-c(1,3)]
   colnames(ss)<-c("sunrise", "sunset")
   return(ss)
 }



thanks in advance,

-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Labeling points with xYplot

2008-11-10 Thread John Poulsen
Yes, using panel.xYplot is the best thing to do.  I couldn't get it to 
work, which probably means I was specifying it incorrectly.  I would be 
very happy if someone had an example of how to do it.


Thanks again -- John

Frank E Harrell Jr wrote:

John Poulsen wrote:

Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but 
then I lose the error bars.  I suspect that I should be using 
panel.xYplot rather than panel.xyplot, but that didn't work either...


Can anybody help me out?  Example code is below.  First xYplot has 
error bars, second tries to label the points and the bars disappear.


Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
   ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
   panel=function(x,y,...){
 panel.xyplot(x,y,...)
 ltext(x=list(1,2,3,4),
   y=list(13,14,15,16),
   labels=list("A","B","C","D"), pos=2)})


One of the purposes of xYplot is to use panel.xYplot
Frank



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Make one vector from matrix comparison

2008-11-10 Thread Gabor Grothendieck
Try:

c(inner(testmat1, testmat2, setequal))

where inner is defined here:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70762.html

On Mon, Nov 10, 2008 at 10:11 AM, Chris82 <[EMAIL PROTECTED]> wrote:
>
> Hello R-users,
>
> I have a little problem.
>
> I compare each row of a matrix with each row of another matrix.
>
> testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
> testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
>
> Both matrix differs in the last row.
>
> Now I create a loop:
>
> for (i in (1:4)){
> for (j in (1:4)){
> b <- (c(setequal(testmat1[j,],testmat2[i,])))
> print(b)
> }
> }
>
> R outputs me the following:
>
> [1] TRUE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] TRUE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] TRUE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
>
> but I need one vector like this:
>
> [1] TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE
> FALSE FALSE FALSE FALSE
>
> Any ideas?
>
> thanks
> --
> View this message in context: 
> http://www.nabble.com/Make-one-vector-from-matrix-comparison-tp20421761p20421761.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Labeling points with xYplot

2008-11-10 Thread Frank E Harrell Jr

John Poulsen wrote:

Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but 
then I lose the error bars.  I suspect that I should be using 
panel.xYplot rather than panel.xyplot, but that didn't work either...


Can anybody help me out?  Example code is below.  First xYplot has error 
bars, second tries to label the points and the bars disappear.


Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
   ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
   panel=function(x,y,...){
 panel.xyplot(x,y,...)
 ltext(x=list(1,2,3,4),
   y=list(13,14,15,16),
   labels=list("A","B","C","D"), pos=2)})


One of the purposes of xYplot is to use panel.xYplot
Frank

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] maptools sunrise sunset function

2008-11-10 Thread stephen sefick
I have looked at the timezone documentation
?POSIXct
and can not figure it out
maybe it would be good to ask this specifically on the list
this function is going to be included in the next update of the
package StreamMetabolism

Stephen Sefick

On Mon, Nov 10, 2008 at 2:20 PM, Farley, Robert <[EMAIL PROTECTED]> wrote:
> I have a time zone problem.
>
> Running the code provided I get the result in UTC, and a lot of warnings
> like this:
> 28: In as.POSIXlt.POSIXct(x, tz) ... : unknwon timezone 'PST'
>
>
>
>
>> sunrise.set(34.11583, -118.18719, "2008-11-14")
>   sunrise  sunset
> newlon 2008-11-14 14:25:02 2008-11-15 00:49:09
>>
>> Sys.timezone()
> [1] "PST"
>>
> The result is equivalent to 06:25:02 16:49:09 {PST = UTC-8}
> The "correct" values from another source show 06:25 16:50 which agree to
> beyond the accuracy of prediction due to atmospheric uncertainty.
>
>
> How SHOULD I specify the TZ?  I would think that PST is a pretty
> "standard" ;-) time zone.
>
>
>
>
> Yes, I steal a lot of code snippets.  I justify it by telling myself it
> helps me learn R.
>
>
>
>
>
>
> Robert Farley
> Metro
> www.Metro.net
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of stephen sefick
> Sent: Saturday, November 08, 2008 17:09
> To: R-help
> Subject: Re: [R] maptools sunrise sunset function
>
> Nevermind, when one puts in the proper coordinates in decimal degrees
> everything works just fine.
> thanks for you patience,
>
> Stephen
>
> On Sat, Nov 8, 2008 at 7:40 PM, stephen sefick <[EMAIL PROTECTED]>
> wrote:
>> ##This is a function that I am trying to write to calculate sunrise
>> and sunset and works "mostly", but returns nonsensical values.  What
>> am I #missing?  Thanks in advance.
>>
>> ###remember to include maptools as dependence###
>> library(maptools)
>> sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
>>#this needs to be long lat#
>>lat.long <- matrix(c(long, lat), nrow=1)
>>day <- as.POSIXct(date, tz=timezone)
>>sequence <- seq(from=day, length.out=num.days , by="days")
>>sunrise <- sunriset(lat.long, sequence, direction="sunrise",
> POSIXct=TRUE)
>>sunset <- sunriset(lat.long, sequence, direction="sunset",
> POSIXct=TRUE)
>>ss <- data.frame(sunrise, sunset)
>>ss <- ss[,-c(1,3)]
>>colnames(ss)<-c("sunrise", "sunset")
>>return(ss)
>> }
>>
>> #This doesn't make any sense
>> sunrise.set(33.46, 84.25, "2008-11-08", timezone="EST")
>>
>>
>> --
>> Stephen Sefick
>> Research Scientist
>> Southeastern Natural Sciences Academy
>>
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>-K.
> Mullis
>>
>
>
>
> --
> Stephen Sefick
> Research Scientist
> Southeastern Natural Sciences Academy
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>-K.
> Mullis
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
Certainly this has been recognized as a potential problem:

http://developer.r-project.org/nonstandard-eval.pdf

however, it is convenient when you are performing
an analysis and entering commands directly as opposed
to writing a program although possibly the potential ambiguities
overshadow the convenience.

On Mon, Nov 10, 2008 at 2:04 PM, Wacek Kusnierczyk
<[EMAIL PROTECTED]> wrote:
> pardon me, but does this address in any way the legitimate complaint of
> the rightfully confused user?
>
> consider the following:
>
> d = data.frame(a=1, b=2)
> a = c("a", "b")
> z = a
> # that is, both a and z are c("a", "b")
>
> subset(d, select=z)
> # gives two columns, since z is a two element vector whose elements are
> valid column names
>
> subset(d, select=a)
> # gives one column, since 'a' (but not a) is a valid column name
>
> subset(d, select=c(a,b))
> # gives two columns
>
>
> this is certainly what the authors intended, and they may have good
> grounds for this smart design.  but this must break the expectation of a
> naive (r-naive, for that matter) user, who may otherwise have excellent
> experience in using a functional programming language, e.g., scheme.
> (especially scheme, where symbols and expressions are first-class
> objects, yet the distinction between a symbol or an expression and their
> referent is made painfully clear, perhaps except for when one hacks with
> macros.)
>
> the examples above illustrate the notorious problem with r that one can
> never tell whether 'a' means "the value referred to with the identifier
> 'a'" or "the symbol 'a'", unless one gets ugly surprises and is forced
> to study the documentation.  and even then one may not get a clear answer.
>
> the example given by the confused user is a red flag warning.  it's a
> typical abstraction where a nested sequence of operations (here print
> over names over subset) is abstracted into a single procedure, which can
> be called with whatever arguments are valid:
>
> pns = function(d, g) print(names(subset(d, select=g)))
>
> what sane person, without carefully studying the gory details of subset,
> will ever expect that if the first argument happens to have a column
> named 'g', only this one will be selected, while if it doesn't, subset
> will select the columns named by the components of what 'g' evaluates
> to.  i wonder how many users have *not* noticed that what they get is
> not what they assume they get because of such tricky tricks, and in
> consequence were not able to publish their analyses (or worse, have
> published them).
>
> what is scary is that this may happen with about any other function in
> r, because the design is pervasive.  no one should ever use any r
> function without first carefully reading the docs (which is not
> guaranteed to help) or trying it first on a number of carefully crafted
> test cases.  if such care is not taken, results obtained with r cannot
> be taken seriously.
>
>
> vQ
>
>
> Gabor Grothendieck wrote:
>> Forgot the name part.  Try:
>>
>> TestFunc2 <- function(DF, group) names(DF[group])
>> TestFunc3 <- function(...) names(subset(..., subset = TRUE))
>> TestFunc4 <- function(...) eval.parent(names(subset(..., subset = TRUE)))
>>
>> # e.g.
>> df1 <- data.frame(group = "G1", visit = "V1", value = 0.9)
>> TestFunc2(df1, c("group", "visit"))
>> TestFunc3(df1, c("group", "visit"))
>> TestFunc4(df1, c("group", "visit"))
>> TestFunc4(df1, c(group, visit)) # this works too
>>
>> On Mon, Nov 10, 2008 at 10:43 AM, Gabor Grothendieck
>> <[EMAIL PROTECTED]> wrote:
>>
>>> Here are a few things to try:
>>>
>>> TestFunc1 <- get("[")
>>>
>>> TestFunc2 <- function(DF, group) DF[group]
>>>
>>> TestFunc3 <- function(...) subset(..., subset = TRUE)
>>>
>>>
>>>
>>> On Mon, Nov 10, 2008 at 10:18 AM, Karl Knoblick <[EMAIL PROTECTED]> wrote:
>>>
 Hello!

 I have the problem that in my function the passed variable is not used, 
 but the variable name of the dataframe itself - difficult to explain, but 
 an easy example:

 TestFunc<-function(df, group) {
 print(names(subset(df, select=group)))
 }
 df1<-data.frame(group="G1", visit="V1", value=0.9)
 TestFunc(df1, c("group", "visit"))

 Result:
 [1] "group"

 But I expected and want to have [1] "group" "visit" as result! Does 
 anybody know how to get this result?

 Thanks!
 Karl

>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read SAS file

2008-11-10 Thread Philipp Pagel
> I must have this file in the wrong directory.  I can see it and
> it's spelled correctly in my command (including case) but I
> get:
>  
> > library(foreign)
> > read.xport("cft2008R")
> Error in lookup.xport(file) :   unable to open file: 'No such file or
> > directory'

R is looking in the current work directory - whatver that may be
in your case. try this to ease things:

read.xport(file.choose())

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] maptools sunrise sunset function

2008-11-10 Thread Farley, Robert
I have a time zone problem.  

Running the code provided I get the result in UTC, and a lot of warnings
like this:
28: In as.POSIXlt.POSIXct(x, tz) ... : unknwon timezone 'PST'




> sunrise.set(34.11583, -118.18719, "2008-11-14")
   sunrise  sunset
newlon 2008-11-14 14:25:02 2008-11-15 00:49:09
>
> Sys.timezone()
[1] "PST"
>
The result is equivalent to 06:25:02 16:49:09 {PST = UTC-8}
The "correct" values from another source show 06:25 16:50 which agree to
beyond the accuracy of prediction due to atmospheric uncertainty.


How SHOULD I specify the TZ?  I would think that PST is a pretty
"standard" ;-) time zone.




Yes, I steal a lot of code snippets.  I justify it by telling myself it
helps me learn R.





 
Robert Farley
Metro
www.Metro.net 
 
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of stephen sefick
Sent: Saturday, November 08, 2008 17:09
To: R-help
Subject: Re: [R] maptools sunrise sunset function

Nevermind, when one puts in the proper coordinates in decimal degrees
everything works just fine.
thanks for you patience,

Stephen

On Sat, Nov 8, 2008 at 7:40 PM, stephen sefick <[EMAIL PROTECTED]>
wrote:
> ##This is a function that I am trying to write to calculate sunrise
> and sunset and works "mostly", but returns nonsensical values.  What
> am I #missing?  Thanks in advance.
>
> ###remember to include maptools as dependence###
> library(maptools)
> sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
>#this needs to be long lat#
>lat.long <- matrix(c(long, lat), nrow=1)
>day <- as.POSIXct(date, tz=timezone)
>sequence <- seq(from=day, length.out=num.days , by="days")
>sunrise <- sunriset(lat.long, sequence, direction="sunrise",
POSIXct=TRUE)
>sunset <- sunriset(lat.long, sequence, direction="sunset",
POSIXct=TRUE)
>ss <- data.frame(sunrise, sunset)
>ss <- ss[,-c(1,3)]
>colnames(ss)<-c("sunrise", "sunset")
>return(ss)
> }
>
> #This doesn't make any sense
> sunrise.set(33.46, 84.25, "2008-11-08", timezone="EST")
>
>
> --
> Stephen Sefick
> Research Scientist
> Southeastern Natural Sciences Academy
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>-K.
Mullis
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K.
Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read SAS file

2008-11-10 Thread Erik Iverson

What is the working directory, getwd() ?

That's where R will look.  give read.xport the full path to your file? 
YOu might also look at sas.get from the Hmisc package.


b g wrote:

I must have this file in the wrong directory.  I can see it and it's spelled 
correctly in my command (including case) but I get:
 

library(foreign)> read.xport("cft2008R")Error in lookup.xport(file) :   unable to 
open file: 'No such file or directory'> There are several subdirectories under C:\Program 
Files\R\R-2.8.0\ .  Should it be in one of those?
 
 

From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]; r-help@r-project.org> Date: Mon, 10 Nov 2008 13:41:37 -0500> Subject: RE: [R] read SAS file> > Did you load the "foreign" library first?> > 
Try:> > library(foreign)> read.xport("cft2008R")> > HTH,> > Patrick> > > -Original Message-> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of b g> 
Sent: Monday, November 10, 2008 1:29 PM> To: r-help@r-project.org> Subject: [R] read SAS file> > > Looked at a lot of documentation and listserv postings and still can't solve this problem. I need to get 
a SAS dataset into R. I've converted it to an .xpt file and when I try to read it I get:> > > read.xport("cft2008R")> Error: could not find function "read.xport"> >> > Not 
sure what I'm doing wrong. I'm running SAS 9.1.3 on an UNIX box. I ftp'd the file over to my C:\Program Files\R\R-2.8.0\ directory on my local machine running WinXP. Suggestions appreciated.> ___

!

 __> > l.> > ty_112008> [[alternative 
HTML version deleted]]> > This email message, including any attachments, is for the sole use 
of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, 
disclosure or distribution is prohibited. If you are not the intended recipient(s) please contact 
the sender by reply email and destroy all copies of the original message. Thank you.
_

of your life

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Combing xyplot and curve() plot via print

2008-11-10 Thread Afshartous, David

Thanks.  I tried you suggestion and it indeed solves the problem.  For the 
sample code below the appropriate substitute to the curve function is:

xv = seq(0, 3, by = .05)
yv = sin(xv)
yv.new = cos(xv)
p.12 = xyplot(yv + yv.new ~ xv, type="l", lty=c(1,5), col="black")


On 11/10/08 2:09 PM, "Greg Snow" <[EMAIL PROTECTED]> wrote:

The xyplot function is a lattice function that uses grid graphics.  The curve 
function is a base graphics function.  'par' and 'layout' work with base 
graphics, the print idea works with grid graphics.  Grid graphics and base 
graphics don't mix easily.  One option is to find a grid/lattice/ggplot2 
alternative of the curve function so that you are using all grid graphics, or 
you can use base graphics to recreate the xyplot in base.  There is also the 
gridBase package that makes combining the 2 systems easier (but still not 
simple).

Hope this helps,

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


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Afshartous, David
> Sent: Monday, November 10, 2008 8:51 AM
> To: r-help@r-project.org
> Subject: [R] Combing xyplot and curve() plot via print
>
> All,
>
> I'm trying to put an xyplot and a plot produced via curve() on the same
> page.  It seems that mfrow and layout don't work, and now I'm trying
> print
> but that does not work either.  Any suggestions much appreciated.
>
> Cheers,
> David
>
> p.11 = xyplot(1:10 ~ 1:10)
>
> curve(sin, 0,3, ylim=c(-3,3), ylab="sin and cos",  lty = 1)
> curve(cos, 0,3,  ylim=c(-3,3), lty = 5, add=TRUE)
> legend(2,2, legend = "legend here")
> p.12 = recordPlot()
>
> print(p.11, split = c(1,1, 2,1), more = T)
> print(p.12, split=c(2,1,2,1), more = T  )
>
>
>
>
>
> > sessionInfo()
> R version 2.7.1 (2008-06-23)
> i386-apple-darwin8.10.1
>
> locale:
> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] lattice_0.17-8
>
> loaded via a namespace (and not attached):
> [1] Matrix_0.999375-11 grid_2.7.1 lme4_0.999375-24   nlme_3.1-
> 89
> >
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read SAS file

2008-11-10 Thread b g

I must have this file in the wrong directory.  I can see it and it's spelled 
correctly in my command (including case) but I get:
 
> library(foreign)> read.xport("cft2008R")Error in lookup.xport(file) :   
> unable to open file: 'No such file or directory'> There are several 
> subdirectories under C:\Program Files\R\R-2.8.0\ .  Should it be in one of 
> those?
 
 
> From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]; r-help@r-project.org> Date: 
> Mon, 10 Nov 2008 13:41:37 -0500> Subject: RE: [R] read SAS file> > Did you 
> load the "foreign" library first?> > Try:> > library(foreign)> 
> read.xport("cft2008R")> > HTH,> > Patrick> > > -Original Message-> 
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of b g> Sent: 
> Monday, November 10, 2008 1:29 PM> To: r-help@r-project.org> Subject: [R] 
> read SAS file> > > Looked at a lot of documentation and listserv postings and 
> still can't solve this problem. I need to get a SAS dataset into R. I've 
> converted it to an .xpt file and when I try to read it I get:> > > 
> read.xport("cft2008R")> Error: could not find function "read.xport"> >> > Not 
> sure what I'm doing wrong. I'm running SAS 9.1.3 on an UNIX box. I ftp'd the 
> file over to my C:\Program Files\R\R-2.8.0\ directory on my local machine 
> running WinXP. Suggestions appreciated.> ___!
 __> > l.> > ty_112008> 
[[alternative HTML version deleted]]> > This email message, including any 
attachments, is for the sole use of the intended recipient(s) and may contain 
confidential information. Any unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient(s) please 
contact the sender by reply email and destroy all copies of the original 
message. Thank you.
_

of your life

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] in R when I get negative adjusted R^2 using "lm", what might be the problem?

2008-11-10 Thread Greg Snow
No problem, adjusted R-squared can be negative.  If there truly is no 
relationship, then the adjusted R-squared should average to 0, so sometimes it 
must be negative.  All of your R-squared and adjusted R-squared values suggest 
that there is not much of a relationship (less without the transform).

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


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Michael
> Sent: Sunday, November 09, 2008 6:37 PM
> To: r-help
> Subject: [R] in R when I get negative adjusted R^2 using "lm", what
> might be the problem?
>
> This is a linear regression of Y onto factors...
>
> If I take log of Y, and regress onto the factors, I got:
>
> Multiple R-squared: 0.4023, Adjusted R-squared: 0.2731
>
> If I don't take log of Y, and directly regress Y onto the factors, I
> got:
>
> Multiple R-squared: 0.1807, Adjusted R-squared: -0.001112
>
> Is this negative adjusted R^2 a problem?
>
> What observation can I make here and what might be the problem?
>
> Thanks!
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] making shape files into data bases usable within maps

2008-11-10 Thread claudia tebaldi
Hello R-helpers,

a while ago I had a question about identifying points on a map
belonging to a specific region.
I learned at that time that if the region is part of one of the
databases in the library maps that is easily done by using the
function map.where()  -- thanks to Duncan Murdoch for the hint!

My now related question is, what if my geographical information is not
already available within maps (the library) but is in a shape file? I
can read the file in R, but I'm not clear how to make it into a
database that is "understood" by the functions in the library maps. Is
this at all possible?

Thank you very much -- once again -- in advance

claudia

-- 
Claudia Tebaldi
Research Scientist, Climate Central
http://www.climatecentral.org
currently visiting IMAGe/NCAR
PO Box 3000
Boulder, CO 80305
tel. 303.497.2487

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Wacek Kusnierczyk
pardon me, but does this address in any way the legitimate complaint of
the rightfully confused user?

consider the following:

d = data.frame(a=1, b=2)
a = c("a", "b")
z = a
# that is, both a and z are c("a", "b")

subset(d, select=z)
# gives two columns, since z is a two element vector whose elements are
valid column names

subset(d, select=a)
# gives one column, since 'a' (but not a) is a valid column name

subset(d, select=c(a,b))
# gives two columns


this is certainly what the authors intended, and they may have good
grounds for this smart design.  but this must break the expectation of a
naive (r-naive, for that matter) user, who may otherwise have excellent
experience in using a functional programming language, e.g., scheme. 
(especially scheme, where symbols and expressions are first-class
objects, yet the distinction between a symbol or an expression and their
referent is made painfully clear, perhaps except for when one hacks with
macros.)

the examples above illustrate the notorious problem with r that one can
never tell whether 'a' means "the value referred to with the identifier
'a'" or "the symbol 'a'", unless one gets ugly surprises and is forced
to study the documentation.  and even then one may not get a clear answer.

the example given by the confused user is a red flag warning.  it's a
typical abstraction where a nested sequence of operations (here print
over names over subset) is abstracted into a single procedure, which can
be called with whatever arguments are valid:

pns = function(d, g) print(names(subset(d, select=g)))

what sane person, without carefully studying the gory details of subset,
will ever expect that if the first argument happens to have a column
named 'g', only this one will be selected, while if it doesn't, subset
will select the columns named by the components of what 'g' evaluates
to.  i wonder how many users have *not* noticed that what they get is
not what they assume they get because of such tricky tricks, and in
consequence were not able to publish their analyses (or worse, have
published them). 

what is scary is that this may happen with about any other function in
r, because the design is pervasive.  no one should ever use any r
function without first carefully reading the docs (which is not
guaranteed to help) or trying it first on a number of carefully crafted
test cases.  if such care is not taken, results obtained with r cannot
be taken seriously.


vQ


Gabor Grothendieck wrote:
> Forgot the name part.  Try:
>
> TestFunc2 <- function(DF, group) names(DF[group])
> TestFunc3 <- function(...) names(subset(..., subset = TRUE))
> TestFunc4 <- function(...) eval.parent(names(subset(..., subset = TRUE)))
>
> # e.g.
> df1 <- data.frame(group = "G1", visit = "V1", value = 0.9)
> TestFunc2(df1, c("group", "visit"))
> TestFunc3(df1, c("group", "visit"))
> TestFunc4(df1, c("group", "visit"))
> TestFunc4(df1, c(group, visit)) # this works too
>
> On Mon, Nov 10, 2008 at 10:43 AM, Gabor Grothendieck
> <[EMAIL PROTECTED]> wrote:
>   
>> Here are a few things to try:
>>
>> TestFunc1 <- get("[")
>>
>> TestFunc2 <- function(DF, group) DF[group]
>>
>> TestFunc3 <- function(...) subset(..., subset = TRUE)
>>
>>
>>
>> On Mon, Nov 10, 2008 at 10:18 AM, Karl Knoblick <[EMAIL PROTECTED]> wrote:
>> 
>>> Hello!
>>>
>>> I have the problem that in my function the passed variable is not used, but 
>>> the variable name of the dataframe itself - difficult to explain, but an 
>>> easy example:
>>>
>>> TestFunc<-function(df, group) {
>>> print(names(subset(df, select=group)))
>>> }
>>> df1<-data.frame(group="G1", visit="V1", value=0.9)
>>> TestFunc(df1, c("group", "visit"))
>>>
>>> Result:
>>> [1] "group"
>>>
>>> But I expected and want to have [1] "group" "visit" as result! Does anybody 
>>> know how to get this result?
>>>
>>> Thanks!
>>> Karl
>>>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read SAS file

2008-11-10 Thread David Huffer
Do you have the foreign package loaded? 

--
 David

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read SAS file

2008-11-10 Thread Richardson, Patrick
Did you load the "foreign" library first?

Try:

library(foreign)
read.xport("cft2008R")

HTH,

Patrick


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of b g
Sent: Monday, November 10, 2008 1:29 PM
To: r-help@r-project.org
Subject: [R] read SAS file


Looked at a lot of documentation and listserv postings and still can't solve 
this problem.  I need to get a SAS dataset into R.  I've converted it to an 
.xpt file and when I try to read it I get:

> read.xport("cft2008R")
Error: could not find function "read.xport"
>

Not sure what I'm doing wrong.  I'm running SAS 9.1.3 on an UNIX box.  I ftp'd 
the file over to my C:\Program Files\R\R-2.8.0\ directory on my local machine 
running WinXP.  Suggestions appreciated.
_

l.

ty_112008
[[alternative HTML version deleted]]

This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] read SAS file

2008-11-10 Thread b g

Looked at a lot of documentation and listserv postings and still can’t solve 
this problem.  I need to get a SAS dataset into R.  I’ve converted it to an 
.xpt file and when I try to read it I get:
 
> read.xport("cft2008R")
Error: could not find function "read.xport"
> 
 
Not sure what I’m doing wrong.  I’m running SAS 9.1.3 on an UNIX box.  I ftp’d 
the file over to my C:\Program Files\R\R-2.8.0\ directory on my local machine 
running WinXP.  Suggestions appreciated.
_

l.

ty_112008
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Combing xyplot and curve() plot via print

2008-11-10 Thread Greg Snow
The xyplot function is a lattice function that uses grid graphics.  The curve 
function is a base graphics function.  'par' and 'layout' work with base 
graphics, the print idea works with grid graphics.  Grid graphics and base 
graphics don't mix easily.  One option is to find a grid/lattice/ggplot2 
alternative of the curve function so that you are using all grid graphics, or 
you can use base graphics to recreate the xyplot in base.  There is also the 
gridBase package that makes combining the 2 systems easier (but still not 
simple).

Hope this helps,

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


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Afshartous, David
> Sent: Monday, November 10, 2008 8:51 AM
> To: r-help@r-project.org
> Subject: [R] Combing xyplot and curve() plot via print
>
> All,
>
> I'm trying to put an xyplot and a plot produced via curve() on the same
> page.  It seems that mfrow and layout don't work, and now I'm trying
> print
> but that does not work either.  Any suggestions much appreciated.
>
> Cheers,
> David
>
> p.11 = xyplot(1:10 ~ 1:10)
>
> curve(sin, 0,3, ylim=c(-3,3), ylab="sin and cos",  lty = 1)
> curve(cos, 0,3,  ylim=c(-3,3), lty = 5, add=TRUE)
> legend(2,2, legend = "legend here")
> p.12 = recordPlot()
>
> print(p.11, split = c(1,1, 2,1), more = T)
> print(p.12, split=c(2,1,2,1), more = T  )
>
>
>
>
>
> > sessionInfo()
> R version 2.7.1 (2008-06-23)
> i386-apple-darwin8.10.1
>
> locale:
> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] lattice_0.17-8
>
> loaded via a namespace (and not attached):
> [1] Matrix_0.999375-11 grid_2.7.1 lme4_0.999375-24   nlme_3.1-
> 89
> >
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re : Regarding lme functions

2008-11-10 Thread ratna ghosal
If I give the following command:
 
myfit<-lme(...)
intervals(myfit)
 then its returning the following error
 
"Cannot get confidence intervals on var-cov components:Non-positive definite 
approximate variance-covariance"
 
I would like to extract the confidence interval for the fixed effects..so 
which command to use???
 
Ratna


 
Ratna Ghosal
Research Scholar
Centre for Ecological Sciences
Indian Institute of Sciences
Bangalore-12

--- On Mon, 10/11/08, justin bem <[EMAIL PROTECTED]> wrote:

From: justin bem <[EMAIL PROTECTED]>
Subject: Re : [R] Regarding lme functions
To: [EMAIL PROTECTED]
Cc: "R Maillist" <[EMAIL PROTECTED]>
Date: Monday, 10 November, 2008, 10:35 PM





in nlme package you the intervals function.

myfit<-lme(...)
intervals(myfit)


 Justin BEM
BP 1917 Yaoundé
Tél (237) 99597295
(237) 22040246






De : ratna ghosal <[EMAIL PROTECTED]>
À : r-help@r-project.org
Envoyé le : Lundi, 10 Novembre 2008, 17h51mn 51s
Objet : [R] Regarding lme functions

Hi all,

I recently got accquainted with the R stats and using the 'lme' function
for some of my analyses. Since I am a novice, I am facing a lot of
problems regarding the analyses. 

I have applied the Linear Mixed Effect model for my dataset and would like
to know the commands for extracting the confidence interval for the fixed
effect. 
 
Also would like to request if you can kindly guide me the command
for plotting the observed value vs the value predicted from the mixed
effect model.

Thanking you

Regards

Ratna




Ratna Ghosal
Research Scholar
Centre for Ecological Sciences
Indian Institute of Sciences
Bangalore-12

--- On Mon, 10/11/08, John Poulsen <[EMAIL PROTECTED]> wrote:

From: John Poulsen <[EMAIL PROTECTED]>
Subject: [R] Labeling points with xYplot
To: r-help@r-project.org
Date: Monday, 10 November, 2008, 9:56 PM

Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but then I
lose the error bars.  I suspect that I should be using panel.xYplot rather than
panel.xyplot, but that didn't work either...

Can anybody help me out?  Example code is below.  First xYplot has error bars,
second tries to label the points and the bars disappear.

Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
      ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
      panel=function(x,y,...){
        panel.xyplot(x,y,...)
        ltext(x=list(1,2,3,4),
              y=list(13,14,15,16),
              
labels=list("A","B","C","D"), pos=2)})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



      Share files, take polls, and make new friends - all under one roof. G
    [[alternative HTML version deleted]]





  Add more friends to your messenger and enjoy! Go to 
http://messenger.yahoo.com/invite/
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re : Regarding lme functions

2008-11-10 Thread ratna ghosal
Hi,
 
Thanks
 
But then how to interpret the rows and columns
 
Ratna


Ratna Ghosal
Research Scholar
Centre for Ecological Sciences
Indian Institute of Sciences
Bangalore-12

--- On Mon, 10/11/08, justin bem <[EMAIL PROTECTED]> wrote:

From: justin bem <[EMAIL PROTECTED]>
Subject: Re : [R] Regarding lme functions
To: [EMAIL PROTECTED]
Cc: "R Maillist" <[EMAIL PROTECTED]>
Date: Monday, 10 November, 2008, 10:35 PM





in nlme package you the intervals function.

myfit<-lme(...)
intervals(myfit)


 Justin BEM
BP 1917 Yaoundé
Tél (237) 99597295
(237) 22040246






De : ratna ghosal <[EMAIL PROTECTED]>
À : r-help@r-project.org
Envoyé le : Lundi, 10 Novembre 2008, 17h51mn 51s
Objet : [R] Regarding lme functions

Hi all,

I recently got accquainted with the R stats and using the 'lme' function
for some of my analyses. Since I am a novice, I am facing a lot of
problems regarding the analyses. 

I have applied the Linear Mixed Effect model for my dataset and would like
to know the commands for extracting the confidence interval for the fixed
effect. 
 
Also would like to request if you can kindly guide me the command
for plotting the observed value vs the value predicted from the mixed
effect model.

Thanking you

Regards

Ratna




Ratna Ghosal
Research Scholar
Centre for Ecological Sciences
Indian Institute of Sciences
Bangalore-12

--- On Mon, 10/11/08, John Poulsen <[EMAIL PROTECTED]> wrote:

From: John Poulsen <[EMAIL PROTECTED]>
Subject: [R] Labeling points with xYplot
To: r-help@r-project.org
Date: Monday, 10 November, 2008, 9:56 PM

Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but then I
lose the error bars.  I suspect that I should be using panel.xYplot rather than
panel.xyplot, but that didn't work either...

Can anybody help me out?  Example code is below.  First xYplot has error bars,
second tries to label the points and the bars disappear.

Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
      ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
      panel=function(x,y,...){
        panel.xyplot(x,y,...)
        ltext(x=list(1,2,3,4),
              y=list(13,14,15,16),
              
labels=list("A","B","C","D"), pos=2)})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



      Share files, take polls, and make new friends - all under one roof. G
    [[alternative HTML version deleted]]





  Be the first one to try the new Messenger 9 Beta! Go to 
http://in.messenger.yahoo.com/win/
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] comparing rows

2008-11-10 Thread markleeds
hi chris: i'm betting  that there is a better/shorter more R'ish way to 
do it ( if someone could provide that, it's appreciated ) but below will 
get the output in the format you need. the all function tests whether 
all the elements are equal so you don't need setequal although i guess 
it's a matter of taste ?


as.vector((t(sapply(1:nrow(testmat1),function(.rowindex1) {
  sapply(1:nrow(testmat2), function(.rowindex2) {
 all(testmat2[.rowindex2,] == testmat1[.rowindex1,])
   })
}))
))


#===

Hello R-users,

I have a little problem.

I compare each row of a matrix with each row of another matrix.

testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)

print(testmat1)
print(testmat2)

Both matrix differs in the last row.

Now I create a loop:

for (i in (1:4)){
for (j in (1:4)){
b <- (c(setequal(testmat1[j,],testmat2[i,])))
print(b)
}
}

R outputs me the following:

[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE

but I need one vector like this:

[1] TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE
FALSE FALSE FALSE FALSE


as.vector((t(sapply(1:nrow(testmat1),function(.rowindex1) {
  sapply(1:nrow(testmat2), function(.rowindex2) {
 all(testmat2[.rowindex2,] == testmat1[.rowindex1,])
   })
}))
))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Re : Regarding lme functions

2008-11-10 Thread justin bem
in nlme package you the intervals function.

myfit<-lme(...)
intervals(myfit)


 Justin BEM
BP 1917 Yaoundé
Tél (237) 99597295
(237) 22040246





De : ratna ghosal <[EMAIL PROTECTED]>
À : r-help@r-project.org
Envoyé le : Lundi, 10 Novembre 2008, 17h51mn 51s
Objet : [R] Regarding lme functions

Hi all,

I recently got accquainted with the R stats and using the 'lme' function
for some of my analyses. Since I am a novice, I am facing a lot of
problems regarding the analyses. 

I have applied the Linear Mixed Effect model for my dataset and would like
to know the commands for extracting the confidence interval for the fixed
effect. 

Also would like to request if you can kindly guide me the command
for plotting the observed value vs the value predicted from the mixed
effect model.

Thanking you

Regards

Ratna




Ratna Ghosal
Research Scholar
Centre for Ecological Sciences
Indian Institute of Sciences
Bangalore-12

--- On Mon, 10/11/08, John Poulsen <[EMAIL PROTECTED]> wrote:

From: John Poulsen <[EMAIL PROTECTED]>
Subject: [R] Labeling points with xYplot
To: r-help@r-project.org
Date: Monday, 10 November, 2008, 9:56 PM

Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but then I
lose the error bars.  I suspect that I should be using panel.xYplot rather than
panel.xyplot, but that didn't work either...

Can anybody help me out?  Example code is below.  First xYplot has error bars,
second tries to label the points and the bars disappear.

Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
   ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
   panel=function(x,y,...){
 panel.xyplot(x,y,...)
 ltext(x=list(1,2,3,4),
   y=list(13,14,15,16),
  
labels=list("A","B","C","D"), pos=2)})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



  Share files, take polls, and make new friends - all under one roof. G
[[alternative HTML version deleted]]


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Regarding lme functions

2008-11-10 Thread ratna ghosal
Hi all,

I recently got accquainted with the R stats and using the 'lme' function
for some of my analyses. Since I am a novice, I am facing a lot of
problems regarding the analyses. 

I have applied the Linear Mixed Effect model for my dataset and would like
to know the commands for extracting the confidence interval for the fixed
effect. 
 
Also would like to request if you can kindly guide me the command
for plotting the observed value vs the value predicted from the mixed
effect model.

Thanking you

Regards

Ratna




Ratna Ghosal
Research Scholar
Centre for Ecological Sciences
Indian Institute of Sciences
Bangalore-12

--- On Mon, 10/11/08, John Poulsen <[EMAIL PROTECTED]> wrote:

From: John Poulsen <[EMAIL PROTECTED]>
Subject: [R] Labeling points with xYplot
To: r-help@r-project.org
Date: Monday, 10 November, 2008, 9:56 PM

Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but then I
lose the error bars.  I suspect that I should be using panel.xYplot rather than
panel.xyplot, but that didn't work either...

Can anybody help me out?  Example code is below.  First xYplot has error bars,
second tries to label the points and the bars disappear.

Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
   ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
   panel=function(x,y,...){
 panel.xyplot(x,y,...)
 ltext(x=list(1,2,3,4),
   y=list(13,14,15,16),
  
labels=list("A","B","C","D"), pos=2)})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



  Share files, take polls, and make new friends - all under one roof. G
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] question about the "Y of R" article in the latest R news

2008-11-10 Thread Mark Kimpel
Thanks, I appreciate both your comments and those of Gabor. For what its
worth, after Gabor's clarification I checked the performance of Recall and
found it to be intermediate between the base recursion example (function
's') and those of the 'Y of R' approach. As a teaching example, however, the
'Y of R' approach would seem to be a very nice approach to dissect. In my
day to day work I don't often see functions used as arguments, so this is
stretching me a bit in a positive way.

Thanks so much for your contributions to the R project and to R News,

Mark

Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work, & Mobile & VoiceMail
(317) 399-1219  Home
Skype:  mkimpel

"The real problem is not whether machines think but whether men do." -- B.
F. Skinner
**


On Sun, Nov 9, 2008 at 3:59 PM, Vincent Carey 525-2265 <
[EMAIL PROTECTED]> wrote:

> On Sat, 8 Nov 2008, Mark Kimpel wrote:
>
> > I found the article the "Y of R" in the latest R news to be very
> > interesting. It is certainly challenging me to learn more about how R
> works
> > "under the hood" as the author states. What is less clear to me is
> whether
> > this approach is primarily for teaching purposes or has a real world
> > application. What is meant by "fragility of reliance on the function
> > name defined as a global variable" as a downside to the classical
> recursive
> > formulation of function "s"? How can that impact the average R
> programmer?
> >
> > Beyond that, empiricist that I am, I decided to put the examples to the
> > test. My source code and output is below, but the bottom line consists of
> 2
> > observations:
> >
> >- The Y function approach using csum is consistently slower on my
> machine
> >that the s function approach
> >- The Y function using csum gives recursive error with high input
> values
> >just like the s function does
> >- The Y function in fact reaches the limit of recursion BEFORE the s
> >function does
> >
> > Given that it is slower, is more cumbersome to write, and has a lower
> > nesting limit than the classical approach, I wonder about its utility for
> > the average programmer (or somewhat below average programmer like me).
> >
>
> Thanks for your comments and to Gabor for some clarification.  Your
> empirical study adds to our knowledge of the situation.  I considered
> the implementation of Y in R to be of conceptual interest only, and I
> probably should have said that.  Even the conceptual considerations
> may admit of improvement, as there are use-mention distinctions that are
> murky in various points in the text.  But I will not be able to revisit
> this, apart from dealing with major misconceptions if such exist, in the
> foreseable future.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Labeling points with xYplot

2008-11-10 Thread John Poulsen

Hello R-Users,

I am trying to label points on an xYplot.  I can label the points, but 
then I lose the error bars.  I suspect that I should be using 
panel.xYplot rather than panel.xyplot, but that didn't work either...


Can anybody help me out?  Example code is below.  First xYplot has error 
bars, second tries to label the points and the bars disappear.


Thanks,
John


a=c(1:4)
b=rnorm(4,15,5)
blab=b+1

xYplot(Cbind(b, b-1.5, b+1.5)~a,
   ylim=c(0,max(b)+3))

xYplot(Cbind(b, b-1.5, b+1.5)~a, ylim=c(0,max(b)+3),
   panel=function(x,y,...){
 panel.xyplot(x,y,...)
 ltext(x=list(1,2,3,4),
   y=list(13,14,15,16),
   labels=list("A","B","C","D"), pos=2)})

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Duncan Murdoch

On 11/10/2008 10:18 AM, Karl Knoblick wrote:

Hello!

I have the problem that in my function the passed variable is not used, but the 
variable name of the dataframe itself - difficult to explain, but an easy 
example:

TestFunc<-function(df, group) {
print(names(subset(df, select=group)))
}
df1<-data.frame(group="G1", visit="V1", value=0.9)
TestFunc(df1, c("group", "visit"))

Result:
[1] "group"
 
But I expected and want to have [1] "group" "visit" as result! Does anybody know how to get this result?


Don't use subset.  You can get what you want using


print(names(df[,group]))

Or alternatively, you can force group to be found in the right place in 
this way:


e <- environment()
print(names(subset(df, select=e$group)))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Get Information

2008-11-10 Thread Greg Snow
Your code creates the menu that will run the cascade function.  The cascade 
function gets a name from the user to save, but you don't do anything with the 
name other than return it, and the code that calls cascade does nothing with 
the return value.  If you want the text in the text window saved, then you will 
need to add that functionality to the cascade function, first you will need to 
extract the text from the text widget, then using R commands and the filename 
you can save the information (see the cat command for one way of doing this).

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


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of justin Kameni
> Sent: Saturday, November 08, 2008 12:39 PM
> To: r-help@r-project.org
> Cc: [EMAIL PROTECTED]
> Subject: [R] Get Information
>
> I am a new commer in R. I am using the library tcltk, i need few
> information about it.
> so that, i wrote the following programme to save the file, but when i
> save the file, i do not find the file save, please help me, in order to
> continue my projet.
> this is the programme:
>
> tt  <- tktoplevel()
> txt <- tktext(tt)
> tkwm.title(tt,"Saisi des modalités") #intitule la fenêtre
> tkgrid(txt)
> tkmark.set(txt,"insert","0.0")
> topMenu <- tkmenu(tt)
> tkconfigure(tt,menu=topMenu)
> cascade =function ()
> {fileName=tclvalue(tkgetSaveFile(initialfile="modalite.txt",filetypes="
> {{JPEG Files} {.jpg .jpeg}} {{PDF File} {.pdf}} {{Text File} {.txt}}
> {{All files} *}"))
>   return(fileName)
>   }
> tkadd(topMenu,"command",label="Enregistrer",command=function ()
> cascade()) Please correct the programme i send it back. Please, i need
> the correction to continue my projet.
> Thanks in advance.
>
>
>  Ing KAMENI Justin
> Etudiant en Master en Statistique
> Option: Econométrie,
> Assurance et Finance
> Data Management et Data Mining
> Gsm: 0032487710413
> Route de Blocry 29/003
>
>
>
>
> [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R 2.8. and languageR

2008-11-10 Thread Ben Bolker
Audrey Bürki Foschini  pse.unige.ch> writes:

> I now would like to use new functions of this library (especially  
> plotLMER.fnc) and have downloaded R 2.8.0.
> 
> Error messages appear when I load the languageR library (I have tried  
> several times on different computers but this doesn't help.:
> Attachement du package : 'Matrix'
[snip]
> 
> I guess this is the reason why I cannot use the lmer function with  
> this version of R.
> 


  These are warnings, not errors.
  Are you sure you are actually unable to use lmer, or are
you just being scared off by the warning messages?
Try typing sessionInfo() after you get the messages and
see whether Matrix, lme4, and languageR are in your
list of loaded packages.

  good luck
Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Combing xyplot and curve() plot via print

2008-11-10 Thread Afshartous, David
All,

I'm trying to put an xyplot and a plot produced via curve() on the same
page.  It seems that mfrow and layout don't work, and now I'm trying print
but that does not work either.  Any suggestions much appreciated.

Cheers,
David

p.11 = xyplot(1:10 ~ 1:10)

curve(sin, 0,3, ylim=c(-3,3), ylab="sin and cos",  lty = 1)
curve(cos, 0,3,  ylim=c(-3,3), lty = 5, add=TRUE)
legend(2,2, legend = "legend here")
p.12 = recordPlot()

print(p.11, split = c(1,1, 2,1), more = T)
print(p.12, split=c(2,1,2,1), more = T  )





> sessionInfo()
R version 2.7.1 (2008-06-23)
i386-apple-darwin8.10.1

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] lattice_0.17-8

loaded via a namespace (and not attached):
[1] Matrix_0.999375-11 grid_2.7.1 lme4_0.999375-24   nlme_3.1-89
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
Here are a few things to try:

TestFunc1 <- get("[")

TestFunc2 <- function(DF, group) DF[group]

TestFunc3 <- function(...) subset(..., subset = TRUE)



On Mon, Nov 10, 2008 at 10:18 AM, Karl Knoblick <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I have the problem that in my function the passed variable is not used, but 
> the variable name of the dataframe itself - difficult to explain, but an easy 
> example:
>
> TestFunc<-function(df, group) {
> print(names(subset(df, select=group)))
> }
> df1<-data.frame(group="G1", visit="V1", value=0.9)
> TestFunc(df1, c("group", "visit"))
>
> Result:
> [1] "group"
>
> But I expected and want to have [1] "group" "visit" as result! Does anybody 
> know how to get this result?
>
> Thanks!
> Karl
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Make one vector from matrix comparison

2008-11-10 Thread Jorge Ivan Velez
Hi Chris82,
Yes. Try this:

testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)

b=NULL
for (i in 1:4){
for (j in 1:4){
b <- c(b,setequal(testmat1[j,],testmat2[i,]))
b
}
}

b

HTH,

Jorge




On Mon, Nov 10, 2008 at 10:11 AM, Chris82 <[EMAIL PROTECTED]> wrote:

>
> Hello R-users,
>
> I have a little problem.
>
> I compare each row of a matrix with each row of another matrix.
>
> testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
> testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
>
> Both matrix differs in the last row.
>
> Now I create a loop:
>
> for (i in (1:4)){
> for (j in (1:4)){
> b <- (c(setequal(testmat1[j,],testmat2[i,])))
> print(b)
> }
> }
>
> R outputs me the following:
>
> [1] TRUE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] TRUE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] TRUE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
>
> but I need one vector like this:
>
> [1] TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE
> FALSE FALSE FALSE FALSE
>
> Any ideas?
>
> thanks
> --
> View this message in context:
> http://www.nabble.com/Make-one-vector-from-matrix-comparison-tp20421761p20421761.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Henrique Dallazuanna
Try this:

TestFunc<-function(df, group) {
return(names(eval(bquote(subset(df1, select = .(group))
}

On Mon, Nov 10, 2008 at 1:18 PM, Karl Knoblick <[EMAIL PROTECTED]>wrote:

> Hello!
>
> I have the problem that in my function the passed variable is not used, but
> the variable name of the dataframe itself - difficult to explain, but an
> easy example:
>
> TestFunc<-function(df, group) {
> print(names(subset(df, select=group)))
> }
> df1<-data.frame(group="G1", visit="V1", value=0.9)
> TestFunc(df1, c("group", "visit"))
>
> Result:
> [1] "group"
>
> But I expected and want to have [1] "group" "visit" as result! Does anybody
> know how to get this result?
>
> Thanks!
> Karl
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] SNPassoc, mvtnorm, Absoft FORTRAN to gfortran

2008-11-10 Thread Kacper Zukowski
Hi,

I'm using R version 2.6.2 (2008-02-08) and also Absoft Fortran Compiler. I try 
to install SNPassoc package on SUSE 10.2 but it's require mvtnorm package...

* Installing *source* package 'mvtnorm' ...
** libs
gcc -std=gnu99 -I/usr/lib64/R/include -I/usr/lib64/R/include  
-I/usr/local/include-fpic  -g -O2 -c miwa.c -o miwa.o
gfortran   -fpic  -g -O2 -c mvt.f -o mvt.o
make: gfortran: Command not found
make: *** [mvt.o] Error 127
ERROR: compilation failed for package 'mvtnorm'

I used Absoft Fortran Compiler is is any possibility to install this package 
without gfortran?? How I could to this??

Sincerely, 
Kacper



Kacper Żukowski
PhD student
Institute of Animal Genetics
Wroclaw University of Life Sciences


mail: Kozuchowska 7, 
PL-51631 Wroclaw, Poland
e-mail: [EMAIL PROTECTED]
www: http://gen.ar.wroc.pl/theta/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R 2.8. and languageR

2008-11-10 Thread Audrey Bürki Foschini

Hi,

I have been using the library languageR in R2.6.0 for some while.

I now would like to use new functions of this library (especially  
plotLMER.fnc) and have downloaded R 2.8.0.


Error messages appear when I load the languageR library (I have tried  
several times on different computers but this doesn't help.:

Attachement du package : 'Matrix'


The following object(s) are masked from package:stats :

 xtabs


The following object(s) are masked from package:base :

 colMeans,
 colSums,
 rcond,
 rowMeans,
 rowSums



I guess this is the reason why I cannot use the lmer function with  
this version of R.


I would be very grateful if anyone could help on this.


Audrey Burki

--
Assistante-Doctorante
Laboratoire de Psycholinguistique Expérimentale
FAPSE Université de Genève
40, Bd Pont d'Arve
1201 Genève
(0041) 22 379 91 45
http://www.unige.ch/fapse/PSY/persons/frauenfelder/audrey/audrey.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Karl Knoblick
Hello!

I have the problem that in my function the passed variable is not used, but the 
variable name of the dataframe itself - difficult to explain, but an easy 
example:

TestFunc<-function(df, group) {
    print(names(subset(df, select=group)))
}
df1<-data.frame(group="G1", visit="V1", value=0.9)
TestFunc(df1, c("group", "visit"))

Result:
[1] "group"
 
But I expected and want to have [1] "group" "visit" as result! Does anybody 
know how to get this result?

Thanks!
Karl




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Make one vector from matrix comparison

2008-11-10 Thread Chris82

Hello R-users,

I have a little problem.

I compare each row of a matrix with each row of another matrix.

testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)

Both matrix differs in the last row.

Now I create a loop:

for (i in (1:4)){
for (j in (1:4)){
b <- (c(setequal(testmat1[j,],testmat2[i,])))
print(b)
}
}

R outputs me the following:

[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] TRUE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE

but I need one vector like this:

[1] TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE
FALSE FALSE FALSE FALSE

Any ideas?

thanks
-- 
View this message in context: 
http://www.nabble.com/Make-one-vector-from-matrix-comparison-tp20421761p20421761.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] coxph diagnostics plot for shape of hazard function?

2008-11-10 Thread Eric Rescorla
Hi,

I've been banging my head against the following problem for a while
and thought the fine people on r-help might be able to help. I'm
using the survival package.

I'm studying the survival rate of a population with a preexisting
linear-like event rate (there are theoretical reasons to believe
it's linear, but of course it's subject to the usual sampling noise)

Some of the population exhibit predictor
X and some don't [I'm not trying to be cagey about the setting
here, it's just complicated to explain and I'm trying to keep my
message short.] When I plot the survival curves, there's a qualitatively
significant difference and this is confirmed by survdiff.

When I run cox.zph, however, it's pretty clear that the proportional
hazards assumption isn't satisfied:

> zph <- cox.zph(cox)
> zph
 rho chisqp
Initially.Vulnerable -0.0476  32.5 1.19e-08
>

Similarly, when I do plot(zph), B(t) is fairly non-constant.

This isn't inherently a problem for me. I don't need a hard single number
to characterize the shape of the excess risk. However, I'd like to be
able to say
something qualitative about the shape of the excess risk for the predictor.
E.g., is it linear, monotonically increasing, monotonially decreasing, etc.
Is it safe to use the coxph diagnostic plot for this purpose?

I did try heuristically subtracting out the background and then fitting a spline
using locfit as described in the MASS supplement, but this seemed a little more
ad hoc than I was hoping for something more principled.

Thanks in advance.

-Ekr

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ubuntu system refuses to update packages

2008-11-10 Thread Vincent Goulet

Le lun. 10 nov. à 00:45, Leon Yee a écrit :


Dirk Eddelbuettel wrote:

On 9 November 2008 at 20:35, Alan Jackson wrote:
| There must be a simple answer to this.
| | I'm running ubuntu gutsy, currently have 2.7.2 loaded, but the  
update
| tools refuse to update it, and don't tell me why. With apt-get I  
get :

| | [668 ~]$ sudo apt-get -u -V --simulate dist-upgrade
| Reading package lists... Done
| Building dependency tree   | Reading state information... Done
| Calculating upgrade... Done
| The following packages have been kept back:
|r-base (2.7.2-1gutsy0 => 2.8.0-1gutsy1)
|r-base-core (2.7.2-1gutsy0 => 2.8.0-1gutsy1)
|r-base-dev (2.7.2-1gutsy0 => 2.8.0-1gutsy1)
|r-cran-rpart (3.1.41-1gutsy0 => 3.1.42-1gutsy0)
|r-recommended (2.7.2-1gutsy0 => 2.8.0-1gutsy1)
| 0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
| | If I use a gui package manager, it tells me the update will break
| the installation and refuses to go forward, but doesn't show what  
the

| issue is.
In cases like this just take the set of packages and pass them  
directly to

'sudo apt-get install' ie
  $ sudo apt-get install r-base r-base-core r-base-dev r-cran-rpart  
r-recommended
which will show which packages this will install (as new), upgrade,  
or

remove, if any.  It still allows you to pack out if you so choose.
In this case it is probably 'just' a fortran or c++ library  
transition.  If
you are still running gutsy you are also now two Ubuntu releases  
behind so

you may want to consider upgrading to hardy and/or intrepid.
By the way, this would have a good question for the r-sig-debian  
list.

Hth, Dirk


Hi,

  I encountered similar problems:

apt-get install r-base-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.

Since you only requested a single operation it is extremely likely  
that

the package is simply not installable and a bug report against
that package should be filed.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 r-base-core: Depends: tcl8.5 (>= 8.5.0) but it is not installable
  Depends: tk8.5 (>= 8.5.0) but it is not installable
E: Broken packages

/etc/apt/sources.list

deb http://mirror.optus.net/ubuntu/ gutsy-security main restricted  
universe multiverse
deb-src http://mirror.optus.net/ubuntu/ gutsy-security restricted  
main multiverse universe


deb http://mirror.optus.net/ubuntu/ gutsy universe main
deb-src http://mirror.optus.net/ubuntu/ gutsy universe main
deb http://mirror.optus.net/ubuntu/ gutsy-updates universe main
deb-src http://mirror.optus.net/ubuntu/ gutsy-updates universe main

deb http://cran.ms.unimelb.edu.au/bin/linux/ubuntu gutsy/

deb http://security.ubuntu.com/ubuntu/ gutsy-security universe main
deb-src http://security.ubuntu.com/ubuntu/ gutsy-security universe  
main



It seems that R2.8.0 for gutsy is built on a system with tcl8.5 and  
tk8.5, which is not available in gutsy?


From the CRAN Ubuntu README:

>>>
Installation and compilation of R or some its packages may require  
Ubuntu packages from the "backports" repositories. In particular, this  
is the case for Tcl/Tk 8.5 on Gutsy and Hardy. Therefore, it is  
suggested to activate the backports repositories with an entry like


deb http:/// hardy-backports main  
restricted universe


in your /etc/apt/sources.list file. See http://www.ubuntu.com/getubuntu/downloadmirrors 
 for the list of Ubuntu mirrors.

<<<

Vincent





Best wishes,
Leon

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Postdoc Positions Available at Leiden University The Netherlands

2008-11-10 Thread beukerspkpd
 

Two Postdoctoral fellows (fulltime) 

Leiden University, Leiden, The Netherlands



 

Job description 



TOP Institute Pharma (TI Pharma) has granted our proposal to set up a
mechanism-based PK-PD modelling platform. This platform focuses on the
transfer of knowledge from academia to the pharmaceutical industry and
is a collaborative effort of four academic partners and six industrial
partners. Unique to this platform is the availability of shared
databases on disease and drug related parameters.



The aim of the platform is to provide a scientific basis for rational
drug discovery and development with a strong focus on priority
medicines. Challenges are 1) to develop mechanism-based PKPD models to
characterise disease progression and to predict the effects of ageing on
clinical response and 2) to create a translational research framework
that allows extrapolation of preclinical to clinical and epidemiological
findings. Existing (pre-) clinical data will be analysed with advanced
data analysis software tools such as NONMEM and R.



We are looking for two highly motivated scientists (PhD degree) to:

1) investigate disease models in COPD. The COPD project is part
of the disease progression working group which consist of two PhD
students and two post-doctoral research fellows. 

2) evaluate the "operational" efficacy of drugs that have been
identified to produce QTc-interval prolongation in early clinical
development. The translational research working group will focus on
cardiovascular safety, schizophrenia and neuropathic pain. This working
group consists in total of six PhD students and two post-doctoral
fellows. 



Requirements 



The post-doctoral fellows should have the following background and
competencies:



*   A strong background in modelling & simulation and/or
Bayesian statistics 

*   A degree in Biostatistics, Medicine, Bioengineering,
Biopharmaceutical Sciences, Physiology or equivalent scientific training

*   Conceptual thinker

*   Problem-solving and coaching skills are essential

*   Ambitious

*   Creative

*   Interested to perform research in a unique multidisciplinary
setting



Organisation 



The Leiden Division of Pharmacology at the Leiden/Amsterdam Center for
Drug Research (LACDR) has a long-standing expertise in the development
of Pharmacokinetic/Pharmacodynamic (PKPD) models to predict efficacy and
safety of drugs. Given the nature of the disease, understanding of
statistical methodology (principal component analysis, multivariate
analysis, longitudinal and hierarchical models) is required for the
postdoc working on the COPD project. Knowledge of Bayesian concepts is
highly desirable. The main task of the post-doctoral fellow working on
the cardiovascular project will be to coach the PhD students, support
model building and simulation. Furthermore, he /she will be responsible
for the development of an overarching approach to link findings in early
and late clinical development.





Conditions of employment 



The employment for this position will be full time for at least 3 years.



Additional conditions of employment:

You will work as a team member of a TI Pharma project. The project team
comprises academic and industrial partners. In this case, the partners
are: universities of Leiden and Groningen, the University Medical Center
of Utrecht, the Erasmus Medical Center and the companies Eli Lilly,
Johnson & Johnson, GSK, Nycomed, Pfizer and Schering-Plough. You will
attend a unique drug discovery education and training program offered by
TI Pharma.

Additional Information 



For instance:



Additional information can be obtained through one of the following
links: 

http://www.lacdr.nl

Application You can apply by
sending your application to:

Contact person

Dr. O. Della Pasqua

Division of Pharmacology, Leiden/Amsterdam Center for Drug Research

Leiden, The Netherlands

[EMAIL PROTECTED] 

+44 7876031907




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Odp: how to sample a block

2008-11-10 Thread Petr PIKAL
Peter Dalgaard <[EMAIL PROTECTED]> napsal dne 10.11.2008 14:05:41:

> Petr PIKAL wrote:
> > Hi
> > 
> > [EMAIL PROTECTED] napsal dne 10.11.2008 13:25:41:
> > 
> >> Hi,
> >> I want to sample a block of information.
> >>
> >> Let's say x is a time series. Using sample(x,5) I get a random sample 
of
> >> length 5 from x.
> >>
> >> Is it possible to sample consecutive observations, i.e. I sample one
> >> observation and also get the next 4 observations?
> > 
> > Easy
> > 
> > sam <-  sample(x,1)
> > x[sam:(sam+4)]
> 
> 
> You mean
> 
> sam <-  sample(seq_along(x),1)
> x[sam:(sam+4)]

Yes, I meant it. Without an example I set my x series as 1:100 so it was 
in seq order and no need to use seq_along.

Petr

> 
> I think this answers the question as posed, but possibly not as meant.
> 
> You might have
> 
> block <- seq_along(x) %/% 5
> 
> and want to an entire block. This is a little more tricky:
> 
> bl <- sample(unique(block),1)
> x[block==bl]
> 
> It gets even trickier if you want to vectorize sampling of multiple 
> blocks, but let's leave that for now.
> 
> > Regards
> > Petr
> > 
> > 
> > 
> >> Thanks a lot!
> >>
> >> Martin
> >> -- 
> >> View this message in context: 
> > http://www.nabble.com/how-to-sample-a-block-
> >> tp20418997p20418997.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> > http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> 
> -- 
> O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>   (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 
35327918
> ~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Odp: how to sample a block

2008-11-10 Thread Peter Dalgaard

Petr PIKAL wrote:

Hi

[EMAIL PROTECTED] napsal dne 10.11.2008 13:25:41:


Hi,
I want to sample a block of information.

Let's say x is a time series. Using sample(x,5) I get a random sample of
length 5 from x.

Is it possible to sample consecutive observations, i.e. I sample one
observation and also get the next 4 observations?


Easy

sam <-  sample(x,1)
x[sam:(sam+4)]



You mean

sam <-  sample(seq_along(x),1)
x[sam:(sam+4)]

I think this answers the question as posed, but possibly not as meant.

You might have

block <- seq_along(x) %/% 5

and want to an entire block. This is a little more tricky:

bl <- sample(unique(block),1)
x[block==bl]

It gets even trickier if you want to vectorize sampling of multiple 
blocks, but let's leave that for now.



Regards
Petr




Thanks a lot!

Martin
--
View this message in context: 

http://www.nabble.com/how-to-sample-a-block-

tp20418997p20418997.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Remove empty levels in subset

2008-11-10 Thread Ronaldo Reis-Jr.
Thanks

it work perfectly.

2008/11/10 Henrique Dallazuanna <[EMAIL PROTECTED]>

> Try this:
>
> test2$a <- factor(test2$a)
>
> On Mon, Nov 10, 2008 at 10:33 AM, Ronaldo Reis-Jr. <[EMAIL PROTECTED]>wrote:
>
>> Hi,
>>
>> when I use use subset in a data.frame, all empty levels are maintained in
>> the new table.
>>
>>  > test <-
>> data.frame(a=as.factor(rep(c("f1","f2","f3"),10)),b=rep(c(1,2,3),10))
>> > summary(test)
>>  ab
>>  f1:10   Min.   :1
>>  f2:10   1st Qu.:1
>>  f3:10   Median :2
>> Mean   :2
>> 3rd Qu.:3
>> Max.   :3
>> > test2 <- subset(test,test$a=="f1")
>> > summary(test2)
>>  ab
>>  f1:10   Min.   :1
>>  f2: 0   1st Qu.:1
>>  f3: 0   Median :1
>> Mean   :1
>> 3rd Qu.:1
>> Max.   :1
>>
>> Look that the f2 and f3 are in the new table, how to remove all empty
>> levels?
>>
>> Thanks
>> Ronaldo
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] as.Data with minutes resolution

2008-11-10 Thread Henrique Dallazuanna
Try this:

diff(strptime(time1, "%d/%m/%y-%H:%M"))

On Mon, Nov 10, 2008 at 10:38 AM, Ronaldo Reis-Jr. <[EMAIL PROTECTED]>wrote:

> Hi,
>
> I have a vetor os dates with day and hour:minutes.
>
> > time1 <- c("03/08/08-11:00","03/08/08-11:10")
> > time1 <- as.Date(time1,"%d/%m/%y-%R")
> > summary(time1)
>Min.  1st Qu.   Median Mean  3rd Qu.
> Max.
> "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03"
> "2008-08-03"
> > time1[2]-time1[1]
> Time difference of 0 days
>
> I need to get the difference between these minutes, my expected result in
> this operation is 10 minutes.
>
> How I make this in R?
>
> Thanks
> Ronaldo
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Remove empty levels in subset

2008-11-10 Thread Henrique Dallazuanna
Try this:

test2$a <- factor(test2$a)

On Mon, Nov 10, 2008 at 10:33 AM, Ronaldo Reis-Jr. <[EMAIL PROTECTED]>wrote:

> Hi,
>
> when I use use subset in a data.frame, all empty levels are maintained in
> the new table.
>
>  > test <-
> data.frame(a=as.factor(rep(c("f1","f2","f3"),10)),b=rep(c(1,2,3),10))
> > summary(test)
>  ab
>  f1:10   Min.   :1
>  f2:10   1st Qu.:1
>  f3:10   Median :2
> Mean   :2
> 3rd Qu.:3
> Max.   :3
> > test2 <- subset(test,test$a=="f1")
> > summary(test2)
>  ab
>  f1:10   Min.   :1
>  f2: 0   1st Qu.:1
>  f3: 0   Median :1
> Mean   :1
> 3rd Qu.:1
> Max.   :1
>
> Look that the f2 and f3 are in the new table, how to remove all empty
> levels?
>
> Thanks
> Ronaldo
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] as.Data with minutes resolution

2008-11-10 Thread Gabor Grothendieck
You can use chron:

   library(chron)
   time1 <- c("03/08/08-11:00","03/08/08-11:10")
   diff(as.chron(time1, "%d/%m/%y-%H:%M"))

Also you can use POSIXct but in that case be careful
about time zones.  See R News 4/1.

On Mon, Nov 10, 2008 at 7:38 AM, Ronaldo Reis-Jr. <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a vetor os dates with day and hour:minutes.
>
>> time1 <- c("03/08/08-11:00","03/08/08-11:10")
>> time1 <- as.Date(time1,"%d/%m/%y-%R")
>> summary(time1)
>Min.  1st Qu.   Median Mean  3rd Qu.
> Max.
> "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03"
> "2008-08-03"
>> time1[2]-time1[1]
> Time difference of 0 days
>
> I need to get the difference between these minutes, my expected result in
> this operation is 10 minutes.
>
> How I make this in R?
>
> Thanks
> Ronaldo
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: how to sample a block

2008-11-10 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 10.11.2008 13:25:41:

> 
> Hi,
> I want to sample a block of information.
> 
> Let's say x is a time series. Using sample(x,5) I get a random sample of
> length 5 from x.
> 
> Is it possible to sample consecutive observations, i.e. I sample one
> observation and also get the next 4 observations?

Easy

sam <-  sample(x,1)
x[sam:(sam+4)]

Regards
Petr



> 
> Thanks a lot!
> 
> Martin
> -- 
> View this message in context: 
http://www.nabble.com/how-to-sample-a-block-
> tp20418997p20418997.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] as.Data with minutes resolution

2008-11-10 Thread Ronaldo Reis-Jr.
Hi,

I have a vetor os dates with day and hour:minutes.

> time1 <- c("03/08/08-11:00","03/08/08-11:10")
> time1 <- as.Date(time1,"%d/%m/%y-%R")
> summary(time1)
Min.  1st Qu.   Median Mean  3rd Qu.
Max.
"2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03" "2008-08-03"
"2008-08-03"
> time1[2]-time1[1]
Time difference of 0 days

I need to get the difference between these minutes, my expected result in
this operation is 10 minutes.

How I make this in R?

Thanks
Ronaldo

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Remove Columns by Name from zoo object

2008-11-10 Thread Gabor Grothendieck
On Mon, Nov 10, 2008 at 12:31 AM, Sean Carmody <[EMAIL PROTECTED]> wrote:
> The tricks for removing columns specified by name from data frames such as
>
> x$mycol <- NULL

That only works for data frames since they are based on
lists but not for objects like matrix, ts and zoo which are not
based on lists.  Try this:

library(zoo)
z <- zoo(cbind(a = 1:2, b = 3:4, c = 5:6))
# all but b
z <- z[, colnames(z) != "b"]
z

z <- zoo(cbind(a = 1:2, b = 3:4, c = 5:6))
# all but b and c
z <- z[, ! colnames(z) %in% c("b", "c")]
z

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Remove empty levels in subset

2008-11-10 Thread Ronaldo Reis-Jr.
Hi,

when I use use subset in a data.frame, all empty levels are maintained in
the new table.

 > test <-
data.frame(a=as.factor(rep(c("f1","f2","f3"),10)),b=rep(c(1,2,3),10))
> summary(test)
  ab
 f1:10   Min.   :1
 f2:10   1st Qu.:1
 f3:10   Median :2
 Mean   :2
 3rd Qu.:3
 Max.   :3
> test2 <- subset(test,test$a=="f1")
> summary(test2)
  ab
 f1:10   Min.   :1
 f2: 0   1st Qu.:1
 f3: 0   Median :1
 Mean   :1
 3rd Qu.:1
 Max.   :1

Look that the f2 and f3 are in the new table, how to remove all empty
levels?

Thanks
Ronaldo

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to sample a block

2008-11-10 Thread Spiderschwein

Hi,
I want to sample a block of information.

Let's say x is a time series. Using sample(x,5) I get a random sample of
length 5 from x.

Is it possible to sample consecutive observations, i.e. I sample one
observation and also get the next 4 observations?

Thanks a lot!

Martin
-- 
View this message in context: 
http://www.nabble.com/how-to-sample-a-block-tp20418997p20418997.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] rimage don't install on mac OS X 10.5.5 solved

2008-11-10 Thread Florencio Gonzalez Blazquez
Hello i resolve the installation of the package rimage following the  
indications  by Andy Jacobson in the list [EMAIL PROTECTED]

the trick is using R CMD INSTALL --configure-vars='LDFLAGS=-L/sw/lib  
CPPFLAGS=-I/sw/include' rimage_0.5-7.tar.gz
the packages fftw2.1.5 and libjpeg were installed via Fink.
Thanks for Prof. Brian Ripley for ththe response and hope this can  
help anyone.
Regards, Florencio González Blázquez


Message: 93
Date: Fri, 31 Oct 2008 11:40:23 +0100
From: Florencio Gonzalez Blazquez <[EMAIL PROTECTED]>
Subject: Re: [R] rimage don't install on mac OS X 10.5.5
To: Prof Brian Ripley <[EMAIL PROTECTED]>
Cc: r-help@r-project.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed;
delsp=yes

Thanks for your rapid response. I tried your sugerences and set
C_INCLUDE_PATH=/usr/local/include. I also look in /usr/local/include
and here it appears fftw.h and also fftw3.f, fftw3.h, fftw_threads.h
and rfftw.h rfftw_threads.h
but it don't work also. I will try to update to R 2.8.0
Thanks for your sugestions

El 31/10/2008, a las 10:10, Prof Brian Ripley escribi?:

> On Fri, 31 Oct 2008, Florencio Gonzalez Blazquez wrote:
>
>> Hello, i'm trying to install de rimage package form source. I have
>> installed fftw2.1.5 and libjpeg, but during compilation appear this
>> message:
>
> Where did you install the fftw headers?  If in /usr/local/include,
> this is apparently not in the C_INCLUDE_PATH for your system.  (The
> reason that configure finds ffw.h but the compile does not is most
> likely that -isysroot has been set in the compile: the author of
> rimage has not been careful to use the same compiler flags as R
> uses. Cc:ing the author here -- please study 'Writing R Extensions'
> about how to use a configure script in a package.)  I suspect the
> workaround is to set C_INCLUDE_PATH=/usr/local/include (or as
> appropriate) in the environment used for the compile, or to install
> ffw with --prefix=/usr.
>
> There is a list, R-sig-mac, for MacOS-specific questions and you
> will get the ears of the MacOS experts there.
>
> Please note the advice of the posting guide to update your R *before
> posting*: R 2.7.0 is rather old and many bugs have been fixed since.
>
>>
>> * Installing *source* package 'rimage' ...
>> checking for g++... g++
>> checking for C++ compiler default output... a.out
>> checking whether the C++ compiler works... yes
>> checking whether we are cross compiling... no
>> checking for suffix of executables...
>> checking for suffix of object files... o
>> checking whether we are using the GNU C++ compiler... yes
>> checking whether g++ accepts -g... yes
>> checking for gcc... gcc
>> checking whether we are using the GNU C compiler... yes
>> checking whether gcc accepts -g... yes
>> checking for gcc option to accept ANSI C... none needed
>> checking how to run the C preprocessor... gcc -E
>> checking for egrep... grep -E
>> checking for ANSI C header files... yes
>> checking for sys/types.h... yes
>> checking for sys/stat.h... yes
>> checking for stdlib.h... yes
>> checking for string.h... yes
>> checking for memory.h... yes
>> checking for strings.h... yes
>> checking for inttypes.h... yes
>> checking for stdint.h... yes
>> checking for unistd.h... yes
>> checking fftw.h usability... yes
>> checking fftw.h presence... yes
>> checking for fftw.h... yes
>> checking jpeglib.h usability... yes
>> checking jpeglib.h presence... yes
>> checking for jpeglib.h... yes
>> checking for inline... inline
>> checking for stdlib.h... (cached) yes
>> checking for GNU libc compatible malloc... yes
>> configure: creating ./config.status
>> config.status: creating src/Makevars
>> ** libs
>> ** arch - i386
>> g++ -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-
>> version-min=10.4 -I/Library/Frameworks/R.framework/Resources/
>> include -I/Library/Frameworks/R.framework/Resources/include/i386 -g
>> -O2   -msse3 -fPIC  -g -O2 -march=nocona -c equalize.cpp -o
>> equalize.o
>> gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-
>> version-min=10.4 -std=gnu99 -I/Library/Frameworks/R.framework/
>> Resources/include -I/Library/Frameworks/R.framework/Resources/
>> include/i386 -g -O2   -msse3 -fPIC  -g -O2 -march=nocona -c
>> fftw_access_func.c -o fftw_access_func.o
>> fftw_access_func.c:10:18: error: fftw.h: No such file or directory
>> fftw_access_func.c: In function ?fftw_access_func?:
>> fftw_access_func.c:20: error: ?fftwnd_plan? undeclared (first use
>> in this function)
>> fftw_access_func.c:20: error: (Each undeclared identifier is
>> reported only once
>> fftw_access_func.c:20: error: for each function it appears in.)
>> fftw_access_func.c:20: error: syntax error before ?plan?
>> fftw_access_func.c:21: error: ?fftw_complex? undeclared (first use
>> in this function)
>> fftw_access_func.c:21: error: ?i? undeclared (first use in this
>> function)
>> fftw_access_func.c:21: error: ?s? undeclared (first use in this
>> function)

[R] Copula package: How to calculate correlation matrix using 144 variables to denote parameters for normal copula?

2008-11-10 Thread rasti matus
Dears,

I calculated correlation matrix using 144 variables with a given function:
cor_flows_vec=cor()

Then I  defined a normal copula with the above correlation matrix
myCop=normalCopula(param=cor_flows_vec, dim = 144, dispstr = "un")

Then I created a multivariate distribution with our defined copula while the
univariete functions were fitted by GEV distribution using fExtremes package
library(fExtremes)

paramMargin=function(d){

n=length(d[1,])
param=c(1:n)

for (i in seq(1:n)){
param[i]= list(list(xi=d[1,i], mu=d[2,i], beta=d[3,i]))
}
return(param)
}

paramMargins=paramMargin(d)

myMvd <- mvdc(copula=myCop,
margins=c(rep("gev",144)),paramMargins=paramMargins)

The problem occures when I am trying to sample from the mvdc regarding
correlation matrix.
rmvdc(myMvd, 3)

Cam anyone help? Thanks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >