[R] Partial loop?

2009-06-27 Thread Hesen Peng
My dear R buddies,

I'm writing a loop program like this:

for(i in 1:n){
   for(j in 1:i){
...
   }
}

I wonder if there is any simple apply()-like function to make the loop
a little bit easier and faster. Thanks a lot.

Best wishes,

-- 
彭河森 Hesen Peng
http://hesen.peng.googlepages.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] compressing the plot's white space

2009-06-27 Thread Alexy Khrabrov
I need to fit a graph into a column of a 2-column paper.  I found that
just specifying width and height parameters (3.2in x 3.5in) to plot
doesn't decrease the fonts of the main title, axis titles, and
labeling numbers, and tick sizes.  So I have to add cex to all labels
and titles and manage ticks.  However, I can't decrease the space
between axis label and numbers on ticks.  Is there a way to place
those numbers inside the plot, and/or explicitly remove most of the
space between the numbers and the axis title?  Also, how should I
specify the margins to achieve best white space elimination?  On
Quartz, decreasing margins seem to squeeze the titles properly, on
postscript device, the axis titles simply move outside the plot.

Cheers,
Alexy

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 50993 point distance matrix, too big to as.matrix, looking for another way to calculate point-level summary

2009-06-27 Thread Romain Francois

Hi,

If you are only interested in row means, you can work the distance 
matrix at the c level.


You might like to adapt this post:
http://tolstoy.newcastle.edu.au/R/e6/devel/09/04/1378.html

Romain

On 06/26/2009 09:40 PM, leif olson wrote:

Hello, Im working on a 50933 point count bird abundance dataset. I've
succeeded in calculating a distance matrix for this entire set, but I don't
have sufficient memory to convert this to a matrix, as below...
abun.dist- dist(abun.mat[1:50993,1:235)
test- rowMeans(as.matrix(abun.dist))
Error in matrix(0, size, size) : too many elements specified

ive been able to run a hclust() clustering procedure, due to the fact that
hclust() makes a call to fortran code, but id like to be able to generate a
calinski index for each of the clusters to assess the validity.
Unfortunately, all the validation routines I have found are all native R
code, and usually call as.matrix, resulting in the same error i receive
above.
What I'd like to figure out is how to just go through, one point at a time,
and calculate the values i need. But I've been unable to come up with code
to call the correct positions in the dist vector, can anyone suggest some
code that might do this? Thanks...

...leif
   



--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Partial loop?

2009-06-27 Thread Hesen Peng
Finally I ended up doing this:

temp - expand.grid(1:n,1:n)
temp-temp[temp[,1]temp[,2]]

apply(temp,1, ... )

and it seems much faster :)

On Sat, Jun 27, 2009 at 3:26 PM, Patrick Burnspbu...@pburns.seanet.com wrote:
 See 'The R Inferno'.



 Patrick Burns
 patr...@burns-stat.com
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of The R Inferno and A Guide for the Unwilling S User)


 Hesen Peng wrote:

 My dear R buddies,

 I'm writing a loop program like this:

 for(i in 1:n){
   for(j in 1:i){
    ...
   }
 }

 I wonder if there is any simple apply()-like function to make the loop
 a little bit easier and faster. Thanks a lot.

 Best wishes,





-- 
彭河森 Hesen Peng
http://hesen.peng.googlepages.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] Compute correlation matrix for panel data with specific ordering

2009-06-27 Thread Serguei Kaniovski

Hello All,

I have a panel date - here a small-scale example:

df - 
data.frame(cbind(rep(c(AUT,BEL,DEN,GER),4),cbind(rep(c(1999,2000,2001,2002),4)),sample(10,16,replace=T)))

names(df) - c(country,year,x)

SORT - c(GER,BEL,DEN,AUT)

I need to compute the correlation between countries in the variable x 
in such a way that the rows  columns of the resulting correlation 
matrix are not in an alphabetical order but in the order of a given 
factor vector - here SORT.


How can I do this? Greatly appreciate any help!

Serguei Kaniovski

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] questions about meta-analysis

2009-06-27 Thread Emmanuel Charpentier
Le samedi 27 juin 2009 à 13:02 +0800, sdzhangping a écrit :
 Dear R users:
 
 In the example of meta-analysis (cochrane, package rmeta), I can not
 found the p-value of Test for overall effect, and some other indices
 (Z, I, weight and et al).  How can I get the these indices listed? 
  library(rmeta)
  data(cochrane)
  cochrane
   name ev.trt n.trt ev.ctrl n.ctrl
 1 Auckland 36   532  60538
 2Block  169   5 61
 3Doran  481  11 63
 4Gamsu 14   131  20137
 5 Morrison  367   7 59
 6 Papageorgiou  171   7 75
 7  Tauesch  856  10 71
  a=meta.MH(n.trt,n.ctrl,ev.trt,ev.ctrl,names=name,data=cochrane)
  summary(a)
 Fixed effects ( Mantel-Haenszel ) meta-analysis
 Call: meta.MH(ntrt = n.trt, nctrl = n.ctrl, ptrt = ev.trt, pctrl =
 ev.ctrl, 
 names = name, data = cochrane)
 
OR (lower  95% upper)
 Auckland 0.580.38   0.89
 Block0.160.02   1.45
 Doran0.250.07   0.81
 Gamsu0.700.34   1.45
 Morrison 0.350.09   1.41
 Papageorgiou 0.140.02   1.16
 Tauesch  1.020.37   2.77
 
 Mantel-Haenszel OR =0.53 95% CI ( 0.39,0.73 ) (where is Z and
 p-value ?)
 Test for heterogeneity: X^2( 6 ) = 6.9 ( p-value 0.3303 )

You might easily recompute them : use the confidence interval to
guesstimate the standard deviation of OR, its value and the damn Z and p
you long for... Remember that it's log(OR) that is (asymptotically)
normally distributed. The weights are proportional to inverse of
variance and sum to 1. You might peek at the source code for
enlightment...

Alternatively, you may grow lazy an use the meta package, whose
function metabin() will give you all that. The recent metafor package
seems also quite interesting.

Another (smarter(?)) alternative is to ask yourself *why* you need Z and
p. Z is just a computing device allowing you to use a known density. And
the real meaning of p and its usefulness has been discussed, disputed
and fought over at exceedingly large lengths in the past 80 years.

Of course, if you have an instructor to please ...

HTH,

Emmanuel Charpentier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Compute correlation matrix for panel data with specific ordering

2009-06-27 Thread Dieter Menne
Serguei Kaniovski Serguei.Kaniovski at wifo.ac.at writes:

 
 df - 

data.frame(cbind(rep(c(AUT,BEL,DEN,GER),4),
 cbind(rep(c(1999,2000,2001,2002),4)),sample(10,16,replace=T)))
 names(df) - c(country,year,x)
 
 SORT - c(GER,BEL,DEN,AUT)
 
 I need to compute the correlation between countries in the variable x 
 in such a way that the rows  columns of the resulting correlation 
 matrix are not in an alphabetical order but in the order of a given 
 factor vector - here SORT.
 

