Re: [R] Clean programming with R

2007-11-25 Thread cgenolin
>> library(codetools)
>> findGlobals(power)

Thanks for your answer.
In addition, findGlobals(power,FALSE) gives the list of the globals 
variables alone :

> findGlobals(power,F)
$functions
[1] "^"  "{"  "<-" "return"

$variables
[1] "pp"



Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre

__
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] determine the number of digits printed into graph with "text(...)"

2007-11-25 Thread Prof Brian Ripley
Your misunderstanding is that this is not 'printing'.  From ?text:

   labels: a character vector or expression specifying the _text_ to be
   written.  An attempt is made to coerce other language objects
   (names and calls) to expressions, and vectors and other
   classed objects to character vectors by 'as.character'.

If you don't want what as.character does (see its help page), you need to 
do the conversion to character yourself, e.g. by sprintf() or format().

On Sun, 25 Nov 2007, Georg Ehret wrote:

> Dear R comunity,
>   I am printing a number in a graph using "text(...)" -  see code
> below: "fraction" is my number. I wish to print only two digits of the
> number and struggle to do this... options(digit=3) does not work...
> Thank you for your suggestions! Cheers, Georg.
>
> **
> Georg Ehret
> Johns Hopkins
> Baltimore
>
> callrates<-read.table("RSG",col.names=c("variant","callrate"))
> hist(callrates[,2],breaks=100)
> fraction<-nrow(callrates[callrates$callrate>=0.9,])/nrow(callrates)
> hist(callrates[,2],breaks=100)
> text(0.4,500,"proportion of callrates >= 0.9:")
> text(0.4,450,fraction)

-- 
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.


[R] Odp: help in plotting

2007-11-25 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 24.11.2007 08:55:54:

> Dear list,
> 
> I want to combine several plots in one graph.
> I did this: plot(a1); plot(a2, add=TRUE); ...plot(a5, add=TRUE)
> The problem is the more plot we put, the more complex the graph.
> Is there any way to label each line; or other way just to make sure I 
know
> which one which?

Did you consider ?lines

Regards
Petr



> 
> Thank you for the help,
> Ilham
> 
>[[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] Plotting + saving to file on Linux

2007-11-25 Thread peter360

Yep you are right on=)  Both worked after I followed dev.copy with dev.off. 
Thanks!

> You likely forgot dev.off() after dev.copy.

-- 
   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.



-- 
View this message in context: 
http://www.nabble.com/Plotting-%2B-saving-to-file-on-Linux-tf4853743.html#a13944546
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] testing independence of categorical variables

2007-11-25 Thread Shoaaib Mehmood
i cant find help for xtab. Which package contains this function

On Nov 24, 2007 12:16 PM, G Ilhamto <[EMAIL PROTECTED]> wrote:
> hi shohaib,
> have you tried xtab instead of chisq.test?
>
> Ilham
>
>
>
> On Nov 22, 2007 6:16 AM, Shoaaib Mehmood <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > hi,
> >
> > is there a way of calculating of measuring dependence between two
> > categorical variables. i tried using the chi square test to test for
> > independence but i got error saying that the lengths of the two
> > vectors don't match. Suppose X and Y are two factors. X has 5 levels
> > and Y has 7 levels. This is what i tried doing
> >
> > >temp<-chisq.test(x,y)
> >
> > but got error "the lengths of the two vectors don't match". any help
> > will be appreciated
> > --
> > Regards,
> > Rana Shoaaib Mehmood
> >
> >
> > __
> > 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.
> >
>
>



-- 
Regards,
Rana Shoaaib Mehmood
(+92) 333 550 4531

__
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] CPCA?

2007-11-25 Thread Daniel Berner
It would be great to know if and where an R code for Common Principal Component 
Analysis is available.
Thanks,
Daniel

Daniel Berner
Redpath Museum & Dept. of Biology
McGill University
859 Sherbrooke St. W.
Montreal, QC, H3A 2K6
Canada
Phone: 514-398-4086 ext. 00908
Fax: 514-398-3185
Email: [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] R as server application

2007-11-25 Thread David Katz

This sounds useful, but can you give more info on "forward X...". Thanks.


Scionforbai wrote:
> 
> Do you need something more than a simple ssh connection to a remote
> host in which you run R (trivial when the server is Linux)?
> 
> My advice is to run R in a "screen" session on the remote host (it
> protects from sudden disconnections). Then you have a window on your
> screen with the R command line, which you can copy/paste your scripts
> to (from whichever editor you want) as if it was running locally. Of
> course, on-screen graphics works (if you forward X... if you see what
> I mean) but it depends on connection speed (in LAN no problem, through
> internet it can be a pain, I usually don't use it then) and you need
> an X server running locally (if the 'client' is windows, cygwin highly
> recommended).
> 
> A real R 'server' could be very useful though.
> 
> __
> 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/R-as-server-application-tf4849719.html#a13944110
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] Any useR conference in US in YR2008

2007-11-25 Thread elw



Something like this - alternating among continents - happens with AoIR, 
the Association for Internet Research.  A real effort has been made to 
make sure that the conference is in North America no more than every other 
year, with alternating slots going to Europe and (once so far..) to 
Australia.  There is quite a lot of discussion of how to get that 
particular conference (and research-base) spun up in South America, as 
well - and I think that eventually we'll see a conference hosted there.

A good model to follow, I think; AoIR is, like useR, a relatively young 
and savvy conference/group, pretty close to the bleeding edge.

--elijah


On Fri, 23 Nov 2007, [EMAIL PROTECTED] wrote:

> Date: Fri, 23 Nov 2007 11:13:53 +1000
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED], [EMAIL PROTECTED]
> Cc: R-help@r-project.org
> Subject: Re: [R] Any useR conference in US in YR2008
> 
> Apropos this issue, the R Foundation has had an offer to host useR 2009
> from a European based group rather than a North American based one.  My
> understanding is that no decision has yet been taken, though.  If other
> groups had an interest in hosting useR 2009, it might not be a bad idea
> to register that interest fairly soon.
>
> There was a suggestion that alternating between the North America and
> Europe would be a good idea, but I don't know if this is a cosy
> understanding of what would be nice, or a reasonably firm policy
> decision.  (I'm also not sure in which camp little places like Brazil,
> New Zealand, Australia, Japan, China, India, ..., would fit in this
> rather occidental view of the world, too.  :-)
>
> Bill Venables.
>
>
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):  +61 7 3826 7304
> Mobile: +61 4 8819 4402
> Home Phone: +61 7 3286 7700
> mailto:[EMAIL PROTECTED]
> http://www.cmis.csiro.au/bill.venables/
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Marc Schwartz
> Sent: Friday, 23 November 2007 3:54 AM
> To: Wensui Liu
> Cc: r-help@r-project.org
> Subject: Re: [R] Any useR conference in US in YR2008
>
> None sponsored by the R Foundation.
>
> There may be others, offered by the various companies who offer R/S-PLUS
> training. They do periodically post e-mails about them on these lists.
>
> Regards,
>
> Marc
>
> On Thu, 2007-11-22 at 12:44 -0500, Wensui Liu wrote:
>> Thank you so much, Marc!
>> So if I understand correctly, there is no conference related to R in
>> US in the coming yr2008. Am I correct?
>>
>> On 11/22/07, Marc Schwartz <[EMAIL PROTECTED]> wrote:
>>>
>>> On Thu, 2007-11-22 at 11:58 -0500, Wensui Liu wrote:
 Dear usRs,
 Is there any conference for usR in US next year?
 Happy Turkey day!

 wensui
>>>
>>> R related conferences, at least those officially related to the R
>>> Foundation, are listed here:
>>>
>>>   http://www.r-project.org/conferences.html
>>>
>>> This past August, the useR! conference was at Iowa State University.
>>> Next year's useR! conference is in Dortmund, Germany. If the pattern
>>> holds, the useR! conference in 2009 will be back in the U.S.
>>>
>>> HTH,
>>>
>>> Marc Schwartz
>>>
>
> __
> 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] Install repeated library

2007-11-25 Thread Simon Blomberg
The repeated package is on CRAN. I installed it successfully from there.

Simon.