This boils down to : how do I reorder a factor not to use alphabetical order?
There are several reorders around, and you could do it with base function in R,
but I find the following solution using package gdata the most readable:

library(gdata)
df - data.frame(country = sample(c(AUT,BEL,DEN,GER),10,TRUE))
str(df)

SORT - c(GER,BEL,DEN,AUT)
df$countryS = reorder(df$country, new.order=SORT)

Dieter

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


Re: [R] How to automatically placing a legend in empty space

2009-06-27 Thread Dieter Menne
Jason Rupert jasonkrupert at yahoo.com writes:

 At one point I believe I heard of an R package that would automatically find
the most empty space in a plot, and
 then that answer could then be used to intelligently place a legend. 
 

Have a look a some of the plotting function in package Hmisc.

Dieter

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


[R] Creating Excel-Charts via RDCOMClient

2009-06-27 Thread Dr. Michael Wolf
Hi R-users!

I'm trying to create an easy Excel chart using the package RDCOMClient. The
following example is working fine:

#---
library(RDCOMClient)

xlLocationAsObject -2
xlXYScatterSmoothNoMarkers - 73

ex - COMCreate(Excel.Application)
wb - ex[[Workbooks]]$Add()
sh - ex$ActiveSheet()
ex[[Visible]] - TRUE

r - sh$Range(A1:D1)
r[[Value]] - c(1:4)

ch - ex$Charts()
ch$Add()
ac - ex$ActiveChart()
ac[[ChartType]] - xlXYScatterSmoothNoMarkers
ac$Location(Where=xlLocationAsObject, Name=Tabelle1)
ac$SeriesCollection()$NewSeries()
ac$SeriesCollection(1)[[XValues]] - r
ac$SeriesCollection(1)[[Values]] - r
#---

But I don't perfer this way writing calculated values like c(1:4) to the
Excel Sheet and calling them via SeriesCollection. I'm looking for direct
adressing to SeriesCollection. But codes like

ac$SeriesCollection(1)[[XValues]] - asCOMArray(c(1:4))
ac$SeriesCollection(1)[[Values]]  - asCOMArray(c(1:4))

were not successfull. E.g. the code above produces the error message OLE
error 0x800a01a8.

Ok, I know that there are better ways to solve my problem by using the
RExcel/statconn tools. Unfortunately the conditions under which I work
(partly using other computers by adressing R on my working computer) permit
the use of these tools. As I see, my best chance is a solution with
RDCOMClient. (A clipboard solution which I developed some month ago are very
slow when using large data matrices.)

So, could anyone help me solving the problem?

Thanks,

Michael Wolf
Von-Schonebeck-Ring 18
D-48161 Muenster

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] questions about meta-analysis

2009-06-27 Thread David Winsemius

The object a has log.estimates and selog.estimates:
 str(a)
List of 10
 $ logOR : num [1:7] -0.548 -1.804 -1.404 -0.357 -1.055 ...
 $ selogOR   : num [1:7] 0.22 1.11 0.611 0.372 0.715 ...
 $ logMH : num -0.632
 $ selogMH   : num 0.16
snipped remainder of output.

You can also look at the the code of meta.MH:

meta.MH

On Jun 27, 2009, at 1:02 AM, sdzhangping wrote:


Dear R users:

In the example of meta-analysis (cochrane, package rmeta), I can not  
found the p-value of Test for overall effect, and some other indices  
(Z, I, weight and et al).  How can I get the these indices listed?

library(rmeta)
data(cochrane)
cochrane

 name ev.trt n.trt ev.ctrl n.ctrl
1 Auckland 36   532  60538
2Block  169   5 61
3Doran  481  11 63
4Gamsu 14   131  20137
5 Morrison  367   7 59
6 Papageorgiou  171   7 75
7  Tauesch  856  10 71

a=meta.MH(n.trt,n.ctrl,ev.trt,ev.ctrl,names=name,data=cochrane)
summary(a)

Fixed effects ( Mantel-Haenszel ) meta-analysis
Call: meta.MH(ntrt = n.trt, nctrl = n.ctrl, ptrt = ev.trt, pctrl =  
ev.ctrl,

   names = name, data = cochrane)

  OR (lower  95% upper)
Auckland 0.580.38   0.89
Block0.160.02   1.45
Doran0.250.07   0.81
Gamsu0.700.34   1.45
Morrison 0.350.09   1.41
Papageorgiou 0.140.02   1.16
Tauesch  1.020.37   2.77

Mantel-Haenszel OR =0.53 95% CI ( 0.39,0.73 ) (where is Z and p- 
value ?)

Test for heterogeneity: X^2( 6 ) = 6.9 ( p-value 0.3303 )



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Regression; how to get t-values for all parameters estimates

2009-06-27 Thread gzf200
Dear all,

Even after a couple of hours looking at old messages I still haven't found a
solution for my problem. 
I'm trying to fit an additive linear regression model with 2 effects, both
fixed, to some dataset. The function contrasts(effectA) - contr.sum can
gaurantee that the coefficients per parameter sum to one, and the function
dummy.coef provices the estimates of all coefficientss. But I would also like to
be able to obtain the corresponding t-values for ALL parameters (not just the
number of effects minus 1, provided by summary()). Does anyone know how to get
(all of) them?  

Here comes what I've already tried:
## Try data:
 Data - rbinom(1000,50,.9);
 Dates - Sys.Date()-(1000:1)
 facweek - factor(weekdays(Dates,abbreviate=TRUE))
 facmonth - factor(months(Dates,abbreviate=TRUE))
 contrasts(facweek) - contr.sum ;
 contrasts(facmonth) - contr.sum ;
 fit - lm(formula = Data ~ facweek + facmonth)  
 summary(fit)

Call:
lm(formula = Data ~ facweek + facmonth)

Residuals:
Min  1Q  Median  3Q Max 
-8.7498 -1.3774  0.1778  1.5108  5.1643 

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) 45.014520.06976 645.252   2e-16 ***
facweek1-0.371140.16836  -2.204   0.0277 *  
facweek2 0.403600.16836   2.397   0.0167 *  
facweek3-0.199180.16885  -1.180   0.2384
facweek4-0.136890.16834  -0.813   0.4163
facweek5-0.070490.16835  -0.419   0.6755
facweek6 0.409740.16836   2.434   0.0151 *  
facmonth1   -0.120460.22053  -0.546   0.5850
facmonth2   -0.108320.26155  -0.414   0.6789
facmonth30.252810.21731   1.163   0.2450
facmonth40.401610.22627   1.775   0.0762 .  
facmonth5   -0.374090.21731  -1.721   0.0855 .  
facmonth60.066450.26155   0.254   0.7995
facmonth70.136270.22509   0.605   0.5451
facmonth8   -0.047890.21731  -0.220   0.8256
facmonth9   -0.229100.21731  -1.054   0.2920
facmonth10   0.117520.22053   0.533   0.5942
facmonth11  -0.272330.21731  -1.253   0.2104
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 2.174 on 982 degrees of freedom
Multiple R-squared: 0.02673,Adjusted R-squared: 0.009879 
F-statistic: 1.586 on 17 and 982 DF,  p-value: 0.06097 
 print(dummy.coef(fit),digits=3)