On Sun, 2007-11-25 at 10:41 -1200, Becky Parker wrote:
> Hello -
> 
> I cannot get to
> www.alpha.luc.ac.be/~jlindsey/rcode.htmlto
> obtain and install the repeated library for use of glmm().  Is the web
> page not active?  Can you give me an alternative location to obtain the
> repeated library?
> 
> Thank you,
> Becky Parker
> 
>   [[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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
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 in closing R console

2007-11-25 Thread amna khan
Dear Sir

When I close R console then following message apear when I want to save the
workspace. If I close the R console without saving workspace then R console
is closed otherwise not.

Error in gzfile(file, "wb") : unable to open connection
In addition: Warning message:
In gzfile(file, "wb") : cannot open compressed file '.RDataTmp'
Regards

-- 
AMINA SHAHZADI
Department of Statistics
GC University Lahore, Pakistan.

[[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] Packages - a great resource, but hard to find the right one

2007-11-25 Thread hadley wickham
> As for who should do the review, I wouldn't trust so much any user as I
> would an organization such as the JSS. If the latter is not possible, the
> first alternative is better than nothing.

Of course, it doesn't have to be one or the other, but both could be
included.  It would be also nice to include:

 *  lists of papers that cite that package (relatively difficult with
current bibliographic data sources, but hopefully will be easier in
the future)

 * messages from the mailing lists (r-help, and announcements)

 * easy access to changelogs (both human and computer generated - e.g.
cranberries)

 * links to buy or find in a local library accompanying books

 * other packages produced by the same author, other packages on the same topic

 * packages that dependent on this package, package that this package depends on

And I'm sure there are many other things that I haven't thought of in
5 minutes of brainstorming.  I'd be interested in developing something
like this, but I have to get my PhD finished first!

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] determine the number of digits printed into graph with "text(...)"

2007-11-25 Thread jim holtman
sprintf("%.2f", fraction)

On Nov 25, 2007 10:00 PM, Georg Ehret <[EMAIL PROTECTED]> wrote:
> Dear R comunity,
>   I am printing a number in a graph using "text(...)" -  see code
> below: "fraction" is my number. I wish to print only two digits of the
> number and struggle to do this... options(digit=3) does not work...
> Thank you for your suggestions! Cheers, Georg.
>
> **
> Georg Ehret
> Johns Hopkins
> Baltimore
>
> callrates<-read.table("RSG",col.names=c("variant","callrate"))
> hist(callrates[,2],breaks=100)
> fraction<-nrow(callrates[callrates$callrate>=0.9,])/nrow(callrates)
> hist(callrates[,2],breaks=100)
> text(0.4,500,"proportion of callrates >= 0.9:")
> text(0.4,450,fraction)
>
> __
> 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 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.


[R] Install repeated library

2007-11-25 Thread Becky Parker
Hello -

I cannot get to
www.alpha.luc.ac.be/~jlindsey/rcode.htmlto
obtain and install the repeated library for use of glmm().  Is the web
page not active?  Can you give me an alternative location to obtain the
repeated library?

Thank you,
Becky Parker

[[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] determine the number of digits printed into graph with"text(...)"

2007-11-25 Thread Peter Alspach
Georg

?format

(or simply ?round if you are happy to drop the occasional final 0)

HTH ...

Peter Alspach
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Georg Ehret
> Sent: Monday, 26 November 2007 4:00 p.m.
> To: r-help
> Subject: [R] determine the number of digits printed into 
> graph with"text(...)"
> 
> Dear R comunity,
>I am printing a number in a graph using "text(...)" -  see code
> below: "fraction" is my number. I wish to print only two 
> digits of the number and struggle to do this... 
> options(digit=3) does not work...
> Thank you for your suggestions! Cheers, Georg.
> 
> **
> Georg Ehret
> Johns Hopkins
> Baltimore
> 
> callrates<-read.table("RSG",col.names=c("variant","callrate"))
> hist(callrates[,2],breaks=100)
> fraction<-nrow(callrates[callrates$callrate>=0.9,])/nrow(callrates)
> hist(callrates[,2],breaks=100)
> text(0.4,500,"proportion of callrates >= 0.9:")
> text(0.4,450,fraction)
> 
> __
> 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.
> 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

__
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] Assessing accuracy of clustering output

2007-11-25 Thread Y.Xia - Final Year Mathematician
Dear All,Say I've got a 2 by 3 data matrix with numerical entries A, B, C,
D. The 3rd column labels the real cluster of these values (A and B belong to
cluster 1 and C, D belong to cluster 2.) Now if I perform a clustering
algorithm such as kmeans on those numerical part of the matrix with
pre-specified k=2), which gives, for example, A,C belongs to cluster 3 and
B, D belongs to cluster 4, what R codes do I use to check the accuracy of
such output based on knowledge of the real clusters in the data matrix? The
whole point of this is to compare the performance of various clustering
algorithms with the "Real" information.

Yours sincerely,
Yang

[[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] time series analysis with covariates

2007-11-25 Thread Daniel Malter

Hi, I am trying to analyze a time series with covariates. Since I have
basically no prior experience with time series modeling, I followed a
procedure suggested by Wooldridge, but I slightly changed the procedure and
wanted to ask whether it is sound or flawed in your opinion.

Wooldridge suggests fitting a time trend to the dependent variable and then
regressing the residuals on both a time trend and the explanatory variables.
Therefore, I did the following:

- I regressed the dependent variable on a time trend using gam().

reg=gam(dependent~s(time))

- Then I inspected and analyzed the residuals of the gam()-fit for
autocorrelation (with acf-plots and the ar() function). This suggested an
autocorrelation of 4 lags of the residuals even after fitting the time trend
(indicating a second-order time trend).

ar(reg$res)
acf(reg$res,type="partial",lag=20)

- Then I extracted for each time period the lagged residuals for t-1, t-2,
t-3, and t-4 (L1res, L2res, L3res, L4res).

- Finally, I ran a gam() on both the residuals of the gam()-fit and the
dependent variable, including a time trend and the lagged residuals
t-1...t-4 from the gam()-fit. The regression on the residuals basically
implies doubly fitting the time trend (as suggested by Wooldridge) whereas
the regression of the dependent variable only implies fitting the time trend
in the final regression only, but still using the lagged residuals of the
first regression. Again, in both regressions I use the lagged residuals from
the initial time trend fit. The results of the two regressions are almost
identical, but the 

reg2=gam(reg$res~s(time)+L1res+L2res+L3res+L4res+independents)
reg3=gam(dependent~s(time)+L1res+L2res+L3res+L4res+independents)

Is it sound to fit a time series model with covariates in this way? Is it
sound to use the 4 period lagged residuals in the later regressions? If not,
could you please point me to the package and functions that I can to this
with.

Thanks so much,
Daniel

__
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] Packages - a great resource, but hard to find the right one

2007-11-25 Thread diegol

Hi all,

I've been reading your suggestions and I'd like to share my thoghts, which
might be common to people not so deeply involved in the development of R.

One of the advantages of R is that it's an open source software, meaning
that anyone can peruse the code for whatever purpose they might have. 

In R this is also true with contributed packages. However, for novices (like
me) R is terribly overwhelming and although I suspect there are excellent
professionals in their development, I really don't know how skilled the
person behind a certain package is, both in his discipline and in coding in
R.

Since it won't be short until I can understand complex R functions, in the
meantime I'd find a third-party review of the package useful. So I download
a package and know that at least someone else has taken a look at it and
vouches for its correct functioning or alerts of errors in certain points.
An alternative would be not to use R until I get to understand the code and
make sure it does what I expect, whereas I use another software to solve my
problems. In many cases this could mean setting R apart for good.

Also this is not a minor point if R is expected to spread at the corporate
level. Users need some level of assurance that what they use is reliable, if
not able to check the code in their own (having the code available is indeed
very useful, but not enough in all cases).

As for who should do the review, I wouldn't trust so much any user as I
would an organization such as the JSS. If the latter is not possible, the
first alternative is better than nothing.

Best regards,


-
~~
Diego Mazzeo
Actuarial Science Student
Facultad de Ciencias Económicas
Universidad de Buenos Aires
Buenos Aires, Argentina
-- 
View this message in context: 
http://www.nabble.com/Re%3A-Packages---a-great-resource%2C-but-hard-to-find-the-right-one-tf4855917.html#a13937354
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] determine the number of digits printed into graph with "text(...)"

2007-11-25 Thread Georg Ehret
Dear R comunity,
   I am printing a number in a graph using "text(...)" -  see code
below: "fraction" is my number. I wish to print only two digits of the
number and struggle to do this... options(digit=3) does not work...
Thank you for your suggestions! Cheers, Georg.

**
Georg Ehret
Johns Hopkins
Baltimore

callrates<-read.table("RSG",col.names=c("variant","callrate"))
hist(callrates[,2],breaks=100)
fraction<-nrow(callrates[callrates$callrate>=0.9,])/nrow(callrates)
hist(callrates[,2],breaks=100)
text(0.4,500,"proportion of callrates >= 0.9:")
text(0.4,450,fraction)

__
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] about Runtime Error

2007-11-25 Thread Xin Huang
Hi,

I wrote my own R program doing some MCMC simulation but I often got
"Runtime Error" even the program only run for a couple of hundred
times. The detail error message is as following:

Runtime Error!
Program: C:\Program Files\R\R-2.5.1\bin\Rgui.exe
This application has requested the Runtime to terminate it in an
unusual way. Please contact the application's support team for more
information.

When I turned off the program, there was another error message:

RGui:Rgui.exe-Application Error
The instruction at "0x5ad71531" referenced memory at "0x0014". The
memory count not be "read".

Please let me know if there is anything I can do to solve the problem.

Thank you very much.
Xin

__
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] Heatmap problem

2007-11-25 Thread Gregory Warnes
Hi Allen,

The dotted line is an 'extra' feature to help quantify the difference  
between adjacent color boxes.  It can be turned off by using the  
argument heatmap.2(..., trace="none").  For more details do

library(gplots)
?heatmap.2

-G

On Nov 22, 2007, at 12:03PM , affy snp wrote:

> Hi Marco,
>
> Thanks! I actually tried heatmap.2 earlier but I observed
> dot line along each column generated as well.
>
> Allen
>
> On 11/22/07, Boks, M.P.M. <[EMAIL PROTECTED]> wrote:
>>
>> Try Heatmap.2 in the gplots package.
>>
>> BW,
>>
>> Marco
>>
>>
>> -Oorspronkelijk bericht-
>> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
>> project.org]
>> Namens Jim Lemon
>> Verzonden: donderdag 22 november 2007 11:21
>> Aan: affy snp
>> CC: r-help@r-project.org
>> Onderwerp: Re: [R] Heatmap problem
>>
>>
>> affy snp wrote:
>>> Hi friends,
>>>
>>> I used heatmap(as.matrix(y2),col=rainbow(256),scale = "column") to
>>> generate the heatmap. But it did not show the code that which color
>>> correspond the value. Is there any parameter for this in heatmap()?
>>>
>> Hi Allen,
>> If you want colors corresponding to the values with a color  
>> legend, have
>>
>> a look at color2D.matplot in the plotrix package.
>>
>> Jim
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-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] Packages - a great resource, but hard to find the right one

2007-11-25 Thread Bert Gunter
Antony, et. al.:

Could this be better handled by just having a place on CRAN for users to
express their (unedited/unrefereed, other than to keep thing within the
bounds of civility and courteous information sharing) extended opinions
rather than formal reviews, akin to the numerous websites hosting reviews
of, e.g. consumer appliances or Amazon book reviews? 

Several contributors to this (worthwhile, IMHO) thread have noted the fluid,
informal, and extremely diverse nature of packages. For this reason, I
wonder if trying to fit them within the usual framework of persistent, long
term, generally supported, widely applicable software is appropriate.
Perhaps, given the innovative nature of R (and open source software in
general?) we need to be similarly innovative in thinking about how to deal
with the vexing problem of the embarassment of software riches that packages
represent. My "unsolicited consumer reviews" suggestion above may not be
sufficiently rigorous, but perhaps it may stimulate others to better
approaches.

Incidentally, I thought Hadley Wickham's comments about 1000 reviews adding
to 1000 packages was on point; but wouldn't it be possible to index the
reviews, Google style, to give a much wider "thesaurus" -- to quote another
pertinent comment -- to help in searching? It certainly works pretty well
for Google (and for my research this morning on "slow cookers").

-- Bert

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Antony Unwin
> Sent: Friday, November 23, 2007 12:51 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [R] Packages - a great resource, but hard to 
> find the right one
> 
> Johannes H|sing wrote
> 
> > > Above all there are lots of packages.  As the software 
> editor of the
> > > Journal of Statistical Software I suggested we should review R
> > > packages.
> >
> > You mean: prior to submission?
> 
> No.
> 
> > > No one has shown any enthusiasm for this suggestion, but I
> > > think it would help.  Any volunteers?
> >
> > Thing is, I may like to volunteer, but not in the "here's a
> > package for you to review by week 32" way. Rather in the way that
> > I search a package which fits my problem.
> 
> That's what I was hoping for.
> 
> > One package lets me down
> > and I'd like to know other users and the maintainer about it.
> > The other one works black magic and I'd like to drop a raving
> > review about it. This needs an infrastructure with a low barrier
> > to entry. A wiki is not the worst idea if the initial infrastructure
> > is geared at addressing problems rather than packages.
> 
> We should differentiate between rave reviews of features that just  
> happened to be very useful to someone and reviews of a package as a  
> whole.  Both have their place and at the moment we don't have either.
> 
> If you are willing to review an R package or aspects of R for JSS  
> please let me know.
> 
> Antony Unwin
> Professor of Computer-Oriented Statistics and Data Analysis,
> Mathematics Institute,
> University of Augsburg,
> Germany
>   [[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] rowMean, specify subset of columns within Dataframe?

2007-11-25 Thread aaront

Thank you all. 

So that I look up the relevant Help topic more fully, the part that extracts
the columns of interest: 
[, c(1, 3:4)]

is this an instance of ?Subscript which Charles directs me to?   

Cheers, Aaron 


Bill.Venables wrote:
> 
> Suppose you want to select column 1, 3 and 4 only.
> 
> ### you don't need the cbind(...) here
> Data1 <- data.frame(I1 = 3, I2 = c(0, 3:1, 2:5, NA),
>   I3 = c(1:4, NA, 5:2), I4 = 2, I5 = 3)
> 
> Data1$mean_134 <- rowMeans(Data1[, c(1, 3:4)], na.rm = TRUE)
> Data1
> 
> Bill Venables.
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of aaront
> Sent: Monday, 26 November 2007 6:02 AM
> To: r-help@r-project.org
> Subject: [R] rowMean, specify subset of columns within Dataframe?
> 
> 
> I would like to calculate the mean of tree leader increment growth over
> 5
> years (I1 through I5) where each tree is a row and each row has 5
> columns.
> So far I have achieved this using rowMeans when all columns are numeric
> type
> and used in the calculation:
> 
> Data1 <- data.frame(cbind(I1 = 3, I2 = c(0,3:1, 2:5,NA), I3
> =c(1:4,NA,5:2),I4=2,I5=3))
> Data1
> Data1$mean_5 <- rowMeans(Data1, na.rm =T)
> Data1
> 
> My real dataset has many columns including several Factor type. Is it
> possible to specify a range of columns within a data frame  using
> rowMeans
> dims= (say where there is a one 
> Factor  column called Species leading I1 to I5, and one Factor column
> called
> Moisture following, so 7 columns total) , or do I either need to extract
> those columns to a new data frame, calculate means, and reattach to the
> original data frame, or use a different function such as apply?
> 
> Unfortunately I am fairly new to R and have a difficult time with some
> terminology and concepts in R Help.
> 
> -- 
> View this message in context:
> http://www.nabble.com/rowMean%2C-specify-subset-of-columns-within-Datafr
> ame--tf4871420.html#a13939204
> 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/rowMean%2C-specify-subset-of-columns-within-Dataframe--tf4871420.html#a13941498
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] attribute evaluation

2007-11-25 Thread Max Kuhn
Julia,

Try using something like

   RSiteSearch("gain")

and see what you get.

Max

On Nov 25, 2007 5:43 PM, "Julia Kröpfl" <[EMAIL PROTECTED]> wrote:
> Hey there!
>
> I am searching for an attribute evaluation algorithm (such as based on Info 
> gain, Gain ratio or Chi squared statistics).
>
> Is something like that available in R?
>
> Thanks for your reply.
> Best regards,
> Julia

-- 

Max

__
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] rowMean, specify subset of columns within Dataframe?

2007-11-25 Thread Bill.Venables
Suppose you want to select column 1, 3 and 4 only.

### you don't need the cbind(...) here
Data1 <- data.frame(I1 = 3, I2 = c(0, 3:1, 2:5, NA),
  I3 = c(1:4, NA, 5:2), I4 = 2, I5 = 3)

Data1$mean_134 <- rowMeans(Data1[, c(1, 3:4)], na.rm = TRUE)
Data1

Bill Venables.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of aaront
Sent: Monday, 26 November 2007 6:02 AM
To: r-help@r-project.org
Subject: [R] rowMean, specify subset of columns within Dataframe?


I would like to calculate the mean of tree leader increment growth over
5
years (I1 through I5) where each tree is a row and each row has 5
columns.
So far I have achieved this using rowMeans when all columns are numeric
type
and used in the calculation:

Data1 <- data.frame(cbind(I1 = 3, I2 = c(0,3:1, 2:5,NA), I3
=c(1:4,NA,5:2),I4=2,I5=3))
Data1
Data1$mean_5 <- rowMeans(Data1, na.rm =T)
Data1

My real dataset has many columns including several Factor type. Is it
possible to specify a range of columns within a data frame  using
rowMeans
dims= (say where there is a one 
Factor  column called Species leading I1 to I5, and one Factor column
called
Moisture following, so 7 columns total) , or do I either need to extract
those columns to a new data frame, calculate means, and reattach to the
original data frame, or use a different function such as apply?

Unfortunately I am fairly new to R and have a difficult time with some
terminology and concepts in R Help.

-- 
View this message in context:
http://www.nabble.com/rowMean%2C-specify-subset-of-columns-within-Datafr
ame--tf4871420.html#a13939204
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] attribute evaluation

2007-11-25 Thread Julia Kröpfl
Hey there!

I am searching for an attribute evaluation algorithm (such as based on Info 
gain, Gain ratio or Chi squared statistics).

Is something like that available in R?

Thanks for your reply.
Best regards,
Julia 
--

__
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 wait after plotting in BATCH mode?

2007-11-25 Thread Henrique Dallazuanna
Perhaps you can use the Sys.sleep function in the final of file:

plot(rnorm(100))
Sys.sleep(5)

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


On 25/11/2007, Jonas Stein <[EMAIL PROTECTED]> wrote:
> when i plot with the following command on console:
> $ R CMD BATCH cp_messung.R
>
> in the R-script i wrote x11() in the beginning, so it draws a nice plot on
> my screen.
>
> But sadly it disappeares after a second or two. How can i make it to wait
> until i press a key or something?
>
> thank you.
>
> --
> kind regards,
>
> Jonas Stein <[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-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] Set the grid.layout programmatically?

2007-11-25 Thread Felipe Carrillo
Hello all:
Does anyone know if the grid layout function can be
set dynamically? For example if I have a column that
will be changing as new data is added monthly I would
like grid to detect the new data and create another
row or column for the new plot on the same window
instead of adding the new layout manually. The code
below shows a grid.layout of hardcoded two rows and
two columns.Thanks

pushViewport(viewport(layout=grid.layout(2,2))) 

Felipe D. Carrillo
  Fishery Biologist
  US Fish & Wildlife Service
  California, USA

__
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] help in plotting

2007-11-25 Thread David Winsemius
Duncan Murdoch <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> On 25/11/2007 1:00 PM, John Kane wrote:
>> That code seems to put the legend basically out of
>> range.
>> 
>> For the last line try x= 8 rather than 10.
>> 
>> legend(x=8,y=.3,paste("Scale=",c(1,2,4,8)),lty=1:4)
> 
> Or use one of the named locations, e.g.
> 
> legend("topright",paste("Scale=",c(1,2,4,8)),lty=1:4)
> 
> Duncan Murdoch

My apologies. The original had this line immediately preceding the code I 
pasted.

x <- seq(0,30,length=100)

I had an "x" lying around my workspace that did not let me see the errant 
default behavior.

-- 
David Winsemius

>> 
>> --- David Winsemius <[EMAIL PROTECTED]> wrote:
>> 
>>> "G Ilhamto" <[EMAIL PROTECTED]> wrote in
>>>
>> news:[EMAIL PROTECTED]:
>>>
 I want to combine several plots in one graph.
 I did this: plot(a1); plot(a2, add=TRUE);
>>> ...plot(a5, add=TRUE)
 The problem is the more plot we put, the more
>>> complex the graph.
 Is there any way to label each line; or other way
>>> just to make sure I
 know which one which?

>>> Try:
>>> ?legend
>>>
>>> This is a worked example taken from Seefeld and
>>> Kim's monograph:
>>>
>> 
>>> plot(x,dgamma(x,shape=2,scale=1), type='l',xlab="x",
>>> ylab="f(x)", main="Gamma pdf's")
>>> lines(x,dgamma(x,shape=2,scale=2),lty=2)
>>> lines(x,dgamma(x,shape=2,scale=4),lty=3)
>>> lines(x,dgamma(x,shape=2,scale=8),lty=4)
>>> legend(x=10,y=.3,paste("Scale=",c(1,2,4,8)),lty=1:4)
>>>
>>> -- 
>>> David Winsemius
>>>
>>> __
>>> 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. 
>

__
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] rowMean, specify subset of columns within Dataframe?

2007-11-25 Thread Charles C. Berry
On Sun, 25 Nov 2007, aaront wrote:

>
> I would like to calculate the mean of tree leader increment growth over 5
> years (I1 through I5) where each tree is a row and each row has 5 columns.
> So far I have achieved this using rowMeans when all columns are numeric type
> and used in the calculation:
>
> Data1 <- data.frame(cbind(I1 = 3, I2 = c(0,3:1, 2:5,NA), I3
> =c(1:4,NA,5:2),I4=2,I5=3))
> Data1


Try

!sapply( Data1, is.factor )

then

Data_2 <- transform( Data1, I5.factor=factor(I5) )
!sapply( Data_2, is.factor )

then


rowMeans( Data_2[ , !sapply( Data_2, is.factor ) ], na.rm = TRUE )


See

?Subscript
?sapply

HTH,

Chuck