Full coefficients are 
   
(Intercept): 45
facweek:Fri Mon Sat Sun Thu Tue
-0.3711  0.4036 -0.1992 -0.1369 -0.0705  0.4097
facmonth:   Apr Aug Dec Feb Jan Jul
-0.1205 -0.1083  0.2528  0.4016 -0.3741  0.0664
   
(Intercept):   
facweek:Wed
-0.0357
facmonth:   Jun Mar May Nov Oct Sep
 0.1363 -0.0479 -0.2291  0.1175 -0.2723  0.1775

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 do I define the method for gcheckboxgroup in gWidgets?

2009-06-27 Thread Michael Lawrence
On Thu, Jun 25, 2009 at 8:29 AM, Bryan Hanson han...@depauw.edu wrote:

 Hi All...

 I¹m trying to build a small demo using gWidgets which permits interactive
 scaling and selection among different things to plot.  I can get the
 widgets
 for scaling to work just fine.  I am using gcheckboxgroup to make the
 (possibly multiple) selections.  However, I can¹t seem to figure out how to
 properly define the gcheckboxgroup; I can draw the widget properly, I think
 my handler would use the svalue right if it actually received it.  Part of
 the problem is using the index of the possible values rather than the
 values
 themselves, but I'm pretty sure this is not all of the problem.  I've been
 unable to find an example like this in any of the various resources I've
 come across.

 BTW,  report.which is really only there for troubleshooting.  It works to
 return the values, I can't get it to return the indices, which are probably
 what I need in this case.

 A demo script is at the bottom and the error is just below.

  tmp - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
 + checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel)


The above code should define the gcheckboxgroup.


  add(tmp, value = 1, expand = TRUE)


I'm not sure what you are trying to add here.



 Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function .add, for signature
 gCheckboxgroupRGtk, guiWidgetsToolkitRGtk2, numeric

 This error suggests that I don't have a method - I agree, but I don't know
 what goes into the method for gcheckboxgroup.

 For the sliders, it's clear to me how the actions and drawing of the
 widgets
 differ, but not so for gcheckboxgroup.

 A big TIA, Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA

 Full Script:

 x - 1:10
 y1 - x
 y2 - x^2
 y3 - x^0.5
 y4 - y^3
 df - as.data.frame(cbind(x, y1, y2, y3, y4))
 stuff - c(y = x, y = x^2, y = x^0.5, y = x^3)
 which.y - 2 # inital value, to be changed later by the widget

 # Define a function for the widget handlers

 update.Plot - function(h,...) {
plot(df[,1], df[,svalue(which.y)], type = l,
ylim = c(0, svalue(yrange)), main = Interactive Selection  Scaling,
xlab = x values, ylab = y values)
}

 report.which - function(h, ...) { print(svalue(h$obj), index = TRUE) }



In the above handler, do you mean to pass the 'index' parameter to the
svalue() function?




 # Define the actions  type of widget, along with returned values.
 # Must be done before packing widgets.

 yrange - gslider(from = 0, to = max(y), by = 1.0,
value = max(y), handler = update.Plot)
 which.y - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
checked = c(TRUE, FALSE, FALSE, FALSE, FALSE))

 # Assemble the graphics window  groups of containers

 mainWin - gwindow(Interactive Plotting)
 bigGroup - ggroup(cont = mainWin)
 leftPanel - ggroup(horizontal = FALSE, container = bigGroup)

 # Format and pack the widgets,  link to their actions/type

 tmp - gframe(y range, container = leftPanel)
 add(tmp, yrange, expand = TRUE)
 tmp - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel)
 add(tmp, value = 1, expand = TRUE)


 # Put it all together

 add(mainWin, ggraphics()) # puts the active graphic window w/i mainWin

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


[[alternative HTML version deleted]]

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


Re: [R] parallel R?

2009-06-27 Thread Max Kuhn
For cross-validation, the caret package was designed to easily go  
between sequential and parallel processing (using nws, mpi or anything  
else).


See the last examples in ?train.

Max



On Jun 26, 2009, at 11:28 AM, Michael comtech@gmail.com wrote:


I guess when we move to Amazon AWS,

we have to rewrite the whole R programs?

On Fri, Jun 26, 2009 at 8:05 AM, Dirk Eddelbuettele...@debian.org  
wrote:


On 26 June 2009 at 07:40, Michael wrote:
| Hi all,
|
| Lots of big IT companies are renting out their computing  
facilities.

| Amazon has one such service. In my understanding, this will
| dramatically improve the speed of my R program -- currently the  
cross
| validation and model selection part is the bottle neck. It take a  
few

| days to just finish optimal parameter tuning via CV.
|
| Could anybody shed some lights on this? Is it completely  
transparent

| to move my R program to a rented parallel computing facility?
|
| Moreover, at my PC level, I have a 4-core PC, is there anything we
| could do in R to speed up my CV programs?

Try this link:   http://lmgtfy.com/?q=parallel+computing+with+R

A survey paper on parallel computing with R by Schmidberger et al  
will be

fortcoming shortly in Journal of Statistical Software -- that is at
http://jstatsoft.org and a Google query will lead to preprints.

Also note that R has a support site network called 'CRAN' which  
contains so

called 'Task Views'. Amnong these you may find this one of interest:

  http://cran.r-project.org/web/views/HighPerformanceComputing.html

As to your initial question:  yes, people do use R on the Amazon  
service.


Dirk

--
Three out of two people have difficulties with fractions.



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


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


Re: [R] How do I define the method for gcheckboxgroup in gWidgets?

2009-06-27 Thread Bryan Hanson
Thanks Michael...

I was working by analogy to the gbuttons, so I was trying to ³add² the
gcheckboxgroup, which is apparently not necessary (due to, I guess, the
intrinsic differences between the widgets).  The index thing I was just
screwed up on!  I have it working now.

Nice package.  Bryan


On 6/27/09 8:25 AM, Michael Lawrence mflaw...@fhcrc.org wrote:

 
 
 On Thu, Jun 25, 2009 at 8:29 AM, Bryan Hanson han...@depauw.edu wrote:
 Hi All...
 
 I¹m trying to build a small demo using gWidgets which permits interactive
 scaling and selection among different things to plot.  I can get the widgets
 for scaling to work just fine.  I am using gcheckboxgroup to make the
 (possibly multiple) selections.  However, I can¹t seem to figure out how to
 properly define the gcheckboxgroup; I can draw the widget properly, I think
 my handler would use the svalue right if it actually received it.  Part of
 the problem is using the index of the possible values rather than the values
 themselves, but I'm pretty sure this is not all of the problem.  I've been
 unable to find an example like this in any of the various resources I've
 come across.
 
 BTW,  report.which is really only there for troubleshooting.  It works to
 return the values, I can't get it to return the indices, which are probably
 what I need in this case.
 
 A demo script is at the bottom and the error is just below.
 
  tmp - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
 +     checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel)
 
 The above code should define the gcheckboxgroup.
 
  add(tmp, value = 1, expand = TRUE)
 
 I'm not sure what you are trying to add here.
  
 
 Error in function (classes, fdef, mtable)  :
   unable to find an inherited method for function .add, for signature
 gCheckboxgroupRGtk, guiWidgetsToolkitRGtk2, numeric
 
 This error suggests that I don't have a method - I agree, but I don't know
 what goes into the method for gcheckboxgroup.
 
 For the sliders, it's clear to me how the actions and drawing of the widgets
 differ, but not so for gcheckboxgroup.
 
 A big TIA, Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA
 
 Full Script:
 
 x - 1:10
 y1 - x
 y2 - x^2
 y3 - x^0.5
 y4 - y^3
 df - as.data.frame(cbind(x, y1, y2, y3, y4))
 stuff - c(y = x, y = x^2, y = x^0.5, y = x^3)
 which.y - 2 # inital value, to be changed later by the widget
 
 # Define a function for the widget handlers
 
 update.Plot - function(h,...) {
     plot(df[,1], df[,svalue(which.y)], type = l,
     ylim = c(0, svalue(yrange)), main = Interactive Selection  Scaling,
     xlab = x values, ylab = y values)
     }
 
 report.which - function(h, ...) { print(svalue(h$obj), index = TRUE) }
 
 
 In the above handler, do you mean to pass the 'index' parameter to the
 svalue() function?
  
 
 
 # Define the actions  type of widget, along with returned values.
 # Must be done before packing widgets.
 
 yrange - gslider(from = 0, to = max(y), by = 1.0,
     value = max(y), handler = update.Plot)
 which.y - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
     checked = c(TRUE, FALSE, FALSE, FALSE, FALSE))
 
 # Assemble the graphics window  groups of containers
 
 mainWin - gwindow(Interactive Plotting)
 bigGroup - ggroup(cont = mainWin)
 leftPanel - ggroup(horizontal = FALSE, container = bigGroup)
 
 # Format and pack the widgets,  link to their actions/type
 
 tmp - gframe(y range, container = leftPanel)
 add(tmp, yrange, expand = TRUE)
 tmp - gcheckboxgroup(stuff, handler = report.which, index = TRUE,
     checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel)
 add(tmp, value = 1, expand = TRUE)
 
 
 # Put it all together
 
 add(mainWin, ggraphics()) # puts the active graphic window w/i mainWin
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


[[alternative HTML version deleted]]

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


Re: [R] compressing the plot's white space

2009-06-27 Thread Duncan Murdoch

On 27/06/2009 3:06 AM, Alexy Khrabrov wrote:

I need to fit a graph into a column of a 2-column paper.  I found that
just specifying width and height parameters (3.2in x 3.5in) to plot
doesn't decrease the fonts of the main title, axis titles, and
labeling numbers, and tick sizes. 


I normally plot somewhat larger than I'd like the plot displayed, and 
shrink it to fit.  This reduces everything proportionally.


 So I have to add cex to all labels

and titles and manage ticks.  However, I can't decrease the space
between axis label and numbers on ticks. 


That is controlled by par(mgp).

Duncan Murdoch

 Is there a way to place

those numbers inside the plot, and/or explicitly remove most of the
space between the numbers and the axis title?  Also, how should I
specify the margins to achieve best white space elimination?  On
Quartz, decreasing margins seem to squeeze the titles properly, on
postscript device, the axis titles simply move outside the plot.

Cheers,
Alexy

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Creating Excel-Charts via RDCOMClient

2009-06-27 Thread Erich Neuwirth
The statconn tools allow you configure your application
with the Excel client on one machine and the R server
on another machine. In (D)COM, the D stands for
distributed COM.



Dr. Michael Wolf wrote:
 Hi R-users!
 
 I'm trying to create an easy Excel chart using the package RDCOMClient. The
 following example is working fine:
 
 #---
 library(RDCOMClient)
 
 xlLocationAsObject -2
 xlXYScatterSmoothNoMarkers - 73
 
 ex - COMCreate(Excel.Application)
 wb - ex[[Workbooks]]$Add()
 sh - ex$ActiveSheet()
 ex[[Visible]] - TRUE
 
 r - sh$Range(A1:D1)
 r[[Value]] - c(1:4)
 
 ch - ex$Charts()
 ch$Add()
 ac - ex$ActiveChart()
 ac[[ChartType]] - xlXYScatterSmoothNoMarkers
 ac$Location(Where=xlLocationAsObject, Name=Tabelle1)
 ac$SeriesCollection()$NewSeries()
 ac$SeriesCollection(1)[[XValues]] - r
 ac$SeriesCollection(1)[[Values]] - r
 #---
 
 But I don't perfer this way writing calculated values like c(1:4) to the
 Excel Sheet and calling them via SeriesCollection. I'm looking for direct
 adressing to SeriesCollection. But codes like
 
 ac$SeriesCollection(1)[[XValues]] - asCOMArray(c(1:4))
 ac$SeriesCollection(1)[[Values]]  - asCOMArray(c(1:4))
 
 were not successfull. E.g. the code above produces the error message OLE
 error 0x800a01a8.
 
 Ok, I know that there are better ways to solve my problem by using the
 RExcel/statconn tools. Unfortunately the conditions under which I work
 (partly using other computers by adressing R on my working computer) permit
 the use of these tools. As I see, my best chance is a solution with
 RDCOMClient. (A clipboard solution which I developed some month ago are very
 slow when using large data matrices.)
 
 So, could anyone help me solving the problem?
 
 Thanks,
 
 Michael Wolf
 Von-Schonebeck-Ring 18
 D-48161 Muenster
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] questions about meta-analysis

2009-06-27 Thread Michael Dewey

At 06:02 27/06/2009, sdzhangping wrote:

Dear R users:

In the example of meta-analysis (cochrane, package rmeta), I can not 
found the p-value of Test for overall effect, and some other indices 
(Z, I, weight and et al).  How can I get the these indices listed?

 library(rmeta)
 data(cochrane)
 cochrane
  name ev.trt n.trt ev.ctrl n.ctrl
1 Auckland 36   532  60538
2Block  169   5 61
3Doran  481  11 63
4Gamsu 14   131  20137
5 Morrison  367   7 59
6 Papageorgiou  171   7 75
7  Tauesch  856  10 71
 a=meta.MH(n.trt,n.ctrl,ev.trt,ev.ctrl,names=name,data=cochrane)