> Data1$mean_5 <- rowMeans(Data1, na.rm =T)
> Data1
>
> My real dataset has many columns including several Factor type. Is it
> possible to specify a range of columns within a data frame  using rowMeans
> dims= (say where there is a one
> Factor  column called Species leading I1 to I5, and one Factor column called
> Moisture following, so 7 columns total) , or do I either need to extract
> those columns to a new data frame, calculate means, and reattach to the
> original data frame, or use a different function such as apply?
>
> Unfortunately I am fairly new to R and have a difficult time with some
> terminology and concepts in R Help.
>
> -- 
> View this message in context: 
> http://www.nabble.com/rowMean%2C-specify-subset-of-columns-within-Dataframe--tf4871420.html#a13939204
> Sent from the R help mailing list archive at Nabble.com.
>
>   [[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.
>

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

__
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] Constructin a call of function including permutation of column names - how to escape parentheses?

2007-11-25 Thread Tae-kyun Kim
Hi,

I guess this may be a way to construct a list of character vectors
from variable names.

> library(gregmisc)
> mycolnames <- LETTERS[1:12]
> combinations.2<-combinations(12,2,mycolnames)
> arg.list <- as.list(as.data.frame(t(combinations.2), stringsAsFactors=FALSE))
> names(arg.list) <- paste("item", seq_len(length(arg.list)), sep="")
> head(arg.list)
$item1
[1] "A" "B"

$item2
[1] "A" "C"

$item3
[1] "A" "D"

$item4
[1] "A" "E"

$item5
[1] "A" "F"

$item6
[1] "A" "G"

On Nov 25, 2007 5:18 AM, Jiří Voller <[EMAIL PROTECTED]> wrote:
> Dear R-users,
> I would like to construct a list of arguments for a function in a format
> function (list(item1=c("A","B"), item2=c("B","C")), item3=...):
> The individual vectors in the list are permutations of colnames of a
> dataframe.
> The trouble is that I am not able to handle escaping of parentheses
> correctly.
>
> I was trying the following:
> library(gregmisc)
> combinations.2<-combinations(12,2,mycolnames)
> combinations.2.call<-apply(combinations.2,1,function(x){do.call(paste,c(
> as.list(x),sep="\",\""))})
> combinations.2.call<-paste("c(\"",combinations.2.call,"\")",sep="")
>
> but now calling call("list",combinations.2.list) doesnt work.
>
>
> Could anyone give an advice on this? Thank you.
>
> --
> Jiøí Voller
> Laboratory of Growth Regulators
> Palacký University & Institute of Experimental Botany AS CR
> (c)lechtitelù 11, 783 71 Olomouc
> Czech Republic
> landline: +420-585-634-855
> mobile: +420-737-520-506
> fax: +420-585-634-870
> --
>
> [[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.
>
>



-- 
==
T.K. (Tae-kyun) Kim
Ph.D. student
Department of Marketing
Marshall School of Business
University of Southern California
==
__
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] rowMean, specify subset of columns within Dataframe?

2007-11-25 Thread aaront

I would like to calculate the mean of tree leader increment growth over 5
years (I1 through I5) where each tree is a row and each row has 5 columns.
So far I have achieved this using rowMeans when all columns are numeric type
and used in the calculation:

Data1 <- data.frame(cbind(I1 = 3, I2 = c(0,3:1, 2:5,NA), I3
=c(1:4,NA,5:2),I4=2,I5=3))
Data1
Data1$mean_5 <- rowMeans(Data1, na.rm =T)
Data1

My real dataset has many columns including several Factor type. Is it
possible to specify a range of columns within a data frame  using rowMeans
dims= (say where there is a one 
Factor  column called Species leading I1 to I5, and one Factor column called
Moisture following, so 7 columns total) , or do I either need to extract
those columns to a new data frame, calculate means, and reattach to the
original data frame, or use a different function such as apply?

Unfortunately I am fairly new to R and have a difficult time with some
terminology and concepts in R Help.

-- 
View this message in context: 
http://www.nabble.com/rowMean%2C-specify-subset-of-columns-within-Dataframe--tf4871420.html#a13939204
Sent from the R help mailing list archive at Nabble.com.

[[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] spec.pgram() - circularity of kernel

2007-11-25 Thread Nuno Prista

Hi,

I am far from experienced in both R and time series hence the question. 

The code for spec.pgram() seems to involve circularity of the kernel (see
below) yielding new power estimates to all frequencies computed by FFT. 

"
   if (!is.null(kernel)) {
for (i in 1:ncol(x)) for (j in 1:ncol(x)) pgram[, i, 
j] <- kernapply(pgram[, i, j], kernel, circular = TRUE)
"

Can anyone comment on whether the extreme frequencies (low and high) of the
spectrum are still reliable with this circularity option? At the extremes,
values seem to result from kernel application to collections of high and low
frequencies. Related to this, shouldn't the frequency range shorten
according to the size of kernel used? My doubt came from reading
Diggle(1990) p105.

e.g.

data(lh)
x<-spec.pgram(ldeaths, detrend=T, taper=0)$freq
y<-spec.pgram(ldeaths, kernel("modified.daniell", c(6,6)), detrend=T,
taper=0)$freq
x==y


Thanks in advance,

Nuno Prista

__
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] truncated fields with RODBC

2007-11-25 Thread Mikkel Grum
Thanks. I tried the following syntax and got the same
error message:

sqlSave(pg, Grids, append = TRUE, rownames = FALSE,
   typeInfo = list(double = "double precision",
  integer = "integer", character = "text"))

Warning messages:
1: In odbcUpdate(channel, query, mydata, paramdata,
test = test, verbose = verbose,  :
  character data truncated in column 'grids'
2: In odbcUpdate(channel, query, mydata, paramdata,
test = test, verbose = verbose,  :
  character data truncated in column 'grids'
3: In odbcUpdate(channel, query, mydata, paramdata,
test = test, verbose = verbose,  :
  character data truncated in column 'grids'

The database table was created with the following
createdb pgBase

CREATE TABLE grids
(
  scoutdate date,
  sectorid integer,
  trait text,
  grids text
) 
CREATE INDEX gridssst
  ON grids
  USING btree
  (scoutdate, sectorid, trait);
ALTER TABLE grids CLUSTER ON gridssst;

Once the database tables are created and an ODBC
driver set up, the following code should reproduce the
issue in R:
library(RODBC)
pg <- odbcConnect("pgBase", uid="postgres",
   pwd="whatever", case="tolower")
ScoutDate <- rep(Sys.Date(), 2)
SectorId <- rep(888, 2)
Trait <- c("Seed colour", "Plant height")
Grids <- as.data.frame(cbind(ScoutDate, SectorId,
   Trait))
Grids$Grids[1] <- paste(c(round(rnorm(5000, 10, 5))),
   collapse = " ")
Grids$Grids[2] <- paste(c(round(rnorm(5000, 10, 5))),
   collapse = " ")
sqlSave(pg, Grids, append = TRUE, rownames = FALSE,
   typeInfo = list(double = "double precision",
  integer = "integer", character = "text"))

> odbcGetInfo(pg)
   DBMS_Name DBMS_Ver  Driver_ODBC_Ver
Data_Source_Name 
"PostgreSQL"  "8.2.4"  "03.00"
  "pgBase" 
 Driver_Name   Driver_Ver ODBC_Ver
 Server_Name 
  "PSQLODBC.DLL" "08.02.0300" "03.52."
 "localhost" 
> sessionInfo()
R version 2.6.0 (2007-10-03) 
i386-pc-mingw32 

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

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

other attached packages:
[1] RODBC_1.2-2



--- Prof Brian Ripley <[EMAIL PROTECTED]> wrote:

> You need to study the RODBC documentation: you
> haven't set the type of the 
> character fields in the database table correctly (in
> fact, you seem not 
> to have set them at all, hence will get the default
> of varchar(255)).
> 
> The 64k limit is for reading, not writing.
> 
> As ever, full details and a reproducible example are
> needed for people to 
> help you fully.
> 
> On Sat, 24 Nov 2007, Mikkel Grum wrote:
> 
> > I'm changing some functions from storing data in
> > SQLite (using RSQLite) to storing it in PostgreSQL
> > (using RODBC). When trying to store very long
> > character fields I get the following message:
> >
> >>sqlSave(pg, Grids, rownames = FALSE, append =
> > TRUE)
> > Warning messages:
> > 1: In odbcUpdate(channel, query, mydata,
> paramdata,
> > test = test, verbose = verbose,  :
> >  character data truncated in column 'grids'
> > 2: In odbcUpdate(channel, query, mydata,
> paramdata,
> > test = test, verbose = verbose,  :
> >  character data truncated in column 'grids'
> > 3: In odbcUpdate(channel, query, mydata,
> paramdata,
> > test = test, verbose = verbose,  :
> >  character data truncated in column 'grids'
> >
> > The structure of the dataframe that I'm trying to
> > store looks like this:
> >> str(Grids)
> > 'data.frame':   9 obs. of  4 variables:
> > $ ScoutDate: chr  "2007-10-11" "2007-10-11"
> > "2007-10-11" "2007-10-11" ...
> > $ SectorId : int  93 93 93 93 93 93 93 93 93
> > $ Trait: chr  "eTop" "eMB" "nTop" "nMB" ...
> > $ Grids: chr  "0 0 0 0 0 0 0 53 6064 2364 61 0
> 0
> > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 74
> 482
> > 524 51 0 0 157 316 0 0 0 0 0 0 0 0 0 0 0"|
> > __truncated__ "45 45 45 45 45 45 45 1 0 0 0 45 45
> 45
> > 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45
> 45
> > 45 45 45 45 50 68 70 49 46 46 0 0 3"|
> __truncated__ "0
> > 0 0 0 0 0 0 84 18766 7266 111 0 0 0 0 0 0 0 0 0 0
> 0 0
> > 0 0 0 0 0 0 0 0 0 0 0 0 0 192 1628 1777 112 0 0
> 409
> > 903 0 0 0 0 0 0 0 0"| __truncated__ "94 94 94 94
> 94 94
> > 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94
> 94
> > 94 94 94 94 94 94 94 94 94 94 94 94 137 312 331
> 128 94
> > "| __truncated__ ...
> >
> > The same fields could be copied from SQLite into
> > PostgreSQL through a | delimited file without any
> > error message, so it is not PostgreSQL that is the
> > limitation. dbWriteTable in RSQLite was also able
> to
> > handle this without truncating the data. I think
> these
> > fields are 4-5000 characters wide, but don't
> actually
> > know how to get the exact figure.
> >
> > The offending field is set as a text field in
> > PostgreSQL. I'm using psqlODBC on Windows Server
> 2003
> > and R-2.6.0.
> >
> > Have I missed an argument somewhere that could
> s

Re: [R] help in plotting

2007-11-25 Thread Duncan Murdoch
On 25/11/2007 1:00 PM, John Kane wrote:
> That code seems to put the legend basically out of
> range.
> 
> For the last line try x= 8 rather than 10.
> 
> legend(x=8,y=.3,paste("Scale=",c(1,2,4,8)),lty=1:4)

Or use one of the named locations, e.g.

legend("topright",paste("Scale=",c(1,2,4,8)),lty=1:4)

Duncan Murdoch

> 
> --- David Winsemius <[EMAIL PROTECTED]> wrote:
> 
>> "G Ilhamto" <[EMAIL PROTECTED]> wrote in
>>
> news:[EMAIL PROTECTED]:
>>
>>> I want to combine several plots in one graph.
>>> I did this: plot(a1); plot(a2, add=TRUE);
>> ...plot(a5, add=TRUE)
>>> The problem is the more plot we put, the more
>> complex the graph.
>>> Is there any way to label each line; or other way
>> just to make sure I
>>> know which one which?
>>>
>> Try:
>> ?legend
>>
>> This is a worked example taken from Seefeld and
>> Kim's monograph:
>>
> 
>> plot(x,dgamma(x,shape=2,scale=1), type='l',xlab="x",
>> ylab="f(x)", main="Gamma pdf's")
>> lines(x,dgamma(x,shape=2,scale=2),lty=2)
>> lines(x,dgamma(x,shape=2,scale=4),lty=3)
>> lines(x,dgamma(x,shape=2,scale=8),lty=4)
>> legend(x=10,y=.3,paste("Scale=",c(1,2,4,8)),lty=1:4)
>>
>> -- 
>> David Winsemius
>>
>> __
>> 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.


[R] spec.pgram() - circularity of kernel

2007-11-25 Thread Nuno Prista
Hi,

I am far from experienced in both R and time series hence the question. 

The code for spec.pgram() seems to involve a circularity of the kernel (see
below) yielding new power estimates to all frequencies computed by FFT. 

"
   if (!is.null(kernel)) {
for (i in 1:ncol(x)) for (j in 1:ncol(x)) pgram[, i, 
j] <- kernapply(pgram[, i, j], kernel, circular = TRUE)
"

Can anyone comment on whether the extreme frequencies (low and high) of the
spectrum are still reliable with this circularity option? At the extremes,
values seem to result from kernel application to collections of high and low
frequencies. Related to this, shouldn't the frequency range shorten
according to the size of kernel used? My doubt came from reading
Diggle(1990) p105.

e.g.

data(lh)
x<-spec.pgram(ldeaths, detrend=T, taper=0)$freq
y<-spec.pgram(ldeaths, kernel("modified.daniell", c(6,6)), detrend=T,
taper=0)$freq
x==y


Thanks in advance,

Nuno Prista

__
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] accessing the "address" of items in a recursive list

2007-11-25 Thread Jesse D Lecy
Dear useRs,

I am working on a project involving the clustering of a large dataset.  I need 
to extract specific sub-clusters from the parent dendrogram for further 
analysis.  The data is too large for the use of convenient tools such as 
identify.clust (it selects the specific group of interest on a graph), so 
alternatively I have saved the plot as a large image file so that it can be 
printed or viewed piecemeal.  My problem is this: when I find the subclusters 
that I need to analyze I have no way to reference that specific component of 
the dendrogram in order to extract it:

smallDend <- dend[[i]][[j]][[k]]  where i,j,k refer to levels of the dendrogram 
(it's "address")

I would like to print the "address" of the smaller dendrograms on the edge 
similar to this:

addr <- function(n) {
  if(!is.leaf(n)) {
attr(n, "edgetext") <- paste("height of",(attr(n,"height"))
  }
  n
}
labeledDends <- dendrapply(dend, addr)

Where "i,j,k" is printed instead of "height".  But I have not been able to 
figure out how to ask each dendrogram its address within the dendrapply 
function.  Can anyone help me with this?

Many thanks,
Jesse

PhD Student in Social Science
Syracuse 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] R2winBUGS & WinBUGS gui

2007-11-25 Thread Ben Bolker



Evan Cooch wrote:
> 
> 
>>
>> Yes, sure, and indeed, it is a shame that nobody of those people who 
>> want it to work under Linux is trying to submit patches to make it work.
>>
>>
>>
> I agree, but I *think* the primary reason for this is that it requires 
> installing Blackbox as a PASCAL compiler. For much of the Linux 
> community, if it doesn't make use of a standard GNU compiler (there *is* 
> a GNU Pascal compiler, but since I (and most others) don't know PASCAL, 
> I've never installed it), there will be little interest. Of course, what 
> seems attractive about JAGS is that it is less dependent on a non-GNU 
> compiler (although the dependencies to Blackbox may not be large - 
> relative to GNU Pascal - don't know), and is written in a more familiar 
> language.
> 
> What everyone wants is a tarball with a simple configure, make, make 
> install sequence, that plays nice with R, under linux, which is the OS 
> of choice (based on the statistics I have) for folks with high-end 
> hardware (read - multi-processor 64-bit chips with a 64-bit OS). Of 
> course, this doesn't happen by itself (your point is well-taken).
> 
> 

  I'd like to second Evan's point.  I would try to help with OpenBUGS
if I could, but the little bit that I looked at convinced me that it would
mean getting up to speed on a big, complicated black box (so to
speak) -- and it seems that even the experts on OpenBUGS can't
really figure out what's going on.

There are many threads about this ... the thread ending around

https://stat.ethz.ch/pipermail/r-devel/2007-August/046632.html

suggests that Tobias Verbeke did find a way to wrap OpenBUGS on Linux
to run it without Wine (and without a Windows front-end?) -- Uwe indicated
that he would prefer it to go into R2WinBUGS with the other "ugly wrappers"
...
So the three choices for running BUGS analyses more-or-less natively, and/or
without
firing up the WinBUGS window, are ...

 1. make Tobias's stuff work with R2WinBUGS or BRugs
 2. switch to JAGS
 3. make OpenBUGS compilation work on Linux

  #1 seems to be the best short-term prospect; #2 might be best in
the long term (a second, and possibly cleaner, implementation of an
engine to interpret BUGS(like) code, that runs cross-platform etc.);
#3 would be best for continuing the effectiveness/spread of the original
BUGS lineage.  (Does OpenBUGS compile on the Mac ... )

   I may try to work on these at some point, but probably not in the
next month ...
   
  Ben Bolker

-- 
View this message in context: 
http://www.nabble.com/R2winBUGS---WinBUGS-gui-tf4862719.html#a13938134
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] help in plotting

2007-11-25 Thread John Kane
That code seems to put the legend basically out of
range.

For the last line try x= 8 rather than 10.

legend(x=8,y=.3,paste("Scale=",c(1,2,4,8)),lty=1:4)

--- David Winsemius <[EMAIL PROTECTED]> wrote:

> "G Ilhamto" <[EMAIL PROTECTED]> wrote in
>
news:[EMAIL PROTECTED]:
> 
> 
> > I want to combine several plots in one graph.
> > I did this: plot(a1); plot(a2, add=TRUE);
> ...plot(a5, add=TRUE)
> > The problem is the more plot we put, the more
> complex the graph.
> > Is there any way to label each line; or other way
> just to make sure I
> > know which one which?
> > 
> Try:
> ?legend
> 
> This is a worked example taken from Seefeld and
> Kim's monograph:
>

> 
> plot(x,dgamma(x,shape=2,scale=1), type='l',xlab="x",
> ylab="f(x)", main="Gamma pdf's")
> lines(x,dgamma(x,shape=2,scale=2),lty=2)
> lines(x,dgamma(x,shape=2,scale=4),lty=3)
> lines(x,dgamma(x,shape=2,scale=8),lty=4)
> legend(x=10,y=.3,paste("Scale=",c(1,2,4,8)),lty=1:4)
> 
> -- 
> David Winsemius
> 
> __
> 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] complex conjugates roots from polyroot?

2007-11-25 Thread Spencer Graves
Hi, Ravi: 

  Question:  Are duplicate real numbers complex conjugates?  For 
some purposes, perhaps.  However, for identifying (damped) periodicity 
on a difference or differential equation, we must exclude repeated real 
roots. 

  In any event, your suggestion inspired me to create a function 
"findConjugates" (see below), which I've added to the "FinTS" package 
currently under development on R-Forge.  The source code is currently 
available via "svn checkout 
svn://svn.r-forge.r-project.org/svnroot/fints".  In another day or so, 
it should be available (with documentation) via 
'install.packages("FinTS",repos="http://r-forge.r-project.org";)'.  In 
another couple of months, it should appear on CRAN. 

  Thanks again for your suggestion. 

  Best Wishes,
  Spencer
##
findConjugates <- function(x, 
complex.eps=1000*.Machine[["double.neg.eps"]]){
##
##  1.  compute normalization
##
  if(length(x)<1)return(complex(0))
  ax <- abs(x)
  m2 <- outer(ax, ax, pmax)
##
##  2.  Compute complex differences
##
  c2 <- (abs(outer(x, Conj(x), "-") / m2) < complex.eps)
  c2[m2==0] <- FALSE
  c2 <- (c2 & lower.tri(c2))
##
## 3.  Any differences exceed complex.eps? 
##
  if(any(c2)){
# check standard differences
d2 <- (abs(outer(x, x, "-") / m2) > complex.eps)
d2[m2==0] <- FALSE
#
cd2 <- (c2 & d2)
if(any(cd2)){
  ic <- sort(unique(row(cd2)[cd2]))
  return(x[ic])
}
  }
  complex(0)
}
##
Ravi Varadhan wrote:
> Hi Spencer,
>
> Here is a simple approach to detect conjugate pairs:
>
> is.conj <- function(z1, z2, tol=1.e-10) {
> # determine if two complex numbers are conjugates
> cond1 <- abs(Re(z1) - Re(z2)) < tol
> cond2 <- abs(Im(z1) + Im(z2)) < tol
> cond1 & cond2
> }
>
> set.seed(123)
> z <- polyroot(sample(1:5, size=8, rep=T))
> zmat <- which(outer(z, z, FUN="is.conj"), arr.ind=T)
> zmat[zmat[,1] < zmat[,2], ]
>
> # result
>  row col
> [1,]   1   3
> [2,]   5   6
> [3,]   4   7
>   
>
> We see that (1,3), (4,7), and (5,6) are the conjugate pairs.
>
> This doesn't address the issue of numerical round-off (there is no argument
> in polyroot that governs the accuracy of the roots).
>
> Best,
> Ravi.
>
> 
> ---
>
> Ravi Varadhan, Ph.D.
>
> Assistant Professor, The Center on Aging and Health
>
> Division of Geriatric Medicine and Gerontology 
>
> Johns Hopkins University
>
> Ph: (410) 502-2619
>
> Fax: (410) 614-9625
>
> Email: [EMAIL PROTECTED]
>
> Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
>
>  
>
> 
> 
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Spencer Graves
> Sent: Friday, November 23, 2007 12:08 PM
> To: r-help@r-project.org
> Subject: [R] complex conjugates roots from polyroot?
>
> Hi, All: 
>
>   Is there a simple way to detect complex conjugates in the roots 
> returned by 'polyroot'?  The obvious comparison of each root with the 
> complex conjugate of the next sometimes produces roundoff error, and I 
> don't know how to bound its magnitude: 
>
> (tst <- polyroot(c(1, -.6, .4)))
> tst[-1]-Conj(tst[-2])
> [1] 3.108624e-15+2.22045e-16i
> abs(tst[-1]-Conj(tst[-2]))/abs(tst[-1])
> 1.971076e-15
> .Machine$double.neg.eps
> 1.110223e-16
>
>   Testing (abs(tst[-1]-Conj(tst[-2]))/abs(tst[-1]) < 
> (20*.Machine$double.neg.eps)) would catch this example, but it might not 
> catch others. 
>
>   The 'polyroot' help page says, "See Also ... the 'zero' example in 
> the demos directory."  Unfortunately, I've so far been unable to find 
> that. 
>
>   Any suggestions? 
>   Thanks in advance. 
>   Spencer Graves
>
> __
> 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] howto remove all variables (cleanup)

2007-11-25 Thread John Kane
I see a couple of people have already supplied
rm(list=ls())  

A function that I find useful is the ?keep in the
gdata library. It allows you to keep just a few things
that you want to work with and clean up all the odds &
sods.


--- Jonas Stein <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> as i am quite new to R i often play around with
> commands in R until my graph
> looks nice. 
> 
> After testing things there are often lots of
> variables left. How can i reset
> all vars in one command before i do the final plot?
> 
> At the moment i restart rkward (my editor) but thats
> a bit uncomfortable...
> 
> -- 
> kind regards,
> 
> Jonas Stein <[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-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] R2winBUGS & WinBUGS gui

2007-11-25 Thread Evan Cooch

>
> Yes, sure, and indeed, it is a shame that nobody of those people who 
> want it to work under Linux is trying to submit patches to make it work.
>
>
>
I agree, but I *think* the primary reason for this is that it requires 
installing Blackbox as a PASCAL compiler. For much of the Linux 
community, if it doesn't make use of a standard GNU compiler (there *is* 
a GNU Pascal compiler, but since I (and most others) don't know PASCAL, 
I've never installed it), there will be little interest. Of course, what 
seems attractive about JAGS is that it is less dependent on a non-GNU 
compiler (although the dependencies to Blackbox may not be large - 
relative to GNU Pascal - don't know), and is written in a more familiar 
language.

What everyone wants is a tarball with a simple configure, make, make 
install sequence, that plays nice with R, under linux, which is the OS 
of choice (based on the statistics I have) for folks with high-end 
hardware (read - multi-processor 64-bit chips with a 64-bit OS). Of 
course, this doesn't happen by itself (your point is well-taken).

__
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] R2winBUGS & WinBUGS gui

2007-11-25 Thread Uwe Ligges


Evan Cooch wrote:
>> No. The idea is to use BRugs, i.e. OpenBUGS in such cases. If OpenBUGS 
>> lacks some features, you are certainly welcome to implement them and 
>> send patches to Andrew Thomas.
>>
> 
> Just finished trying the install of openBUGS under linux yet again. Same 
> problems (more or less), which I'll list here for the benefit (possibly) 
> of others who might go this route.
> 
> 1. connect to
> 
> http://www.mathstat.helsinki.fi/openbugs/
> 
> Download latest zip of openBUGS
> 
> 2. unzip it (preserving directory structure) onto Linux machine (in this 
> case, running Fedora Core 8 latest flavours of everything, including R).
> 
> 3. look at the 'docs' for installing under linux. I say 'docs' 
> advisedly, since there really isn't much to read - here it is in its 
> entirety.
> 
> OpenBUGS for both Windows and Linux can be downloaded as a .zip file 
> from here . The 
> source code comes with the installation: check the readme notes to see 
> how to compile the code. you will need to install Black Box 
>  as well.
> 
> 
>   Old Installation Instructions for LinBUGS (which may or may not
>   still work):
> 
>1. Un-zip the .zip file into the folder of your choice.
>2. Change the permissions for the LINBUGS and CBugs files (e.g. with
>   chmod 755 LinBUGS CBugs)
>3. Change the temp directory in LINBUGS to the current directory (at
>   the moment it is "/home/ant/temp"). Use the full path name (can
>   anyone suggest a less ugly way of doing this? We don't want to put
>   the temp directory in OpenBUGS/).
>4. Start LinBUGS with the command LINBUGS.
> 
> 
> (the admonition that it may or may not work is not inspiring). Confirmed 
> at step (2), where you're supposed to change permissions on 2 files 
> which, in fact, are *not* distributed in the openBUGS.zip file. This 
> makes it rather tough to install. ;-)
> 
> 
> I dug around, and found some folks have hacked together a LINGUS script 
> - one version I found fairly commonly looks like:
> 
> #!/bin/bash
> 
> export LD_ASSUME_KERNEL=2.4.1 
> 
> DIR=$(dirname $0)
> cd "$DIR"
> if [ \! -e "$DIR/temp" ] ; then
>   mkdir "$DIR/temp"
> fi
> 
> if [ -e bugs.so ] ; then
>   ./cbugs "$DIR" "$DIR/temp" "/bugs.so" 
> else
>   ./cbugs "$DIR" "$DIR/temp" "/brugs.so" 
> 
> 
> Fine, except for line two, which doesn't work with newer distros.
> 
> And, apparently (based on a bunch of websites I just looked at), BRugs 
> doesn't work under Linux, not unless you want to install the Blackbox 
> compiler (is there one for Linux?), and recompile. Not me (not today, 
> anyway...).
> 
> So, unless I (and a lot of folks who seem to be running into the same 
> issues), my preliminary conclusion is that neither openBUGS nor BRugs 

BRugs is just an interface to OpenBUGS.

> are ready for prime time on a Linux platform. Which seems a shame, given 
> how many people using MCMC etc. use Linux as their primary platform.

Yes, sure, and indeed, it is a shame that nobody of those people who 
want it to work under Linux is trying to submit patches to make it work.


Uwe Ligges



> Guess I'll have another look at JAGS.
> 
> __
> 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] R2winBUGS & WinBUGS gui

2007-11-25 Thread Evan Cooch

>
> No. The idea is to use BRugs, i.e. OpenBUGS in such cases. If OpenBUGS 
> lacks some features, you are certainly welcome to implement them and 
> send patches to Andrew Thomas.
>

Just finished trying the install of openBUGS under linux yet again. Same 
problems (more or less), which I'll list here for the benefit (possibly) 
of others who might go this route.

1. connect to

http://www.mathstat.helsinki.fi/openbugs/

Download latest zip of openBUGS

2. unzip it (preserving directory structure) onto Linux machine (in this 
case, running Fedora Core 8 latest flavours of everything, including R).

3. look at the 'docs' for installing under linux. I say 'docs' 
advisedly, since there really isn't much to read - here it is in its 
entirety.

OpenBUGS for both Windows and Linux can be downloaded as a .zip file 
from here . The 
source code comes with the installation: check the readme notes to see 
how to compile the code. you will need to install Black Box 
 as well.


  Old Installation Instructions for LinBUGS (which may or may not
  still work):

   1. Un-zip the .zip file into the folder of your choice.
   2. Change the permissions for the LINBUGS and CBugs files (e.g. with
  chmod 755 LinBUGS CBugs)
   3. Change the temp directory in LINBUGS to the current directory (at
  the moment it is "/home/ant/temp"). Use the full path name (can
  anyone suggest a less ugly way of doing this? We don't want to put
  the temp directory in OpenBUGS/).
   4. Start LinBUGS with the command LINBUGS.


(the admonition that it may or may not work is not inspiring). Confirmed 
at step (2), where you're supposed to change permissions on 2 files 
which, in fact, are *not* distributed in the openBUGS.zip file. This 
makes it rather tough to install. ;-)


I dug around, and found some folks have hacked together a LINGUS script 
- one version I found fairly commonly looks like:

#!/bin/bash

export LD_ASSUME_KERNEL=2.4.1 

DIR=$(dirname $0)
cd "$DIR"
if [ \! -e "$DIR/temp" ] ; then
mkdir "$DIR/temp"
fi

if [ -e bugs.so ] ; then
./cbugs "$DIR" "$DIR/temp" "/bugs.so" 
else
./cbugs "$DIR" "$DIR/temp" "/brugs.so" 


Fine, except for line two, which doesn't work with newer distros.

And, apparently (based on a bunch of websites I just looked at), BRugs 
doesn't work under Linux, not unless you want to install the Blackbox 
compiler (is there one for Linux?), and recompile. Not me (not today, 
anyway...).

So, unless I (and a lot of folks who seem to be running into the same 
issues), my preliminary conclusion is that neither openBUGS nor BRugs 
are ready for prime time on a Linux platform. Which seems a shame, given 
how many people using MCMC etc. use Linux as their primary platform.

Guess I'll have another look at JAGS.

__
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] 'Split' character

2007-11-25 Thread Gabor Grothendieck
Try this using the BOD data frame that comes with R or
try using interaction in place of paste:

split(BOD, do.call(paste, c(BOD, sep = ":")), drop=TRUE)


On Nov 25, 2007 10:23 AM,  <[EMAIL PROTECTED]> wrote:
>
>
> Thanks Jim and Herinque for you reply.
>
> The substitution you are both proposing works fine, except when a or b 
> contains
> decimal numbers (which is mostly my case in a real dataset). In this case, 
> there
> is no distinction between the decimal point and the one introduced by the 
> split
> function.
> If the split function cannot be customized, then I guess I have to first
> substitute the decimal point in my dataset by e.g. a * sign and change it back
> to a . when the split is done...
>
> Sebastien
>
> jim holtman a écrit :
>
> > Here is one way:
> >
> >> a<-1:10
> >> b<-21:30
> >> mydata<-data.frame(a,b)
> >> mydata.split<-split(mydata,(mydata[,1:2]),drop=TRUE)
> >> x <- mydata.split
> >> # customize the names
> >> names(x) <- sapply(strsplit(names(x), "\\."), paste, collapse="-my
> character-")
> >> x
> > $`1-my character-21`
> >   a  b
> > 1 1 21
> >
> > $`2-my character-22`
> >   a  b
> > 2 2 22
> >
> > $`3-my character-23`
> >   a  b
> > 3 3 23
> > ...
> >
> > On Nov 24, 2007 6:15 PM,  <[EMAIL PROTECTED]> wrote:
> >>
> >> Dear R-users,
> >>
> >> The following code splits a very simple dataframe into a list, each element
> of
> >> the list being one line of the dataframe. You will see that the split
> function
> >> names each element of the list by using uses the content of a and b and
> merging
> >> them with a "." character. Is there a way to customize this character?
> >>
> >> a<-1:10
> >> b<-21:30
> >> mydata<-data.frame(a,b)
> >> mydata.split<-split(mydata,(mydata[,1:2]),drop=TRUE)
> >> mydata.split
> >>
> >> Thanks in advance for your help.
> >>
> >> Sebastien
> >>
> >> __
> >> 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] R2winBUGS & WinBUGS gui

2007-11-25 Thread Evan Cooch

>
> No. The idea is to use BRugs, i.e. OpenBUGS in such cases. If OpenBUGS 
> lacks some features, you are certainly welcome to implement them and 
> send patches to Andrew Thomas.
>
>

Thanks very much. I thought as much, but given that I have had a 0% 
success rate in getting OpenBUGS to run on any GNU/Linux platform, I was 
resigning myself into using winBUGS under wine. I have recently 
installed a different distro on one of my machines - perhaps time to try 
openBUGS again.

__
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] Package Building under Windows with MikTeX 2.6

2007-11-25 Thread Duncan Murdoch
Mark Hempelmann wrote:
> Dear WizaRds,
>
>   I wrote a small function in R and would like to create a package. The 
> necessary documentation is done, Rtools etc. are installed and I am 
> still unable to complete the process under Windows. I did extensive 
> research in the archives and read the Murdoch-Sutherland website on the 
> Rtools and MikTeX hints. I realize that I understand only half or less 
> of what is said there concerning the MikTeX-R interaction in creating 
> packages. I am sorry.
>
>   I also read the very helpful Rossi paper on 'Making R Packages under 
> Windows. A Tutorial' as of 2006/01. I also tried to understand the .pdf 
> on Writing R Extensions Version 2.5.1 (2007-09-04). Because of its 
> condensed form it *might* present a true challenge to the uninitiated. I 
> wish to apologize for not being able to comprehensively follow all of 
> your "prescriptions", as pointed out in the manual: "This section 
> contains a lot of prescriptive comments. They are here as a result of 
> bitter experience. Please do not report problems to R-help unless you 
> have followed all the prescriptions." Therefore, I hesitated long to 
> report my problems, but since I spent long hours without any progress, I 
> simply don't know anymore what to do. Is there anyone willing to help?
>
>   I installed MikTex, Perl, htmlhelp, Rtools and WinEdt for editing 
> purposes, and changed the path in the system environment as follows 
> (Carriage return for readability):
> System Path:
> C:\Programme\Uni\Rtools\bin;
> C:\Programme\Uni\Perl\bin;
> C:\Programme\Uni\Rtools\MinGW\bin;
> C:\Programme\Uni\hmtlhelp;
> C:\Programme\Uni\R\bin;
> C:\Programme\Uni\MikTeX\miktex\bin;
> %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
>
> User Path (?what is this for?)
> C:\Programme\Uni\MikTeX\miktex\bin
>
>   
The user path is prepended to the system path, so you've got miktex 
first.  I'd delete it, because you really want Rtools first.
> R Version: R version 2.5.1 Patched (2007-09-04 r42845)
> Rtools Version: 2.6.0.1216
>   
The tools you have were written to work with R 2.6.0.  I think they'll 
work with 2.5.1, but I'd recommend upgrading R to 2.6.1 (when it is 
released tomorrow).  Building packages is getting easier.
> MikTeX 2.6
>
> Directory Structure MikTeX, R, Rtools, WinEdt etc. (hierarchy with tabs):
> C:\Uni\MikTeX
> C:\Uni\R\
>   bin
>   doc
>   etc
>   include
>   library
>   modules
>   share\
>   licenses
>   locale
>   make
>   perl\
>   R
>   Text
>   R
>   texmf
>   src
>   Tcl
>
> C:\Uni\Rtools
> C:\Uni\WinEdt
> C:\Uni\Perl
> C:\Uni\htmlhelp
>
> I generated the minimal package structure for package mbes via 
> skeleton(), consisting of
> c:\RWork\mbes\
>   man\mbes.Rd
>   man\mbes.package.Rd
>   R\mbes.R
>   DESCRIPTION
>
> and then in a MS DOS command window:
> R CMD check mbes
>
> which called forth the error:
> Error message:
> C:\RWork\mbes>R CMD check mbes
> * checking for working latex ...Error: environment variable TMPDIR not 
> set (or set to unusable value) and no default available.
>   at C:\Programme\Uni\R\share\perl/R/Utils.pm line 73
>   

You should set up TMPDIR (or TEMP, or TMP) to point to a writable directory.

Duncan Murdoch
>   I looked at the path and Utils.pm shows:
> ...
> ### * R_tempfile
> sub R_tempfile {
>  my $pat = "Rutils";
>  $pat = $_[0] if $_[0];
>  R::Vars::error("TMPDIR");
>  my $retval = file_path($R::Vars::TMPDIR,
> $pat . $$ . sprintf("%05d", rand(10**5)));
>
>  my $n=0;
>  while(-e $retval) { # was -f, but want to be able to create such a file
>  $retval = file_path($R::Vars::TMPDIR,
>  $pat . $$ . sprintf("%05d", rand(10**5)));
>  croak "Cannot find unused name for temporary file"
>  if($n++ > 1000);
>  }
>  $retval;
> }
> ### * R_system
> sub R_system
> {
>  my ($cmd, $Renv) = @_;
>  my $tmpf = R_tempfile();
>  if($R::Vars::OSTYPE eq "windows") {
>  open(tmpf, "> $tmpf")
>or die "Error: cannot write to '$tmpf'\n";
>  print tmpf "$cmd $Renv\n";
>  close tmpf;
>  $res = system("sh $tmpf");
>  unlink($tmpf);
>  return $res;
>  } else {
>  return system("$Renv $cmd");
>  }
> }
> ...
>
> I simply don't know what to do. I am very grateful for any help.
> Thank you so much.
> Yours
> Mark
>
> __
> 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.o

Re: [R] R2winBUGS | option to turn off GUI?

2007-11-25 Thread Uwe Ligges
Same answer as the one for your other R-help question "[R] R2winBUGS & 
WinBUGS gui" (November 23).
Folks, sometimes people (like me in this case) are out of office and 
then it might take more then an hour to answer your questions...

Best,
Uwe Ligges



Evan Cooch wrote:
> Greetings -
> 
> I run a multi-pro server box (GNU/Linux), on which I've installed 
> winBUGS under wine. Works fine, and plays nice with r2WinBUGS, provided 
> everything is done through a graphical front-end (either by working from 
> console, or using a virtual desktop via VNC or equivalent).
> 
> However, I'm wondering if there is a way to use R2winBUGS and winBUGS 
> such that winBUGS does not spawn any windows - in other words, have R 
> and R2winBUGS access the winBUGS 'engine', dump everything to coda 
> files, but not generate any windows? I ask because a number of my more 
> 'remote' users have trouble running a graphical interface to the 
> machine. Rather, they'd like to ssh into a shell, run a R script calling 
> R2WinBUGS, then sign off. At present, this doesn't work 'cleanly' 
> because winBUGS keeps trying to open up a window or two. Which, needless 
> to say, doesn't work if you're running things in an ASCII shell from the 
> command line.
> 
> We've looked at the R2winBUGS docs, and found nothing there (or on 
> various drills through what we could find on the web) for how to do this 
> - if it is at all possible.
> 
> Possible? If so, we'd be delighted to be enlightened on how! ;-)
> 
> Thanks very much in advance...
> 
> __
> 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] Hmisc: can not reproduce figure 4 of Statistical Tables and Plots using S and LATEX

2007-11-25 Thread Frank E Harrell Jr
John Smith wrote:
> Dear R-users:
> 
> I can not reproduce figure 4 of *Statistical Tables and Plots using S and
> LATEX* by Prof. Frank Harrell with the following code:
> 
> rm(list=ls())
> library(Hmisc)
> 
> getHdata(pbc)
> attach(pbc)
> age.groups <- cut2(age, c(45,60))
> g <- function(y) apply(y, 2, quantile, c(.25,.5,.75))
> y <- with(pbc, cbind(Chol=chol,Bili=bili))
> # You can give new column names that are not legal S names
> # by enclosing them in quotes, e.g. 'Chol (mg/dl)'=chol
> vars <- with(pbc, c(label(chol), label(bili)))
> label(y) <- paste(vars, collapse=' and ') # Will make nice caption in table
> s3 <- summary(y ~ age.groups + ascites, fun=g, data=pbc)
> s3
> 
> windows(width=10.67, height=6.60)
> par(mfrow=c(1,2), oma=c(3,0,3,0))
> for(ivar in 1:2)
>   {
> isub <- (1:3)+(ivar-1)*3
> print(isub)
> plot(s3, which=isub, main='', xlab=vars[ivar], pch=c(91,16,93))

Add ,reset.par=FALSE before the final ) above.  This will be correct in 
the next version of the document.