If at this point you do str(a) you will find what a contains which 
may or may not help you answer your question.

Similarly str(summary(a)) may also be revealing.

Of course R lets you do anything you want but if the author did not 
print out a test and a p-value you might like to ask yourself whether 
that  suggests anything (as someone has already pointed out in another reply).



 summary(a)
Fixed effects ( Mantel-Haenszel ) meta-analysis
Call: meta.MH(ntrt = n.trt, nctrl = n.ctrl, ptrt = ev.trt, pctrl = ev.ctrl,
names = name, data = cochrane)

   OR (lower  95% upper)
Auckland 0.580.38   0.89
Block0.160.02   1.45
Doran0.250.07   0.81
Gamsu0.700.34   1.45
Morrison 0.350.09   1.41
Papageorgiou 0.140.02   1.16
Tauesch  1.020.37   2.77

Mantel-Haenszel OR =0.53 95% CI ( 0.39,0.73 ) (where is Z and p-value ?)
Test for heterogeneity: X^2( 6 ) = 6.9 ( p-value 0.3303 )



Thanks
Yours Ping Zhang


[[alternative HTML version deleted]]


Michael Dewey
http://www.aghmed.fsnet.co.uk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] changing default arguments of a function and return the modified function as a result

2009-06-27 Thread baptiste auguie
see also `%but%.character` in the operators package.

rnorm %but% list( mean = 3 )

function (n, mean = 3, sd = 1)
.Internal(rnorm(n, mean, sd))
environment: namespace:stats


baptiste

[[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] How to read a specific dataset, not the entire data, from HDF5?

2009-06-27 Thread Daehyok Shin
Thanks, Felix.
You are watching new questions here.
I will give a try to rgdal and let you know the result.
BTW, it is surprising to me that there seems no R package handling
HDF5 like PyTables does for Python community, considering HDF5 is as
popular as NetCDF as a file format for scientific data. I hope the gap
will be filled in near future.

Regards,

DH

2009/6/27 Felix Andrews fe...@nfrac.org:
 Hi DH

 I recommend the rgdal package, which provides R bindings for the
 Geospatial Data Abstraction Library (GDAL). This does handle HDF5,
 according to the list at http://www.gdal.org/formats_list.html

 I have not ever used HDF5 myself, but that it what I would try.

 -Felix


 2009/6/27 Daehyok Shin sdh...@gmail.com:
 Hi. Recently I am working for  a project to generate massive numeric data.
 After storing them in HDF5 using PyTables, we are trying to use R for
 data analysis and visualisation.
 Surprising to me, however, I could not find a R package to allow the
 reading of a specific dataset (or its slide) in a HDF5 file.
 I found I can read and write only the entire data using hdf5 package
 and I could not locate rhdf5 in bioconductor.
 Each dataset is huge, so selecting a specific dataset is a mandatory
 function for my project.
 Could you give me a hint for the solution? Thanks.

 --
 DH

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




 --
 Felix Andrews / 安福立
 Post-Doctoral Fellow
 Integrated Catchment Assessment and Management (iCAM) Centre
 Fenner School of Environment and Society [Bldg 48a]
 The Australian National University
 Canberra ACT 0200 Australia
 M: +61 410 400 963
 T: + 61 2 6125 1670
 E: felix.andr...@anu.edu.au
 CRICOS Provider No. 00120C
 --
 http://www.neurofractal.org/felix/




-- 
Daehyok Shin, PhD
Geography Department
University of North Carolina-Chapel Hill
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] panel.text and saving to pdf

2009-06-27 Thread Uwe Ligges
If it is not the device then it's probably just the usage of an 
unexpected unit somewhere - as reported in another reply by another 
helper to your original question on R-help.


Best,
Uwe Ligges


willem vervoort wrote:

Hi Uwe,

I should send these messages from my member e-mail number

Thanks for that.
As you can see from the last bit of my code, I tried that, but it gave
the same results. I had a look at pdf.options() but didn't see
anything there either to make the text stay on the same spot. It seems
to also happen if you use png().


Willem




From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
Sent: Fri 6/26/2009 6:47 PM
To: Willem Vervoort
Cc: r-help@r-project.org
Subject: Re: [R] panel.text and saving to pdf


To get reproducible results, I highly recommend to print the lattice
graphics directly into the desired device, i.e. start the pdf (or jpeg
or whatever) device before printing.

Best,
Uwe Ligges



Willem Vervoort wrote:

Dear all,

I am not sure what I am doing wrong, but I have some unexplained behaviour when 
saving a lattice graph including text to a pdf file. The text seems to move 
around. It must have something to do with the way coordinates are set in 
devices other than jpg.

Any suggestions would be helpful
Willem

Here is some example code

setwd(c:/willem/research/misc)
today - format(Sys.Date(),%Y%m%d)


x - runif(500)
y - rnorm(500)

foo - data.frame(x = x, y = y, z = rep(c(a,b),250))
require(lattice)

xyplot(x~y|z,data=foo)
panel.text(370,470,silly graph,cex=1.2,font=2)
savePlot(paste(today, jpgplot,sep=_),type=jpg) # this plots fine and text 
is as on the screen
savePlot(paste(today, pdfplot,sep=_),type=pdf) # text has moved

pdf(paste(today,pdfplot2.pdf,sep=_)) # no difference using pdf
xyplot(x~y|z,data=foo)
panel.text(370,470,silly graph,cex=1.2,font=2)
dev.off()

# There is also no difference

   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  9.0
year   2009
month  04
day17
svn rev48333
language   R
version.string R version 2.9.0 (2009-04-17)

-
Dr. R.W. Vervoort
McCaughey Senior Lecturer Hydrology and Catchment Management
Faculty of Agriculture, Food and Natural Resources,
Bldg A04, The University of Sydney, NSW 2006
http://tinyurl.com/mccaughey
http://blogs.usyd.edu.au/waterhydrosu
ph: +61 2 9351 8744
fax: +61 2 9351 4953

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


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


Re: [R] Re gression; how to get t-values for all parameters estimates

2009-06-27 Thread Dieter Menne



gzf200 wrote:
 
 Even after a couple of hours looking at old messages I still haven't found
 a
 solution for my problem. 
 I'm trying to fit an additive linear regression model with 2 effects, both
 fixed, to some dataset. The function contrasts(effectA) - contr.sum can
 gaurantee that the coefficients per parameter sum to one, and the function
 dummy.coef provices the estimates of all coefficientss. But I would also
 like to
 be able to obtain the corresponding t-values for ALL parameters (not just
 the
 number of effects minus 1, provided by summary()). Does anyone know how to
 get
 (all of) them?  
 
 

Trying to fit months and weeks as a series of categorical variables and
picking the asterisks is a path to disaster and hopefully not used to model
the future economic of our economy. 

If you must, you can check function estimable in package gmodels,  package
multcomp, package contrast, and several functions in Hmisc.

Dieter