Next time please follow the posting guide with regard to specifying 
information about the version of R, platform, and the description of the 
problem you encountered.

Note that you did reproduce the code in the document exactly as it 
produced a pdf file, not an on-screen graphic.

Frank

>   }
> mtitle(paste('Quartiles of', label(y)), cex.m=1.5)
> 
> 
> Could any one help me?
> 
> 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.
> 


-- 
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] Cluster Analysis:build a classifier?

2007-11-25 Thread x_x

Dear Uwe,
Thank you very much for your reply, I think that's why I've done lots of
research on this to no avail. And also, thanks for the suggestion on the
signature.

Best wishes,
Yang

Uwe Ligges wrote:
> 
> x_x wrote:
>> Dear All,
>> I'm currently doing a project about unsupervised learning, and I'll be
>> using
>> R to analyse a few network traffic datasets downloaded off Andrew Moore's
>> website
>> (http://www.cl.cam.ac.uk/Research/SRG/netos/nprobe/data/papers/sigmetrics/index.html).
>>  
>> 
>> Could anyone shed some light on how to build a classifier from the
>> training
>> set A, and then use a validation set B to assess the performance of the
>> classifier? I'm able to group these datasets into groups using hclust()
>> and
>> kmeans() etc., but I don't see the connection between the clustered
>> dataset
>> A and the remaining sets.
>> 
>> Any thoughts would be much appreciated!
>> 
>> Yours sincerely,
>> x_x
> 
> Dear x_x,
> 
> you are confusing unsupervised learning/clustering with supervised 
> learning/classification, I fear. Please ask your teacher/supervisor for 
> getting the terminology right. Please note that it is good practice to 
> sign e-mail messages with your real name.
> 
> Best,
> Uwe Ligges
> 
> __
> 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/Cluster-Analysis%3Abuild-a-classifier--tf4858425.html#a13936790
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] Package Building under Windows with MikTeX 2.6

2007-11-25 Thread Mark Hempelmann
Dear WizaRds,

I wrote a small function in R and would like to create a package. The 
necessary documentation is done, Rtools etc. are installed and I am 
still unable to complete the process under Windows. I did extensive 
research in the archives and read the Murdoch-Sutherland website on the 
Rtools and MikTeX hints. I realize that I understand only half or less 
of what is said there concerning the MikTeX-R interaction in creating 
packages. I am sorry.

I also read the very helpful Rossi paper on 'Making R Packages under 
Windows. A Tutorial' as of 2006/01. I also tried to understand the .pdf 
on Writing R Extensions Version 2.5.1 (2007-09-04). Because of its 
condensed form it *might* present a true challenge to the uninitiated. I 
wish to apologize for not being able to comprehensively follow all of 
your "prescriptions", as pointed out in the manual: "This section 
contains a lot of prescriptive comments. They are here as a result of 
bitter experience. Please do not report problems to R-help unless you 
have followed all the prescriptions." Therefore, I hesitated long to 
report my problems, but since I spent long hours without any progress, I 
simply don't know anymore what to do. Is there anyone willing to help?

I installed MikTex, Perl, htmlhelp, Rtools and WinEdt for editing 
purposes, and changed the path in the system environment as follows 
(Carriage return for readability):
System Path:
C:\Programme\Uni\Rtools\bin;
C:\Programme\Uni\Perl\bin;
C:\Programme\Uni\Rtools\MinGW\bin;
C:\Programme\Uni\hmtlhelp;
C:\Programme\Uni\R\bin;
C:\Programme\Uni\MikTeX\miktex\bin;
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

User Path (?what is this for?)
C:\Programme\Uni\MikTeX\miktex\bin

R Version: R version 2.5.1 Patched (2007-09-04 r42845)
Rtools Version: 2.6.0.1216
MikTeX 2.6

Directory Structure MikTeX, R, Rtools, WinEdt etc. (hierarchy with tabs):
C:\Uni\MikTeX
C:\Uni\R\
bin
doc
etc
include
library
modules
share\
licenses
locale
make
perl\
R
Text
R
texmf
src
Tcl

C:\Uni\Rtools
C:\Uni\WinEdt
C:\Uni\Perl
C:\Uni\htmlhelp

I generated the minimal package structure for package mbes via 
skeleton(), consisting of
c:\RWork\mbes\
man\mbes.Rd
man\mbes.package.Rd
R\mbes.R
DESCRIPTION

and then in a MS DOS command window:
R CMD check mbes

which called forth the error:
Error message:
C:\RWork\mbes>R CMD check mbes
* checking for working latex ...Error: environment variable TMPDIR not 
set (or set to unusable value) and no default available.
  at C:\Programme\Uni\R\share\perl/R/Utils.pm line 73

I looked at the path and Utils.pm shows:
...
### * R_tempfile
sub R_tempfile {
 my $pat = "Rutils";
 $pat = $_[0] if $_[0];
 R::Vars::error("TMPDIR");
 my $retval = file_path($R::Vars::TMPDIR,
$pat . $$ . sprintf("%05d", rand(10**5)));

 my $n=0;
 while(-e $retval) { # was -f, but want to be able to create such a file
 $retval = file_path($R::Vars::TMPDIR,
 $pat . $$ . sprintf("%05d", rand(10**5)));
 croak "Cannot find unused name for temporary file"
 if($n++ > 1000);
 }
 $retval;
}
### * R_system
sub R_system
{
 my ($cmd, $Renv) = @_;
 my $tmpf = R_tempfile();
 if($R::Vars::OSTYPE eq "windows") {
 open(tmpf, "> $tmpf")
   or die "Error: cannot write to '$tmpf'\n";
 print tmpf "$cmd $Renv\n";
 close tmpf;
 $res = system("sh $tmpf");
 unlink($tmpf);
 return $res;
 } else {
 return system("$Renv $cmd");
 }
}
...

I simply don't know what to do. I am very grateful for any help.
Thank you so much.
Yours
Mark

__
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] intercept in lars fit

2007-11-25 Thread Uwe Ligges


Young Cho wrote:
> I am trying to extract coefficients from lars fit and can't find how to get
> intercept. E.g.


Are we talking about the function lars() from package "lars"?


> y = rnorm(10)
> x = matrix(runif(50),nrow=10)
> X = data.frame(y,x)
> fit1 = lars(as.matrix(X[,2:6]),as.matrix(X[,1]))
> fit2 = lm(y~.,data=X)
> 
> Then, if I do:
>> predict(fit1,s=1,mode='fraction',type='coefficients')$coef
> X1 X2 X3 X4 X5
>  0.3447570  0.7715479 -1.1224714  1.0841587 -1.6259571
>> coef(fit2)
> (Intercept)  X1  X2  X3  X4  X5
>   0.3979150   0.3447570   0.7715479  -1.1224714   1.0841587  -1.6259571
> 
> I expect them to be the same but can't find the intercept. How to extract
> intercept from lars fit object?

No idea, perhaps a question for the package author/maintainer?



> Also, if I do:
>> mean(X$y)
> [1] 0.2596246
> 
> This is not intercept from lm fit. what am I missing here?

You are missing how lm() works!

For the model y ~ x, consider x=c(0,1) and y=c(0,1) then the fit has 
intercept 0 but mean(X$y) is 0.5 ...

Uwe Ligges


> Thanks so much.
> 
> Young
> 
>   [[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] R2winBUGS & WinBUGS gui

2007-11-25 Thread Uwe Ligges


Evan Cooch wrote:
> I am trying to figure out if it is possible to run winBUGS from within 
> R, using R2winBUGS, without having winBUGS spawn any windows (basically 
> - 'true' batch - no GUI actions at all). The reason being I have a 
> machine which I (and several others) ssh/telnet into, and would like to 
> run winBUGS without having to mount a virtual desktop of any kind.
> 
> I've looked through the r2winBUGS docs, and there doesn't seem to be any 
> command(s) which I can invoke to simply use the winBUGS 'engine', and 
> not the winBUGS windows.
> 
> Yes, I know I could look at classic BUGS, or openBUGS, but neither work 
> particularly well for my purposes (since the code I'm using makes use of 
> a numb4er of winBUGS 'extensions' which aren't supported in other 
> flavours of BUGS).
> 
> Is this possible in any fashion?

No. The idea is to use BRugs, i.e. OpenBUGS in such cases. If OpenBUGS 
lacks some features, you are certainly welcome to implement them and 
send patches to Andrew Thomas.

Best,
Uwe Ligges


> Thanks in advance...
> 
> __
> 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] Cluster Analysis:build a classifier?

2007-11-25 Thread Uwe Ligges
x_x wrote:
> Dear All,
> I'm currently doing a project about unsupervised learning, and I'll be using
> R to analyse a few network traffic datasets downloaded off Andrew Moore's
> website
> (http://www.cl.cam.ac.uk/Research/SRG/netos/nprobe/data/papers/sigmetrics/index.html).
>  
> 
> Could anyone shed some light on how to build a classifier from the training
> set A, and then use a validation set B to assess the performance of the
> classifier? I'm able to group these datasets into groups using hclust() and
> kmeans() etc., but I don't see the connection between the clustered dataset
> A and the remaining sets.
> 
> Any thoughts would be much appreciated!
> 
> Yours sincerely,
> x_x

Dear x_x,

you are confusing unsupervised learning/clustering with supervised 
learning/classification, I fear. Please ask your teacher/supervisor for 
getting the terminology right. Please note that it is good practice to 
sign e-mail messages with your real name.

Best,
Uwe Ligges

__
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] 'Split' character

2007-11-25 Thread pomchip


Thanks Jim and Herinque for you reply.

The substitution you are both proposing works fine, except when a or b contains
decimal numbers (which is mostly my case in a real dataset). In this case, there
is no distinction between the decimal point and the one introduced by the split
function.
If the split function cannot be customized, then I guess I have to first
substitute the decimal point in my dataset by e.g. a * sign and change it back
to a . when the split is done...

Sebastien

jim holtman a écrit :
> Here is one way:
>
>> a<-1:10
>> b<-21:30
>> mydata<-data.frame(a,b)
>> mydata.split<-split(mydata,(mydata[,1:2]),drop=TRUE)
>> x <- mydata.split
>> # customize the names
>> names(x) <- sapply(strsplit(names(x), "\\."), paste, collapse="-my
character-")
>> x
> $`1-my character-21`
>   a  b
> 1 1 21
>
> $`2-my character-22`
>   a  b
> 2 2 22
>
> $`3-my character-23`
>   a  b
> 3 3 23
> ...
>
> On Nov 24, 2007 6:15 PM,  <[EMAIL PROTECTED]> wrote:
>>
>> Dear R-users,
>>
>> The following code splits a very simple dataframe into a list, each element
of
>> the list being one line of the dataframe. You will see that the split
function
>> names each element of the list by using uses the content of a and b and
merging
>> them with a "." character. Is there a way to customize this character?
>>
>> a<-1:10
>> b<-21:30
>> mydata<-data.frame(a,b)
>> mydata.split<-split(mydata,(mydata[,1:2]),drop=TRUE)
>> mydata.split
>>
>> Thanks in advance for your help.
>>
>> Sebastien
>>
>> __
>> 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] Constructin a call of function including permutation of column names - how to escape parentheses?

2007-11-25 Thread Jiří Voller
Dear R-users,
I would like to construct a list of arguments for a function in a format
function (list(item1=c("A","B"), item2=c("B","C")), item3=...):
The individual vectors in the list are permutations of colnames of a
dataframe.
The trouble is that I am not able to handle escaping of parentheses
correctly.

I was trying the following:
library(gregmisc)
combinations.2<-combinations(12,2,mycolnames)
combinations.2.call<-apply(combinations.2,1,function(x){do.call(paste,c(
as.list(x),sep="\",\""))})
combinations.2.call<-paste("c(\"",combinations.2.call,"\")",sep="")

but now calling call("list",combinations.2.list) doesnt work.


Could anyone give an advice on this? Thank you.

--
Jiøí Voller
Laboratory of Growth Regulators
Palacký University & Institute of Experimental Botany AS CR
©lechtitelù 11, 783 71 Olomouc
Czech Republic
landline: +420-585-634-855
mobile: +420-737-520-506
fax: +420-585-634-870
--