-- 
View this message in context: 
http://www.nabble.com/Regression--how-to-get-t-values-for-all-parameters-estimates-tp24232820p24234659.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Looking for Rdonlp2

2009-06-27 Thread Paul Smith
Dear All,

I tried to download the package Rdonlp2 from the address given at
CRAN Task View: Optimization and Mathematical Programming:

http://arumat.net/Rdonlp2/

However, this link seems to be dead. Any ideas?

Thanks in advance,

Paul

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


Re: [R] a plot of stacked boxes

2009-06-27 Thread jim holtman
check out 'map.market' in the 'portfolio' package.

On Fri, Jun 26, 2009 at 11:27 PM, Osman Al-Radi osman.al.r...@gmail.comwrote:

 Dear Richard and David,

 Thanks for this reference. I looked into vcd and mosaic plot, it is a nice
 plot for investigating associations between two or more variables. However,
 I just need to plot the frequency of a single variable as the area of the
 box. boxes are stacked to fill a larger box that represents the entire
 population. The axes are non-informative.

 I am trying to recreate the plot in the following website, used to
 represent
 the market capital of public companies. I would like to use a similar plot
 for a totally different application.

 The website: http://finviz.com/map.ashx

 The color code in the above link represents daily change in the stocks, in
 my intended plot I would like the color shade to represent the outcome
 (probability of an event in a predefined time usually 1 year).

 I am again grateful for your assistance.

 Osman



 Osman O. Al-Radi, MD, MSc, FRCSC
 Staff Cardiovascular Surgeon
 Co-medical director, Tissue Bank
 The Hospital for Sick Children
 University of Toronto, Canada


 On Fri, Jun 19, 2009 at 6:55 PM, Richard M. Heiberger r...@temple.edu
 wrote:

  I think you are looking for mosaic()
 
  table(df)
  library(vcd)
  mosaic(outcome ~ group, data=df)
 
  Rich
 

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[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] gradient fill of a grid.polygon

2009-06-27 Thread baptiste auguie
Following up on my previous post.

I've managed to have the function return a gList rather than plot everything
directly, but I get a rather obscure error message when I try to wrap the
grobs in a gTree with a rotated viewport,

Error in x$children[[i]] : attempt to select less than one element

however the same syntax works for simpler gTree such as,

g -
polygonGrob(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(fill=NA,
col=grey90))
gg - gTree(children=gList(gList(clipGrob(), g)))
grid.draw(gg)

Any idea?

Below is the new code,

library(grid)

rotate.polygon - function(g, angle=0){

matR - matrix(c(cos(angle), -sin(angle), sin(angle), cos(angle)),
nrow = 2)
gravity.x = unit(mean(g$x),npc)
gravity.y = unit(mean(g$y),npc)

x.center = convertX(g$x - gravity.x ,npc,TRUE)
y.center = convertY(g$y - gravity.y ,npc,TRUE)

new.xy - matrix(c(x.center, y.center),
ncol=2) %*% matR

editGrob(g, x=unit(new.xy[,1],npc) + gravity.x,
y=unit(new.xy[,2],npc) + gravity.y)
}