[[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 wait after plotting in BATCH mode?

2007-11-25 Thread Jonas Stein
when i plot with the following command on console:
$ R CMD BATCH cp_messung.R

in the R-script i wrote x11() in the beginning, so it draws a nice plot on
my screen.

But sadly it disappeares after a second or two. How can i make it to wait
until i press a key or something?

thank you.

-- 
kind regards,

Jonas Stein <[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] What is the "deviance " and the "ch ange in deviance" of a logistic regression?

2007-11-25 Thread Bin Yue

Dear all:
 I am confounded by the "deviance" and the "change in deviance" of a
logistic regression ?
 I have a object like this:
   summary(glm1)

Call:
glm(formula = status ~ no.filter + light.filter_2, family = binomial, 
data = re)

Deviance Residuals: 
Min   1Q   Median   3Q  Max  
-0.9774  -0.8063  -0.7586   1.4864   3.0635  

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)-1.155042   0.087014 -13.274  < 2e-16 ***
no.filter   0.057531   0.016475   3.492 0.000479 ***
light.filter_2 -0.037554   0.008619  -4.357 1.32e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 3655.4  on 3172  degrees of freedom
Residual deviance: 3612.5  on 3170  degrees of freedom
  (362 observations deleted due to missingness)
AIC: 3618.5

Number of Fisher Scoring iterations: 5

> deviance(glm1)
[1] 3612.516

is the "deviance(glm1)" the "deviance" ?
If yes, what is the "change in deviance"? Is it "residual
deviance-null.deviance"?
Thanks all .

Best wishes,
Bin Yue 

-
Best regards,
Bin Yue

*
student for a Master program in South Botanical Garden , CAS

-- 
View this message in context: 
http://www.nabble.com/%EF%BC%B7hat-is-the-%22deviance-%22--and-the-%22change-in-deviance%22-of-a-logistic-regression--tf4870005.html#a13935092
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] howto remove all variables (cleanup)

2007-11-25 Thread Gabor Csardi
rm(list=ls())

G.

On Sun, Nov 25, 2007 at 01:12:19PM +0100, Jonas Stein wrote:
> Hi,
> 
> as i am quite new to R i often play around with commands in R until my graph
> looks nice. 
> 
> After testing things there are often lots of variables left. How can i reset
> all vars in one command before i do the final plot?
> 
> At the moment i restart rkward (my editor) but thats a bit uncomfortable...
> 
> -- 
> kind regards,
> 
> Jonas Stein <[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.

-- 
Csardi Gabor <[EMAIL PROTECTED]>MTA RMKI, ELTE TTK

__
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] howto remove all variables (cleanup)

2007-11-25 Thread Denver XU
rm(list=ls(all=TRUE))
but be careful to use it.



2007/11/25, Jonas Stein <[EMAIL PROTECTED]>:
> Hi,
>
> as i am quite new to R i often play around with commands in R until my graph
> looks nice.
>
> After testing things there are often lots of variables left. How can i reset
> all vars in one command before i do the final plot?
>
> At the moment i restart rkward (my editor) but thats a bit uncomfortable...
>
> --
> kind regards,
>
> Jonas Stein <[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-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] howto remove all variables (cleanup)

2007-11-25 Thread Jonas Stein
Hi,

as i am quite new to R i often play around with commands in R until my graph
looks nice. 

After testing things there are often lots of variables left. How can i reset
all vars in one command before i do the final plot?

At the moment i restart rkward (my editor) but thats a bit uncomfortable...

-- 
kind regards,

Jonas Stein <[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] truncated fields with RODBC

2007-11-25 Thread Prof Brian Ripley
You need to study the RODBC documentation: you haven't set the type of the 
character fields in the database table correctly (in fact, you seem not 
to have set them at all, hence will get the default of varchar(255)).

The 64k limit is for reading, not writing.

As ever, full details and a reproducible example are needed for people to 
help you fully.

On Sat, 24 Nov 2007, Mikkel Grum wrote:

> I'm changing some functions from storing data in
> SQLite (using RSQLite) to storing it in PostgreSQL
> (using RODBC). When trying to store very long
> character fields I get the following message:
>
>>sqlSave(pg, Grids, rownames = FALSE, append =
> TRUE)
> Warning messages:
> 1: In odbcUpdate(channel, query, mydata, paramdata,
> test = test, verbose = verbose,  :
>  character data truncated in column 'grids'
> 2: In odbcUpdate(channel, query, mydata, paramdata,
> test = test, verbose = verbose,  :
>  character data truncated in column 'grids'
> 3: In odbcUpdate(channel, query, mydata, paramdata,
> test = test, verbose = verbose,  :
>  character data truncated in column 'grids'
>
> The structure of the dataframe that I'm trying to
> store looks like this:
>> str(Grids)
> 'data.frame':   9 obs. of  4 variables:
> $ ScoutDate: chr  "2007-10-11" "2007-10-11"
> "2007-10-11" "2007-10-11" ...
> $ SectorId : int  93 93 93 93 93 93 93 93 93
> $ Trait: chr  "eTop" "eMB" "nTop" "nMB" ...
> $ Grids: chr  "0 0 0 0 0 0 0 53 6064 2364 61 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 74 482
> 524 51 0 0 157 316 0 0 0 0 0 0 0 0 0 0 0"|
> __truncated__ "45 45 45 45 45 45 45 1 0 0 0 45 45 45
> 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45
> 45 45 45 45 50 68 70 49 46 46 0 0 3"| __truncated__ "0
> 0 0 0 0 0 0 84 18766 7266 111 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 192 1628 1777 112 0 0 409
> 903 0 0 0 0 0 0 0 0"| __truncated__ "94 94 94 94 94 94
> 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94
> 94 94 94 94 94 94 94 94 94 94 94 94 137 312 331 128 94
> "| __truncated__ ...
>
> The same fields could be copied from SQLite into
> PostgreSQL through a | delimited file without any
> error message, so it is not PostgreSQL that is the
> limitation. dbWriteTable in RSQLite was also able to
> handle this without truncating the data. I think these
> fields are 4-5000 characters wide, but don't actually
> know how to get the exact figure.
>
> The offending field is set as a text field in
> PostgreSQL. I'm using psqlODBC on Windows Server 2003
> and R-2.6.0.
>
> Have I missed an argument somewhere that could solve
> the problem? I've read that RODBC has a field length
> limit of 64k. This could be the problem. Is there
> somewhere I could change this in the source code?
> Would that just give me other problems?
>
> Any assistance highly appreciated.
>
> cheers,
> Mikkel

-- 
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] R 2.6 and library(survival)

2007-11-25 Thread Prof Brian Ripley
There is a reproducible example in the MASS survival chapter.  I've 
reported this to the survival maintainer more than once: it's a partial 
matching problem.

On Sat, 24 Nov 2007, Ben Bolker wrote:

>
>
>
> makis motakis-2 wrote:
>>
>> Hi all,
>>
>> I have installed in R 2.6 the survival package and I am trying to analyze
>> some
>> data and present plots. The problem occurs when I try to plot lines on
>> the same plot. E.g. take simulated data for time (t), event (e) and groups
>> (group1 and group2) and do:
>>
>> ### this is how I create the plots
>> plot1<-survfit(Surv(t,e)~ as.factor(group1))
>> plot2<-survfit(Surv(t,e)~ as.factor(group2))
>>
>> plot(plot1)
>> lines(plot2,type="s")
>>Error in rep(2, n2 - 1) : invalid 'times' argument
>>
>> The plot is created (plot1) but the lines (plot2) are not. I have run this
>> same program
>> several times from my previous pc (R 2.4 was installed)and I never had
>> such a problem.
>> Now suddenly this error message appears and it concerns only the survival
>> package (I mean
>> for simple plots there is no problem to plot lines in an existing plot).
>> Is there a problem
>> with R 2.6 on this matter? Can someone please help?
>>
>>
>
> Don't know ... a simple reproducible example would help ...
>
> (Some really really trivial things I tried worked, for example:
>
> z = rexp(100)
> f1 = factor(rep(1:5,each=20))
> f2 = factor(rep(1:2,each=50))
> event = rep(1,100)
> library(survival)
> s1 = survfit(Surv(z,event)~f1)
> s2 = survfit(Surv(z,event)~f2)
> plot(s1)
> lines(s2,col=2,type="s")
>
>> sessionInfo()
> R version 2.6.0 (2007-10-03)
> i486-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] splines   stats graphics  grDevices utils datasets  methods
> [8] base
>
> other attached packages:
> [1] survival_2.34
>
>  Ben Bolker
>
>

-- 
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] how to calculate the return?

2007-11-25 Thread Gabor Grothendieck
On Nov 25, 2007 3:25 AM, Denver XU <[EMAIL PROTECTED]> wrote:
> thank you Gabor, I am sure my data is a data.frame and I think you a
> lillte bit misunderstood my question.

Quoting your post:  "data is a matrix"

Also are you sure you want diff(log(x))?  Your x's include negative numbers.

> thank you Patrick, your answer is what I want to find.
>
>
>
>
> 2007/11/24, Denver XU <[EMAIL PROTECTED]>:
>
> > Hi, R-users,
> >   data is a matrix like this
> >  AMR  BS  GE  HR  MO  UK   SP500
> > 1974 -0.3505 -0.1154 -0.4246 -0.2107 -0.0758  0.2331 -0.2647
> > 1975  0.7083  0.2472  0.3719  0.2227  0.0213  0.3569  0.3720
> > 1976  0.7329  0.3665  0.2550  0.5815  0.1276  0.0781  0.2384
> > 1977 -0.2034 -0.4271 -0.0490 -0.0938  0.0712 -0.2721 -0.0718
> > 1978  0.1663 -0.0452 -0.0573  0.2751  0.1372 -0.1346  0.0656
> > 1979 -0.2659  0.0158  0.0898  0.0793  0.0215  0.2254  0.1844
> > 1980  0.0124  0.4751  0.3350 -0.1894  0.2002  0.3657  0.3242
> > 1981 -0.0264 -0.2042 -0.0275 -0.7427  0.0913  0.0479 -0.0491
> > 1982  1.0642 -0.1493  0.6968 -0.2615  0.2243  0.0456  0.2141
> > 1983  0.1942  0.3680  0.3110  1.8682  0.2066  0.2640  0.2251
> > I want  to calculate the return say AMR,so I use
> > re=numeric(10)
> > for (i in 2:nrow(data))
> > re[1]=0
> >re[i]=log(data[i]/data[i-1])
> > to my surprise, the result is
> > > re
> >  [1]  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
> >  [9]  0.0 -1.70109
> > I don't know what's wrong with my code, and is there alternative way
> > to do the same?
> > thanks
> >
> > Denver
> >
>
> __
> 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] GAM with constraints

2007-11-25 Thread lubaroz

Hi,
I am trying to build GAM with linear constraints, for a general link
function, not only identity. If I understand it correctly, the function
pcls() can solve the problem, if the smoothness penalties are given.
What I need is to incorporate the constraints before calculating the
penalties. Can this be done in R? 
Any help would be greately appreciated.
-- 
View this message in context: 
http://www.nabble.com/GAM-with-constraints-tf4869470.html#a13933749
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 calculate the return?

2007-11-25 Thread Denver XU
thank you Gabor, I am sure my data is a data.frame and I think you a
lillte bit misunderstood my question.
thank you Patrick, your answer is what I want to find.




2007/11/24, Denver XU <[EMAIL PROTECTED]>:
> Hi, R-users,
>   data is a matrix like this
>  AMR  BS  GE  HR  MO  UK   SP500
> 1974 -0.3505 -0.1154 -0.4246 -0.2107 -0.0758  0.2331 -0.2647
> 1975  0.7083  0.2472  0.3719  0.2227  0.0213  0.3569  0.3720
> 1976  0.7329  0.3665  0.2550  0.5815  0.1276  0.0781  0.2384
> 1977 -0.2034 -0.4271 -0.0490 -0.0938  0.0712 -0.2721 -0.0718
> 1978  0.1663 -0.0452 -0.0573  0.2751  0.1372 -0.1346  0.0656
> 1979 -0.2659  0.0158  0.0898  0.0793  0.0215  0.2254  0.1844
> 1980  0.0124  0.4751  0.3350 -0.1894  0.2002  0.3657  0.3242
> 1981 -0.0264 -0.2042 -0.0275 -0.7427  0.0913  0.0479 -0.0491
> 1982  1.0642 -0.1493  0.6968 -0.2615  0.2243  0.0456  0.2141
> 1983  0.1942  0.3680  0.3110  1.8682  0.2066  0.2640  0.2251
> I want  to calculate the return say AMR,so I use
> re=numeric(10)
> for (i in 2:nrow(data))
> re[1]=0
>re[i]=log(data[i]/data[i-1])
> to my surprise, the result is
> > re
>  [1]  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
>  [9]  0.0 -1.70109
> I don't know what's wrong with my code, and is there alternative way
> to do the same?
> thanks
>
> Denver
>

__
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.