gradient.polygon - function(g, n=10,
 cols=colorRampPalette(c(#E41A1C, #377EB8, #4DAF4A, #984EA3))(n),
alpha=0.5,
 stripe=FALSE, angle=pi/3){

gx - grobWidth(g)
gy - grobHeight(g)

dx - unit(convertX(gx, npc, valueOnly = TRUE)/(n-1), npc)

startx - min(g$x)
starty - min(g$y)

vp = viewport(angle = angle)
g =  rotate.polygon(g, - angle)
g.all - gList()
for(ii in seq(1, n)){
clip.tmp - clipGrob(x= startx + (ii-1) * dx , y=starty,
   width= 1.0*dx, # fudge factor to overlap well
   height=gy,
   just=bottom)
if(stripe){
  if(ii%%2)# testing with every other masked
g.tmp - editGrob(g, gp=gpar(fill=cols[ii], col=cols[ii], alpha=alpha))
}else{
g.tmp - editGrob(g, gp=gpar(fill=cols[ii], col=NA,lwd=0, alpha=alpha))
}
g.all[[ii]] - gList(clip.tmp, g.tmp)

}
## return(gTree(children=g.all, vp=vp)) # this fails

g.all # simply return the gList for now
}

g -
polygonGrob(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(fill=NA,
col=grey90))

g4 - gradient.polygon(g)

grid.draw(g4) # fine but not in the correct orientation

g6 - gTree(children=g4, vp=viewport(angle=30))
grid.draw(g6)
# Error in x$children[[i]] : attempt to select less than one element
grid.ls(g6) # looks similar to the minimal example of above

[[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] Bayesian Model Averaging

2009-06-27 Thread David S. Schwarz
Two questions pertaining to the iBMA.glm procedure:

 

1)  Does prior.param=1 force variables into the model as it does in
S-Plus? If not, how can I force the first p variables into every model?

2)  Is there some way in which to suppress the intercept as in the case
of origin models?


[[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] data formatting

2009-06-27 Thread James Martin
All,

I have three columns of data: id, date, hab. I am trying to set up a matrix
that has the id as the rows, date as columns, and the hab value as the data
values.  Each id/date combination can only have one hab value.  I would like
for it to look something like this
 date 1, date 2, date 3.
id
0001 21 2
0002 3 56

I don't know how to set this up properly. I am pretty sure dates cannot be
used in a matrix, but I can easily convert this to an integer. I am mainly
unsure of the functions to use to do this operation.

Thank you

[[alternative HTML version deleted]]

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


Re: [R] Looking for Rdonlp2

2009-06-27 Thread David Winsemius
Not sure what word in my prior message triggered the list-filter but  
this is what I got after a bit of cutting  and pasting on the link  
offered:



This directory does not contain anymore the source of DONLP2.
The code is available for some users from its author, Peter Spellucci,
spellu...@mathematik.tu-darmstadt.de


-- DW
On Jun 27, 2009, at 2:06 PM, Paul Smith wrote:


Dear All,

I tried to download the package Rdonlp2 from the address given at
CRAN Task View: Optimization and Mathematical Programming:

http://arumat.net/Rdonlp2/

However, this link seems to be dead. Any ideas?

Thanks in advance,

Paul

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] data formatting

2009-06-27 Thread jim holtman
Is this what you are after (uses the reshape package)

 # test data
 x - expand.grid(id=1:5, date=seq(as.Date('2009-01-01'), by='1 day',
length=5))
 x$hab - seq(nrow(x))  # add hab
 head(x)
  id   date hab
1  1 2009-01-01   1
2  2 2009-01-01   2
3  3 2009-01-01   3
4  4 2009-01-01   4
5  5 2009-01-01   5
6  1 2009-01-02   6
 require(reshape)
 x.melt - melt(x, measure='hab')
 cast(x.melt, id ~ date)
  id 2009-01-01 2009-01-02 2009-01-03 2009-01-04 2009-01-05
1  1  1  6 11 16 21
2  2  2  7 12 17 22
3  3  3  8 13 18 23
4  4  4  9 14 19 24
5  5  5 10 15 20 25


On Sat, Jun 27, 2009 at 7:40 PM, James Martin just.strut...@gmail.comwrote:

 All,

 I have three columns of data: id, date, hab. I am trying to set up a matrix
 that has the id as the rows, date as columns, and the hab value as the data
 values.  Each id/date combination can only have one hab value.  I would
 like
 for it to look something like this
 date 1, date 2, date 3.
 id
 0001 21 2
 0002 3 56

 I don't know how to set this up properly. I am pretty sure dates cannot be
 used in a matrix, but I can easily convert this to an integer. I am mainly
 unsure of the functions to use to do this operation.

 Thank you

[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

[[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] how to interpret coefficients for a natural spline smooth function in a GLM

2009-06-27 Thread spencerg
 I have not seen a reply to this question, so I will offer a 
comment;  someone who knows more than I may correct or add to my comments. 



 There are many different kinds of splines.  Perhaps the most 
common are B-splines, which sum to 1 inside their range of definition 
and are 0 outside.  Natural splines are similar, but support 
extrapolation outside the (finite) range of definition.  A natural cubic 
spline extrapolates as straight lines 
(http://en.wikipedia.org/wiki/Spline_interpolation). 



 The coefficients are weights for a B-spline basis for the natural 
spline, defined in terms of the knots. 



 The fda package includes a TaylorSpline function to translate 
spline coefficients into the coefficients of Taylor expansions about the 
midpoints of the intervals between knots.  However, I do not know if it 
will work with a natural spline. 



 This is far from a complete answer to your question, but I hope it 
helps. 



 Spencer Graves

ltracy wrote:

Hello-

I am trying to model infections counts over 120 months using a GLM in R. 
The model is simple really including a factor variable for year (10 yrs in

total) and another variable consisting of a natural spline function for time
in months.  


My code for the GLM is as follows:
model1-glm(ALL_COUNT~factor(FY)+ns(1:120, 10), offset=log(TOTAL_PTS),
family=poisson, data=TS1)

The summary output pertaining to the smooth function consists of 10
coefficients for each df in the model.  Here are the coefficients:

ns(1:120, 10)1  -0.724380.32773  -2.210 0.027084 *  
ns(1:120, 10)2  -1.190970.37492  -3.177 0.001490 ** 
ns(1:120, 10)3  -1.402500.42366  -3.310 0.000931 ***
ns(1:120, 10)4  -0.827220.47459  -1.743 0.081334 .  
ns(1:120, 10)5  -0.461390.49657  -0.929 0.352812
ns(1:120, 10)6  -0.448920.51909  -0.865 0.387137
ns(1:120, 10)7  -0.530600.54783  -0.969 0.332778
ns(1:120, 10)8  -0.256990.55582  -0.462 0.643814
ns(1:120, 10)9  -0.740910.63899  -1.160 0.246249
ns(1:120, 10)10  0.411420.56317   0.731 0.465054   


What is still unclear to me is what these 10 coefficients from the natural
spline represent.  


Thanks in advace-







__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Defining class as a member of another class

2009-06-27 Thread R_help Help
Hi,

When I define a new class (through setClass), members defined in
representation argument doesn't seem to like a class. For example, if
I do the following:

setClass(NotWork,representation=(x=zoo))

It seems to me that representation members will take in only primitive
type to R. Is there any way to stuff a class as a member in another
class? Thank you.

- adschai

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Defining class as a member of another class

2009-06-27 Thread Gabor Grothendieck
Try this:

 setClass(zoo)
[1] zoo
 setClass(Work,representation=(x=zoo))
[1] Work


On Sat, Jun 27, 2009 at 10:01 PM, R_help Helprhelp...@gmail.com wrote:
 Hi,

 When I define a new class (through setClass), members defined in
 representation argument doesn't seem to like a class. For example, if
 I do the following:

 setClass(NotWork,representation=(x=zoo))

 It seems to me that representation members will take in only primitive
 type to R. Is there any way to stuff a class as a member in another
 class? Thank you.

 - adschai

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Defining class as a member of another class

2009-06-27 Thread R_help Help
Thank you Gabor. It works. I read a bit more and understood what you're doing.

One more question, I want to know more about .Data property of a
class. I know that it defines type of the class when asking typeof.
But I don't know much how to use them. Would you mind pointing me to
some reference and example? Thank you again!

ads

On Sat, Jun 27, 2009 at 10:29 PM, Gabor
Grothendieckggrothendi...@gmail.com wrote:
 Try this:

 setClass(zoo)
 [1] zoo
 setClass(Work,representation=(x=zoo))
 [1] Work


 On Sat, Jun 27, 2009 at 10:01 PM, R_help Helprhelp...@gmail.com wrote:
 Hi,

 When I define a new class (through setClass), members defined in
 representation argument doesn't seem to like a class. For example, if
 I do the following:

 setClass(NotWork,representation=(x=zoo))

 It seems to me that representation members will take in only primitive
 type to R. Is there any way to stuff a class as a member in another
 class? Thank you.

 - adschai

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



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


Re: [R] How to automatically placing a legend in empty space

2009-06-27 Thread Jason Rupert

I really apprecaite the suggestion.  I just downloaded the Hmisc.pdf document 
and looked through it.  Do you have any further thoughts about a specific 
function within the Hmisc package? 

I looked at largest.empty, but not sure how that is applicable to my data 
points. 


x = seq(0, 1000, by = 1)
y1_vals-rnorm(1000, mean = 0, sd = 50)
y2_vals-rnorm(1000, mean = 25, sd = 40)
y3_vals-rnorm(1000, mean = 115, sd = 40)

plot(x_vals, y1_vals, pch=22, col=dark red, bg = dark red, cex =0.3)
points(x_vals, y2_vals, pch=22, col=dark blue, bg = dark blue, cex =0.3)
points(x_vals, y3_vals, pch=22, col=dark green, bg = dark green, cex =0.3)

abline(h=0, col=dark red, lwd=1.5, lty=6)
abline(h=25, col=dark blue, lwd=1.5, lty=6)
abline(h=115, col=dark green, lwd=1.5, lty=6)

legend(topright, c(Best Guess 1 , Best Guess 2, Best Guess 3), 
bg=white, lwd = 2, title = Randomness:)

Is there any chance you can provide a suggestion?

Thanks again.



--- On Sat, 6/27/09, Dieter Menne dieter.me...@menne-biomed.de wrote:

 From: Dieter Menne dieter.me...@menne-biomed.de
 Subject: Re: [R] How to automatically placing a legend in empty space
 To: r-h...@stat.math.ethz.ch
 Date: Saturday, June 27, 2009, 5:37 AM
 Jason Rupert jasonkrupert
 at yahoo.com writes:
 
  At one point I believe I heard of an R package that
 would automatically find
 the most empty space in a plot, and
  then that answer could then be used to intelligently
 place a legend. 
  
 
 Have a look a some of the plotting function in package
 Hmisc.
 
 Dieter
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] applying a function to a pair of components for each row of a list

2009-06-27 Thread Kavitha Venkatesan
Hi,

I have a set of (x,y) coordinate pairs that are stored as a list

 my_list
$x
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25

$y
 [1] -8.0866819 -7.3876052 -6.6849311 -5.9837693 -5.2967432 -4.6525466
 [7] -4.0999453 -3.6556190 -3.3076102 -3.0360780 -2.8220465 -2.6532085
[13] -2.5192816 -2.4086241 -2.3072977 -2.1969611 -2.0574250 -1.8737694
[19] -1.6357864 -1.3478118 -1.0228402 -0.6708884 -0.2973863  0.0922034
[25]  0.4935457

I would like to plot each of these points onto an existing plot. ie., For
each (x,y) pair, I would like to do:

points(x,y)

How can I do this in a vectorized manner?

Thanks!
Kavitha

[[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] applying a function to a pair of components for each row of a list

2009-06-27 Thread milton ruser
Hi Kavitha,

I must confess you that I not understood well what you are looking for.
But..

mylist-list(x=1:25, y=runif(n=25))
plot(mylist, type=n)
points(mylist, type=p, col=mylist$x)
Hth,

miltinho



On Sun, Jun 28, 2009 at 1:03 AM, Kavitha Venkatesan 
kavitha.venkate...@gmail.com wrote:

 Hi,

 I have a set of (x,y) coordinate pairs that are stored as a list

  my_list
 $x
  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 24
 25

 $y
  [1] -8.0866819 -7.3876052 -6.6849311 -5.9837693 -5.2967432 -4.6525466
  [7] -4.0999453 -3.6556190 -3.3076102 -3.0360780 -2.8220465 -2.6532085
 [13] -2.5192816 -2.4086241 -2.3072977 -2.1969611 -2.0574250 -1.8737694
 [19] -1.6357864 -1.3478118 -1.0228402 -0.6708884 -0.2973863  0.0922034
 [25]  0.4935457

 I would like to plot each of these points onto an existing plot. ie., For
 each (x,y) pair, I would like to do:

 points(x,y)

 How can I do this in a vectorized manner?

 Thanks!
 Kavitha

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] applying a function to a pair of components for each row of a list

2009-06-27 Thread Kavitha Venkatesan
Milton,

Thanks, the answer was in fact as simple as you pointed out. I was thinking
more complicated than needed!

Kavitha

On Sun, Jun 28, 2009 at 1:11 AM, milton ruser milton.ru...@gmail.comwrote:

 Hi Kavitha,

 I must confess you that I not understood well what you are looking for.
 But..

 mylist-list(x=1:25, y=runif(n=25))
 plot(mylist, type=n)
 points(mylist, type=p, col=mylist$x)
 Hth,

 miltinho



 On Sun, Jun 28, 2009 at 1:03 AM, Kavitha Venkatesan 
 kavitha.venkate...@gmail.com wrote:

 Hi,

 I have a set of (x,y) coordinate pairs that are stored as a list

  my_list
 $x
  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 24
 25

 $y
  [1] -8.0866819 -7.3876052 -6.6849311 -5.9837693 -5.2967432 -4.6525466
  [7] -4.0999453 -3.6556190 -3.3076102 -3.0360780 -2.8220465 -2.6532085
 [13] -2.5192816 -2.4086241 -2.3072977 -2.1969611 -2.0574250 -1.8737694
 [19] -1.6357864 -1.3478118 -1.0228402 -0.6708884 -0.2973863  0.0922034
 [25]  0.4935457

 I would like to plot each of these points onto an existing plot. ie., For
 each (x,y) pair, I would like to do:

 points(x,y)

 How can I do this in a vectorized manner?

 Thanks!
 Kavitha

[[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.htmlhttp://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] multiple regression w/ no intercept; strange results

2009-06-27 Thread John Hunter
I am writing some software to do multiple regression and am using r to
benchmark the results.  The results are squaring up nicely for the
with-intercept case but not for the no-intercept case.  I am not
sure what R is doing to get the statistics for the 0 intercept case.
For example, I would expect the Multiple R-squared to equal the square
of the correlation between the actual values y and the fitted values
yprime.  For the with-intercept case, they do, but not for the
no-intercept case.  My sample file and R session output are below


   dataset = read.table(/Users/jdhunter/tmp/sample1.csv,
header=TRUE, sep=,)

The with-intercept fit: the Multiple R-Squared is equal to the
cor(yprime, y)**2:

 fit - lm( y~x1+x2, data=dataset)
 summary(fit)

Call:
lm(formula = y ~ x1 + x2, data = dataset)

Residuals:
Min  1Q  Median  3Q Max
-1.8026 -0.4651  0.1778  0.5241  1.0222

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) -4.103581.26103  -3.254  0.00467 **
x1   0.086410.03144   2.748  0.01372 *
x2   0.087600.04548   1.926  0.07100 .
---

Residual standard error: 0.7589 on 17 degrees of freedom
Multiple R-squared: 0.6709, Adjusted R-squared: 0.6322
F-statistic: 17.33 on 2 and 17 DF,  p-value: 7.888e-05

 yp = fitted.values(fit)
 cor(yp, dataset$y)**2
[1] 0.6709279

The no-intercept fit: the Multiple R-Squared is not equal to the
cor(yprime, y)**2:

 fitno - lm( y~0+x1+x2, data=dataset)
 summary(fitno)

Call:
lm(formula = y ~ 0 + x1 + x2, data = dataset)

Residuals:
 Min   1Q   Median   3Q  Max
-1.69640 -0.58134  0.03650  0.53673  1.33358

Coefficients:
   Estimate Std. Error t value Pr(|t|)
x1  0.036550.03399   1.0750.296
x2  0.043580.05376   0.8110.428

Residual standard error: 0.9395 on 18 degrees of freedom

Multiple R-squared: 0.9341, Adjusted R-squared: 0.9267
F-statistic: 127.5 on 2 and 18 DF,  p-value: 2.352e-11

 ypno = fitted.values(fitno)
 cor(ypno, dataset$y)
[1] 0.6701336

If anyone has some suggestions about how R is computing these summary
stats for the no-intercept case, or references to literature or docs,
tha would be helpful.  It seems odd to me that dropping the intercept
would cause the R^2 and F stats to rise so dramatically, and the p
value to consequently drop so much.  In my implementation, I get the
same beta1 and beta2, and the R2 I compute using the

   variance_regression / variance_total

agrees with cor(ypno, dataset$y) but not with the value R reports in
the summary, and my F and p values are similarly off for the
no-intercept case.

Thanks,
JDH


R version 2.9.1 (2009-06-26)

home:~/tmp uname -a
Darwin Macintosh-7.local 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24
17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.