Re: [R] excluding a column from a data frame

2009-04-15 Thread Erin Hodgess
Great!


Thanks to both of you!

Sincerely,
Erin

On Wed, Apr 15, 2009 at 12:54 AM, Coen van Hasselt
coenvanhass...@gmail.com wrote:
 Alternatively you could also drop the column like this:

 xx$x2-NULL


 On Wed, Apr 15, 2009 at 15:51, Peter Alspach
 palsp...@hortresearch.co.nz wrote:
 Tena koe Erin

 xx[, names(xx)!='x2']

 HTH 

 Peter Alspach

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess
 Sent: Wednesday, 15 April 2009 5:39 p.m.
 To: R help
 Subject: [R] excluding a column from a data frame

 Dear R People:

 Suppose I have the following data frame:

   x1 x2   x3
 1 -0.1582116 0.06635783 1.765448
 2 -1.1407422 0.47235664 0.615931
 3  0.8702362 2.32301341 2.653805
  str(xx)
 'data.frame':   3 obs. of  3 variables:
  $ x1: num  -0.158 -1.141 0.87
  $ x2: num  0.0664 0.4724 2.323
  $ x3: num  1.765 0.616 2.654

 I can exclude the second column nicely via:
  xx[,-2]
   x1   x3
 1 -0.1582116 1.765448
 2 -1.1407422 0.615931
 3  0.8702362 2.653805

 Now suppose I wanted to exclude the column called x2.  If I try:
  xx[,-x2]
 Error in -x2 : invalid argument to unary operator
 

 things don't work.  Is there a simple way to do this by name
 rather than number, please?

 Thanks,
 Erin



 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences University
 of Houston - Downtown
 mailto: erinm.hodg...@gmail.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.


 The contents of this e-mail are confidential and may be subject to legal 
 privilege.
  If you are not the intended recipient you must not use, disseminate, 
 distribute or
  reproduce all or any part of this e-mail or attachments.  If you have 
 received this
  e-mail in error, please notify the sender and delete all material 
 pertaining to this
  e-mail.  Any opinion or views expressed in this e-mail are those of the 
 individual
  sender and may not represent those of The New Zealand Institute for Plant 
 and
  Food Research Limited.

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





-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.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] Double seasonal holt winter using R

2009-04-15 Thread Atul Malik
Dear Members,

I have been searching for a package in R which can handle multiple seasonality 
suggested by taylor(2003).

It will be great help if anybody has used this on R before (i.e. which package).

Thanks in Advance.

Best Regards
Atul Malik
[[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] Double seasonal holt winter using R

2009-04-15 Thread Atul Malik

Dear Members,

I have been searching for a package in R which can handle multiple
seasonality suggested by taylor(2003).

It will be great help if anybody has used this on R before (i.e. which
package).

Thanks in Advance.

Best Regards
Atul Malik

-
Atul Malik (Consultant)
DecisionCraft Analytics Ltd.
Ahmedabad, Gujrat India
www.decisioncraft.com
-- 
View this message in context: 
http://www.nabble.com/Double-seasonal-holt-winter-using-R-tp23052889p23052889.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Function call error in cph/survest (package Design)

2009-04-15 Thread Dieter Menne


Dieter Menne wrote:
 
 I do not know if this a problem with me, my data or cph/survest in package
 design. The example below works with a standard data set, but not with my
 data, but I cannot locate the problem.
 

Dieter Menne found out after hours, that in one case and explicit cast is
required, but none in the other, and has no idea why.

#---
library(Design)
data(ovarian)
dd = datadist(ovarian)
options(datadist=dd)
ovarian$rx = as.factor(ovarian$rx)
cp = cph(Surv(futime,fustat)~rx,data=ovarian,surv=TRUE,x=TRUE,y=TRUE)
summary(cp)
survplot(cp,rx=NA)
# works ok, without casting to a data frame
survest(cp,newdata=levels(ovarian$rx),what=survival,times=500)

# Small data set, 223 rows, 3650 bytes
cc = read.table(http://www.menne-biomed.de/uni/cc.csv,header=TRUE)
#cc = read.table(cc.csv,header=TRUE)
dd = datadist(cc)
cp = cph(Surv(DaysToEvent,event)~ITTGroup,data=cc,surv=TRUE,x=TRUE,y=TRUE)
survplot(cp,ITTGroup=NA)
summary(cp)

survest(cp,newdata=levels(cc$ITTGroup),times=200)
#Error in survfit.cph(list(coefficients = c(0.435291247251185,
-0.143015493753166 :
#  NA/NaN/Inf in foreign function call (arg 13)
#In addition: Warning message:
#NAs introduced by coercion

# Works when explicitly converted to a data frame
survest(cp,newdata=data.frame(ITTGroup=levels(cc$ITTGroup)),times=200)

 

-- 
View this message in context: 
http://www.nabble.com/Function-call-error-in-cph-survest-%28package-Design%29-tp23044736p23053729.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] ave returns wrong type

2009-04-15 Thread OKB (not okblacke)
I've been using the ave function to compute some statistics on a 
data frame.  After a while I noticed that, for some reason, it was 
returning numerical statistics as strings instead of numbers.  I delved 
into the code of the functions and traced the problem to the following 
fact:

ave uses split- to do its work.  Specifically, it does split(x, 
g) - lapply(split(x, g), FUN).  The problem is that this assigns the 
result of FUN into the original vector x, thus acquiring the mode of 
that vector.  So if you do ave(x, g, f) to apply f to x as grouped by g, 
and the result has the type of x, not the type that f returns.  So you 
get what strikes me as very annoying behavior, viz.:

ave(rep(c(X, Y), 15), rep(c(A, B, C), times=10), FUN=length)
10 10 10 10 10 10 10 10 10 10 10 10 10 10 
10 10 10 10 10 10 10 10 10 10
[25] 10 10 10 10 10 10

length returns numbers, so I want the result vector to contain 
numbers, obviously.  I can of course work around this by explicitly 
converting the result vector to the data type I want, but it seems silly 
for ave to do this.  ave applies a function to some stuff; the result 
should clearly depend on the RETURN TYPE of the function (as, for 
instance, tapply does it), not the type of the data being summarized by 
that function.

Is this just a bug?  Is there any known way to deal with this other 
than just manually casting the data to the type I need?

Thanks,
-- 
--OKB (not okblacke)
Brendan Barnwell
Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail.
--author unknown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Search for a graph package - see link

2009-04-15 Thread Knut Krueger

Gábor Csárdi schrieb:



The would prefer two parallel arrows one for each direction.



You can set 'curved' to a value close to zero and then the arrows will
be only a bit curved.

  

No I am lost ... do you mean?
...
E(g)$curved - 0.5
...
plot.igraph(g, layout=layout.kamada.kawai, vertex.label.font=2)
I do not see any change ..
and I do not found any curved assignment in the plot.igraph function.

Its a very
 long mathematical formula to display those arrows, depending on the radius
of the circles, and there is a ...hidden...error in the formula.



I am a bit lost. What formula are we talking about?
  

http://www.equine-science.de/temp/r-graph.jpg
I tried to get the starting point of the arrows depending on the 
distance arrow-centerline node1/node2 and between the  tangent 
right-angled to the centerline  of both nodes automatically for all nodes.

(I hope you can understand my translated mathematics description...)
That's exactly what the team would like to get.

Regards Knut

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


Re: [R] Creating a graphics window (in Windows, with RGui) that is not constrained to the RGui Window

2009-04-15 Thread Uwe Ligges



Joseph Voelkel wrote:

Hi, all,

Using RGui, is it possible to create a graphics window that can be moved
outside of the RGui window? (This can be done--in fact must be
done--using Rterm, but I wish to use RGui.)

My interest for this is to use two monitors: in my private monitor I
wish to execute R code in the Rgui window; in the public monitor I
want the audience to see the results in the graphic window.


Start RGui in sdi mode: either by setting it in the GUI preferences or 
by calling RGui with option --sdi.


Uwe Ligges




Thanks,

Joe Voelkel
Rochester Institute of Technology

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

2009-04-15 Thread Gustaf Rydevik
Hi all,
A colleague of mine tried to install the package EMV, which had been
removed from CRAN.
she ran into some kind of trouble, R locked up, and she closed the program.
Now when she starts R, utils can't be loaded which of course create
an unworkable environment.
Below I've copy-pasted the error message she gets when starting R.
Any ideas on what went wrong, and more importantly, how to fix it?
Many thanks in advance,

Gustaf Rydevik

Ps: She's running R on a WinXP box, if that might be of relevance...




Error : package 'utils' does not have a name space

R version 2.8.1 (2008-12-22)
Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and 'citation()' on how to
cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Warning message:
package methods in options(defaultPackages) was not found Error in
library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE,  :
  'utils' is not a valid package -- installed  2.0.0?



-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Search for a graph package - see link

2009-04-15 Thread Gábor Csárdi
On Wed, Apr 15, 2009 at 9:35 AM, Knut Krueger r...@krueger-family.de wrote:
 Gábor Csárdi schrieb:

 The would prefer two parallel arrows one for each direction.


 You can set 'curved' to a value close to zero and then the arrows will
 be only a bit curved.



 No I am lost ... do you mean?
 ...
 E(g)$curved - 0.5
 ...
 plot.igraph(g, layout=layout.kamada.kawai, vertex.label.font=2)
 I do not see any change ..

Because 0.5 the default value. Try 0.1. I.e.

library(igraph)
g - graph.ring(3, dir=TRUE, mut=TRUE)
g$layout - layout.circle

E(g)$curved - 0.5
plot(g)

E(g)$curved - 0.1
plot(g)

 and I do not found any curved assignment in the plot.igraph function.

It is a good idea to read the documentation as well, especially if you
don't understand the code. See ?igraph.plotting and search for
'curved'.

[...]
 http://www.equine-science.de/temp/r-graph.jpg
[...]

That possible with igraph, you need to define a new vertex shape for
it. See ?igraph.vertex.shapes and the R/plot.shapes.R file for some
simple example shapes.

Or you can write the whole thing for yourself, using 'segments', etc.

G.

 Regards Knut

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




-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Kruskal's MDS results

2009-04-15 Thread Dieter Vanderelst

Dear List,

I'm trying to interpret the results of the Kruskal's Non-metric 
Multidimensional Scaling algorithm (isoMDS, MASS package).

The 'goodness of fit' is reported as The final stress achieved (in percent).

What does this mean exactly? I've tried to google for an answer but I've not 
come up with a definitive answer.

Regards,
Dieter


--
Dieter Vanderelst
PhD Student

Active Perception Lab
University of Antwerp
http://batbits.webnode.com/

Postal Address:
Prinsstraat 13
B-2000 Antwerp
Belgium

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

2009-04-15 Thread Peter Kraglund Jacobsen
 (FICB[,temp])
 [1] 0.30 0.55 0.45 2.30 0.45 0.30 0.25 0.30 0.30
1.05 1.00 1.00
[13] 0.30 0.30 0.30 0.55 0.30 0.30 0.30 0.25 1.00
0.30 0.30 0.45
[25] 0.30 1.30 0.30 0.30 0.45 0.30 0.30 0.30   NA
NA   NA   NA
[37] 0.30   NA 0.30 0.30 0.30 0.30   NA   NA 0.35
NA 0.35 0.30
[49] 0.30 0.40   NA 0.40 0.30   NA 0.30 0.30 0.30
0.30 0.45 0.30
[61] 0.30 0.30 0.30 0.50 0.30 0.30 0.45 0.30

How do I output the number to the left of . to variable X and the
two numbers to the right of . to variable Y?

FICB[,x] - substr(FICB[,temp2],1,1)
Works, but

FICB[,y] - substr(FICB[,temp2],3,2)
only returns . temp is class character.

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

2009-04-15 Thread Dimitris Rizopoulos

try this:

string - c(0.30, 0.55, 0.45, 2.30, NA,   NA,   NA, 
0.50, 0.30, 0.30, 0.45, 0.30)


splt - strsplit(string, \\.)
sapply(splt, function (x) if(length(x) == 2) x[1] else as.character(NA))
sapply(splt, function (x) if(length(x) == 2) x[2] else as.character(NA))


I hope it helps.

Best,
Dimitris


Peter Kraglund Jacobsen wrote:

(FICB[,temp])

 [1] 0.30 0.55 0.45 2.30 0.45 0.30 0.25 0.30 0.30
1.05 1.00 1.00
[13] 0.30 0.30 0.30 0.55 0.30 0.30 0.30 0.25 1.00
0.30 0.30 0.45
[25] 0.30 1.30 0.30 0.30 0.45 0.30 0.30 0.30   NA
NA   NA   NA
[37] 0.30   NA 0.30 0.30 0.30 0.30   NA   NA 0.35
NA 0.35 0.30
[49] 0.30 0.40   NA 0.40 0.30   NA 0.30 0.30 0.30
0.30 0.45 0.30
[61] 0.30 0.30 0.30 0.50 0.30 0.30 0.45 0.30

How do I output the number to the left of . to variable X and the
two numbers to the right of . to variable Y?

FICB[,x] - substr(FICB[,temp2],1,1)
Works, but

FICB[,y] - substr(FICB[,temp2],3,2)
only returns . temp is class character.

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-04-15 Thread Chuck Cleland
On 4/15/2009 1:38 AM, Erin Hodgess wrote:
 Dear R People:
 
 Suppose I have the following data frame:
 
   x1 x2   x3
 1 -0.1582116 0.06635783 1.765448
 2 -1.1407422 0.47235664 0.615931
 3  0.8702362 2.32301341 2.653805
 str(xx)
 'data.frame':   3 obs. of  3 variables:
  $ x1: num  -0.158 -1.141 0.87
  $ x2: num  0.0664 0.4724 2.323
  $ x3: num  1.765 0.616 2.654
 
 I can exclude the second column nicely via:
 xx[,-2]
   x1   x3
 1 -0.1582116 1.765448
 2 -1.1407422 0.615931
 3  0.8702362 2.653805
 
 Now suppose I wanted to exclude the column called x2.  If I try:
 xx[,-x2]
 Error in -x2 : invalid argument to unary operator
 
 things don't work.  Is there a simple way to do this by name rather
 than number, please?

  Another way to do it is with subset():

subset(xx, select = -x2)

 Thanks,
 Erin 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] geometric mean to handle large number and negative values

2009-04-15 Thread Daren Tan
I have created two functions to compute geometric means. Method 1 can
handle even number of negative values but not large number, vice versa
for method 2. How can I merge both functions so that both large number
and negative values can be handled ?

 geometric.mean1 - function(x) prod(x)^(1/length(x))
 geometric.mean2 - function(x) exp(mean(log(x)))

 geometric.mean1(1:1000)
[1] Inf
 geometric.mean2(1:1000)
[1] 3678798

 geometric.mean1(c(-5,-4,4,5))
[1] 4.472136
 geometric.mean2(c(-5,-4,4,5))
[1] NaN
Warning message:
In log(x) : NaNs produced

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


[R] Comparing two regression line slopes

2009-04-15 Thread Benedikt Niesterok
Hello R users,
I've used the following help:

 Comparing two regression line slopes
 I knew the method based on the following statement :
 t = (b1 - b2) / sb1,b2
 where b1 and b2 are the two slope coefficients and sb1,b2 the pooled  
 standard error of the slope (b)
 
 which can be calculated in R this way:
   df1 - data.frame(x=1:3, y=1:3+rnorm(3))
   df2 - data.frame(x=1:3, y=1:3+rnorm(3))
   fit1 - lm(y~x, df1)
   s1 - summary(fit1)$coefficients
   fit2 - lm(y~x, df2)
   s2 - summary(fit2)$coefficients
   db - (s2[2,1]-s1[2,1])
   sd - sqrt(s2[2,2]^2+s1[2,2]^2)
   df - (fit1$df.residual+fit2$df.residual)
   td - db/sd
   2*pt(-abs(td), df)
Using my data I finally get the value of the test, which is: 2.245e-7.
Do my slopes differ significantly now?
Thanks for help,  Benedikt
 

--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Search for a graph package - see link

2009-04-15 Thread Gábor Csárdi
Knut, I think you have an older version of igraph that does not
support curved edges. Again, please read
http://lists.gnu.org/archive/html/igraph-help/2009-04/msg00104.html
and install version 0.5.2, it is on CRAN now (except for OSX).

Gabor

On Wed, Apr 15, 2009 at 11:30 AM, Knut Krueger r...@krueger-family.de wrote:
 Gábor Csárdi schrieb:



 Dear Gabor, I am very sorry but i am not able to reproduce your example.
 there is no change, i am using r 2.8.0
[...]

-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 control lattice plot parameters

2009-04-15 Thread Paulo E. Cardoso
I'm not being able to control all parameters of a xyplot.

dataset example:
 tabp[1:10,]
   time  n X id   name
1 1 95  0.00  1 Coral reef
2 1 93  0.00  2 Coral reef
3 1 92  0.00  3 Coral reef
4 1 90  0.00  4 Coral reef
5 1 87  8.994321  5 Coral reef
6 1 86 12.580143  6 Coral reef
7 1 84 17.004030  7 Coral reef
8 1 83 18.469500  8 Coral reef
9 1 82 37.919033  9 Coral reef
101 81 39.059352 10 Coral reef
...

plot code:
xyplot(
  X~n,groups=name,data=tabp[tabp$time %in% c(1,4,8),],  
  ylab=% of target,
  xlab=PU selection Frequency,  
  lty=c(1,3,5), #! not responding
  xlim=c(-10,110),
  scales=list(cex=0.7,at=seq(0,360,by=20),labels=seq(0,360,by=20)), #!
not responding   
  panel=function(x,y,groups,subscripts)
  {
panel.xyplot(x,y,
subscripts=subscripts,
groups=groups,
type=l)
panel.abline(h=30,lty=2,col=grey50)
  },
  key=list(
space=top,
columns=1,  
text=list(levels(tabp$name)[c(2,5,11)]),
lines=list(col=c(grey,blue,green))
)
  )

A few controls are not responding and I don't know how to:
1) control cex for xlab and ylab
2) control position of legend
3) control lty for each group level
4) control plot groups colors
5) match legend colors with graph colors
Any help will be very appreciated.


Paulo E. Cardoso

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


Re: [R] Comparing two regression line slopes

2009-04-15 Thread Arien Lam
Benedikt,

Is this homework? Let's see, the same question as last week, when Eik
Vetorazzi showed you how to interpret the test value.
The significance of this test depends on your pre-specified alpha. Don't
rely on an arbitrary value of 0.05. It would be a good idea to do some
reading (any introductory statistics book would suffice, there are some
excellent suggestions on this list if you care to look for them).

Hope this helps,
Arien

On Wed, April 15, 2009 11:31, Alain Guillet wrote:
 Hello benedikt,

 You say the slopes differ significantly if the p-value is less than a
 given threshold, most of the time 0.05.

 Please, note that fitting a linear regression through three points is
 senseless...

 Regards,
 Alain


 Benedikt Niesterok wrote:
 Hello R users,
 I've used the following help:


 Comparing two regression line slopes
 I knew the method based on the following statement :
 t = (b1 - b2) / sb1,b2
 where b1 and b2 are the two slope coefficients and sb1,b2 the pooled
 standard error of the slope (b)

 which can be calculated in R this way:
   df1 - data.frame(x=1:3, y=1:3+rnorm(3))
   df2 - data.frame(x=1:3, y=1:3+rnorm(3))
   fit1 - lm(y~x, df1)
   s1 - summary(fit1)$coefficients
   fit2 - lm(y~x, df2)
   s2 - summary(fit2)$coefficients
   db - (s2[2,1]-s1[2,1])
   sd - sqrt(s2[2,2]^2+s1[2,2]^2)
   df - (fit1$df.residual+fit2$df.residual)
   td - db/sd
   2*pt(-abs(td), df)

 Using my data I finally get the value of the test, which is: 2.245e-7.
 Do my slopes differ significantly now?
 Thanks for help,  Benedikt


 --

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



 --
 Alain Guillet
 Statistician and Computer Scientist

 SMCS - Institut de statistique - Université catholique de Louvain
 Bureau d.126
 Voie du Roman Pays, 20
 B-1348 Louvain-la-Neuve
 Belgium

 tel: +32 10 47 30 50

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



-- 
drs. H.A. (Arien) Lam (Ph.D. student)
Department of Physical Geography
Faculty of Geosciences
Utrecht University, The Netherlands

E-mail: a@geo.uu.nl
Web:http://www.geo.uu.nl/staff/a.lam

Telephone:  +31(0)30-253 2988 (direct), 2749 (secretary)
Fax:+31(0)30-2531145

Visiting address: Room Zon 121, Heidelberglaan 2, Utrecht
Postal address: P.O.Box 80.115, 3508 TC Utrecht

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Building GUI for custom R application

2009-04-15 Thread Franzini, Gabriele [Nervianoms]
Hello Harsh,
I found useful the fgui package ( 
http://www.people.fas.harvard.edu/~tjhoffm/fgui.html ). 
Regards,
Gabriele Franzini 
ICT Applications Manager 
Nerviano Medical Sciences SRL 
Nerviano Italy 




-Original Message-
From: Barry Rowlingson [mailto:b.rowling...@lancaster.ac.uk] 
Sent: 14 April 2009 12:55
To: Harsh
Cc: r-help@r-project.org
Subject: Re: [R] Building GUI for custom R application

On Tue, Apr 14, 2009 at 9:23 AM, Harsh singhal...@gmail.com wrote:
 HI R users,
 I would appreciate information/examples/suggestions on building GUIs 
 for R applications.
 I am currently working on a project that would require the following 
 functionalities :

 1) Display a  window to the user. Provide a function to scan local 
 drive and choose dataset file.
 2) Display the column names for the user to choose the dependent 
 variable and the independent variables.
 3) Fit regression and display statistics.

 Item 2 provides an example of creating a regression application with 
 slider controls for a parameter in loess function used in the example 
 application in that paper.
 For documentation on RGtk the author recommends reading the Gtk 
 tutorial and documentation. I seem to have difficulty in making sense 
 of the Gtk documentation since most of it is in C and documentation is 
 available for use of Gtk with Perl and Python. I am not a 
 C/Perl/Python programmer.
Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] repeat series of commands for each variable

2009-04-15 Thread Peter Kraglund Jacobsen
For each variable x, y and z I would like to run the same set of
commands. I have tried

for (n in FICB[,calct30], FICB[, calct60]) {
FICB[,temp] - format([n],digits=2)
etc
}

How do I do this correctly?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] geometric mean to handle large number and negative value

2009-04-15 Thread Ted Harding
On 15-Apr-09 09:26:55, richard.cot...@hsl.gov.uk wrote:
 I have created two functions to compute geometric means. Method 1 can
 handle even number of negative values but not large number, vice versa
 for method 2. How can I merge both functions so that both large number
 and negative values can be handled ?
 
  geometric.mean1 - function(x) prod(x)^(1/length(x))
  geometric.mean2 - function(x) exp(mean(log(x)))
 
  geometric.mean1(1:1000)
 [1] Inf
  geometric.mean2(1:1000)
 [1] 3678798
 
  geometric.mean1(c(-5,-4,4,5))
 [1] 4.472136
  geometric.mean2(c(-5,-4,4,5))
 [1] NaN
 Warning message:
 In log(x) : NaNs produced
 
 Geometric mean is usually restricted to positive inputs, because
 otherwise the answer can have an imaginary component. If you really
 want the geometric mean of negative inputs, use the second method
 but convert the input to be a complex number first.
 
 comp.x - as.complex(c(-5,-4,4,5))
 geometric.mean2(comp.x)
# [1] 0+4.472136i
 
 Regards,
 Richie.
 Mathematical Sciences Unit
 HSL

Since it appears that you were content with the result of your product
method when there was an even number of negative cases, and this is
equivalent to the result you would get if all the negative numbers
were positive, why not simply convert all numbers to positive by
using abs(), and then applying your second method (which can cope
with large numbers)?

I.e. geometric.mean3 - function(x) exp(mean(log(abs(x

However, do think carefully about whether the results will make the
sort of sense that you intend.

For instance, on that basis,

  geometric.mean3(c(-1,1)) = 1, not 0

  geometric.mean2(c(-4,-1)) = 2, so the resulting geometric mean
is outside the range of the original numbers.

(yet it is what your first method would have given).

On the other hand, Richie's suggestion gives results which you may
consider to make more sense:

  comp.x - as.complex(c(-1,1))
  geometric.mean2(comp.x)
  # [1] 0+1i

  comp.x - as.complex(c(-4,-1))
  geometric.mean2(comp.x)
  # [1] -2+0i

But then, in the original example:

  comp.x - as.complex(c(-5,-4,4,5))
  geometric.mean2(comp.x)
  # [1] 0+4.472136i

what do you want to do with the resulting 4.472136i ?

So you need to think about what you intend to do with the result,
in general, and about why you want to compute a geometric mean.

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 15-Apr-09   Time: 11:14:27
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Search for a graph package - see link

2009-04-15 Thread Knut Krueger

Gábor Csárdi schrieb:
Hi Gabor, it seems that anybody doesnt not want us to find a solution ;-)

and install version 0.5.2, it is on CRAN now (except for OSX).
  

I got the 0.5.1 at 06.April.2009

I just tried the Munich Mirror got 0.5.1
there is also only 0.5.1 on
http://mirrors.softliste.de/cran/bin/windows/contrib/
also in r-devel

and
http://cneurocvs.rmki.kfki.hu/igraph/download/igraph_0.5.2.zip
seems to be down.
Maybe you could send me the file with email?

Regards Knut

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


Re: [R] Comparing two regression line slopes

2009-04-15 Thread Alain Guillet

Hello benedikt,

You say the slopes differ significantly if the p-value is less than a 
given threshold, most of the time 0.05.


Please, note that fitting a linear regression through three points is 
senseless...


Regards,
Alain


Benedikt Niesterok wrote:

Hello R users,
I've used the following help:

  

Comparing two regression line slopes
I knew the method based on the following statement :
t = (b1 - b2) / sb1,b2
where b1 and b2 are the two slope coefficients and sb1,b2 the pooled  
standard error of the slope (b)


which can be calculated in R this way:
  df1 - data.frame(x=1:3, y=1:3+rnorm(3))
  df2 - data.frame(x=1:3, y=1:3+rnorm(3))
  fit1 - lm(y~x, df1)
  s1 - summary(fit1)$coefficients
  fit2 - lm(y~x, df2)
  s2 - summary(fit2)$coefficients
  db - (s2[2,1]-s1[2,1])
  sd - sqrt(s2[2,2]^2+s1[2,2]^2)
  df - (fit1$df.residual+fit2$df.residual)
  td - db/sd
  2*pt(-abs(td), df)


Using my data I finally get the value of the test, which is: 2.245e-7.
Do my slopes differ significantly now?
Thanks for help,  Benedikt
 


--

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

  


--
Alain Guillet
Statistician and Computer Scientist

SMCS - Institut de statistique - Université catholique de Louvain
Bureau d.126
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] geometric mean to handle large number and negative values

2009-04-15 Thread Richard . Cotton
 I have created two functions to compute geometric means. Method 1 can
 handle even number of negative values but not large number, vice versa
 for method 2. How can I merge both functions so that both large number
 and negative values can be handled ?
 
  geometric.mean1 - function(x) prod(x)^(1/length(x))
  geometric.mean2 - function(x) exp(mean(log(x)))
 
  geometric.mean1(1:1000)
 [1] Inf
  geometric.mean2(1:1000)
 [1] 3678798
 
  geometric.mean1(c(-5,-4,4,5))
 [1] 4.472136
  geometric.mean2(c(-5,-4,4,5))
 [1] NaN
 Warning message:
 In log(x) : NaNs produced

Geometric mean is usually restricted to positive inputs, because otherwise 
the answer can have an imaginary component.  If you really want the 
geometric mean of negative inputs, use the second method but convert the 
input to be a complex number first.

comp.x - as.complex(c(-5,-4,4,5))
geometric.mean2(comp.x)
# [1] 0+4.472136i

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Search for a graph package - see link

2009-04-15 Thread Knut Krueger

Gábor Csárdi schrieb:
  

Dear Gabor, I am very sorry but i am not able to reproduce your example.
there is no change, i am using r 2.8.0

library(igraph)
g - graph.ring(3, dir=TRUE, mut=TRUE)
g$layout - layout.circle

E(g)$curved - 0.5
plot(g)

E(g)$curved - 0.1
plot(g)

  
It is a good idea to read the documentation as well, especially if you

don't understand the code.
hmm maybe I do not understand, but there  is no parameter curves inside 
the parameter asignment

   params - i.parse.plot.params(graph, list(...))
   vertex.size - 1/200 * params(vertex, size)
  ..frame - params(plot, frame)
plot() is only called if !add I think this means only the first time
igraph.Arrows is used to draw the arrows and there I do not find any 
assignment for curved.



It is a good idea to read the documentation as well,

See ?igraph.plotting and search for

'curved'.
  


?igraph.plotting redirects me to plot.common.html
and there is no word inside beginning with curv...
I also did a complete text search, (before I asked you again) in all files of 
the R-directory
I found it only in the library diagram and network 


network.arrow(1,1,2,2,curve=0.1,width=0.01,col=red,border=black) # this is 
working fine
or for curved arrowheads.



Regards Knut

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] geometric mean to handle large number and negative values

2009-04-15 Thread Richard . Cotton
   geometric.mean1 - function(x) prod(x)^(1/length(x))
   geometric.mean2 - function(x) exp(mean(log(x)))
   geometric.mean1(c(-5,-4,4,5))
  [1] 4.472136
   geometric.mean2(c(-5,-4,4,5))
  [1] NaN
  Warning message:
  In log(x) : NaNs produced

 comp.x - as.complex(c(-5,-4,4,5))
 geometric.mean2(comp.x)
 # [1] 0+4.472136i

Obviously, there's a discrepancy between the answer of geometric.mean1 and 
geometric.mean2 with complex inputs.  Having thought about it a little 
more, I think the problem is with my solution.

The log of a complex number decomposes as log(z) = log(abs(z)) +1i*Arg(z). 
 When you sum the second components, you need to take the answer modulo 
2*pi, since the phase angles wrap around.

Here's an alternative geometric mean function that takes that into 
account.

geometric.mean3 - function(x) 
{
   a - mean(log(abs(x)))
   b - 1i/length(x) 
   c - sum(Arg(x))%%(2*pi)
   exp(a+b*c)
}

geometric.mean3(comp.x)
# [1] 4.472136+0i

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

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

2009-04-15 Thread Duncan Murdoch

Gustaf Rydevik wrote:

Hi all,
A colleague of mine tried to install the package EMV, which had been
removed from CRAN.
she ran into some kind of trouble, R locked up, and she closed the program.
Now when she starts R, utils can't be loaded which of course create
an unworkable environment.
Below I've copy-pasted the error message she gets when starting R.
Any ideas on what went wrong, and more importantly, how to fix it?
  


No idea of the details of what went wrong, but it looks as though your 
colleague has some bad startup file (Renviron, Rprofile, etc; see 
?Startup for the full list) or has actually damaged her R installation.  
I'd try re-installing it first, because that's easy, then work through 
?Startup and see if there are some bad files or environment variables 
messing things up.


Duncan Murdoch

Many thanks in advance,

Gustaf Rydevik

Ps: She's running R on a WinXP box, if that might be of relevance...




Error : package 'utils' does not have a name space

R version 2.8.1 (2008-12-22)
Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and 'citation()' on how to
cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Warning message:
package methods in options(defaultPackages) was not found Error in
library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE,  :
  'utils' is not a valid package -- installed  2.0.0?






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rank of factors for experiment based on latin hypercube?

2009-04-15 Thread Hardi

Hi,

I am running a simulation and have to perform ANOVA to determine the rank of 
factors. Used the aov() function and it works great for full factorial design.

1. For a massive set of data, I tried using biglm, while it can create the 
linear model, all the residuals (for assumption validation) are not recorded 
and the sum of squares are not there, just the estimated regression 
coefficient, 95% CI, SE and p. Can I use any of these to get the rank of 
factors ?

2. I'm trying to use Latin Hypercube design instead of the costly full 
factorial design. However, if I choose 2 partitions with 2 variables (for 
experiment with 2 factors - A  B each with 2 levels - min  max), I could not 
use aov() to get the rank of factors since aov() detects that B is dependant 
to A, thus only A causes the variance.
e.g:
Design point 1: A (min), B (max)
Design point 2: A (max), B(min)
Terms:

Sum of Squares34.83342 (A)   0.96427 (Residuals)
Deg. of Freedom  1 (A)   198 (Residuals)

Residual standard error: 0.06978563 
2 out of 4 effects are not estimable
Estimated effects may be unbalanced

Please advice how to solve this problem.

Thank you,

Hardi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 index statements provided as function args?

2009-04-15 Thread Dan Kelley

Is there a way to specify a *vector* of statements, as an argument to a
function.  What I'm trying to do is to provide the ability to add elements
to a series of panels drawn by a function.  (As documented, split.screen
does not provide this capability.) My idea is to mimic the 'plot.axes'
argument of filled.contour(), but with indexed statements to be executed.  A
series of tests is given below.  (NOTE: I know that I can use parse() on
character strings, but I'm trying to avoid forcing users of the function to
deal with nested quote marks, and the filled.contour scheme seems elegant to
my eye.)

 f-function(x){x[[1]]}
 f(list({cat(a\n)},{cat(b\n)}))
a
b

 f(c({cat(a\n)},{cat(b\n)}))
a
b
NULL
 
 f({{cat(a\n)},{cat(b\n)}})
Error: syntax error
 

-- 
View this message in context: 
http://www.nabble.com/how-to-index-statements-provided-as-function-args--tp23056258p23056258.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Search for a graph package - see link

2009-04-15 Thread Knut Krueger

Knut Krueger schrieb:


http://cneurocvs.rmki.kfki.hu/igraph/download/igraph_0.5.2.zip

Server is now available again
I got the file.

Thanks Knut

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Faster Solution for a simple code?

2009-04-15 Thread Chris82

Thanks!

That's a really fast soltution. Now the R process takes a few seconds
instead of a couple of hours with my loop.

greets.


jholtman wrote:
 
 try this:
 
 x
V1  V2 V3
 1 500 320  0
 2 510 310  0
 3 520 310  0
 4 520 320  0
 y
V1  V2 V3
 1 500 320  1
 2 500 320  1
 3 520 310  1
 4 520 300  1
 z - merge(x, y, by=c(V1, V2), all.x=TRUE)
 t(sapply(split(z, z[,1:2], drop=TRUE), function(.grp){
 + if (any(is.na(.grp))) return(c(.grp[1,1], .grp[1,2], 0))
 + c(.grp[1,1], .grp[1,2], nrow(.grp))
 + }))
[,1][,2] [,3]
 510.310 510 3100
 520.310 520 3101
 500.320 500 3202
 520.320 520 3200

 
 
 On Mon, Apr 13, 2009 at 1:06 PM, Chris82 rubenba...@gmx.de wrote:

 Hi R-users,

 I create a simple code to check out how often the same numbers in y occur
 in
 x. For example 500 32 occurs two times.
 But the code with the loop is extremly slow. x have 6100 lines and y
 sometimes more than 5 lines.

 Is there any alternative code to create with R?

 thanks.


 x

 500 320 0
 510 310 0
 520 310 0
 520 320 0


 lengthx - length(x[,1])

 y

 500 320 1
 500 320 1
 520 310 1
 520 300 1


 langthy - length(y[,1])

 for (i in 1:lengthx){
 for (j in 1:lengthy){
 if (x[i,1] == y[j,1]){
 if (x[i,2] == y[j,2]){
 x[i,3] - x[i,3] + 1
 }
 }
 }
 }
 x

 1  500    320      2
 2  510    310      0
 3  520    310      1
 4  520    320      0
 --
 View this message in context:
 http://www.nabble.com/Faster-Solution-for-a-simple-code--tp23024985p23024985.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.

 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem that you are trying to solve?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Faster-Solution-for-a-simple-code--tp23024985p23056586.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to index statements provided as function args?

2009-04-15 Thread Duncan Murdoch

On 15/04/2009 6:31 AM, Dan Kelley wrote:

Is there a way to specify a *vector* of statements, as an argument to a
function. 


There are several ways.  expression() converts its arguments into a 
vector of expressions, e.g.


 e - expression(cat(a\n), cat(b\n))
 e[[1]]
cat(a\n)
 eval(e[[1]])
a

Duncan Murdoch

 What I'm trying to do is to provide the ability to add elements

to a series of panels drawn by a function.  (As documented, split.screen
does not provide this capability.) My idea is to mimic the 'plot.axes'
argument of filled.contour(), but with indexed statements to be executed.  A
series of tests is given below.  (NOTE: I know that I can use parse() on
character strings, but I'm trying to avoid forcing users of the function to
deal with nested quote marks, and the filled.contour scheme seems elegant to
my eye.)


f-function(x){x[[1]]}
f(list({cat(a\n)},{cat(b\n)}))

a
b

f(c({cat(a\n)},{cat(b\n)}))

a
b
NULL

f({{cat(a\n)},{cat(b\n)}})

Error: syntax error



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 index statements provided as function args?

2009-04-15 Thread Dan Kelley

That works perfectly.  Thanks very much!!


Duncan Murdoch-2 wrote:
 
 On 15/04/2009 6:31 AM, Dan Kelley wrote:
 Is there a way to specify a *vector* of statements, as an argument to a
 function. 
 
 There are several ways.  expression() converts its arguments into a 
 vector of expressions, e.g.
 
   e - expression(cat(a\n), cat(b\n))
   e[[1]]
 cat(a\n)
   eval(e[[1]])
 a
 

-- 
View this message in context: 
http://www.nabble.com/how-to-index-statements-provided-as-function-args--tp23056258p23057076.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] using Sweave, how to save a plot in a given size

2009-04-15 Thread Lore M

Yes it works, but I still have a problem.
The thing is that I know the dimensions of my plot but in the R code, not in 
the latex code. So I tried to do :

\SweaveOpts{prefix.string=proj1}
 
label=fig1,fig=T,include=F,width=\Sexpr{wid}, height=\Sexpr{hei}=
plot(1:10)
@

\begin{figure}
\includegraphics {proj1-fig1}   %% show
\end{figure}

But Latex doen't find the value of wid and hei when it creates the chunk 
code. But in the Latex code, it works and I do have the right value for wid 
and hei.

Lore.


 Date: Tue, 14 Apr 2009 12:42:16 +0200
 From: wr...@titus.u-strasbg.fr
 To: tchiba...@hotmail.com
 CC: r-help@r-project.org
 Subject: Re: [R] using Sweave, how to save a plot in a given size
 
 Hi I do somthing like:
 
 \SweaveOpts{prefix.string=proj1}
 
 label=fig1,fig=T,include=F,width=8, height=12=
 plot(1:10)
 @
 
 \begin{figure}
 \includegraphics {proj1-fig1}   %% show
 \label{..}
 \end{figure}
 
 
 Wolfgang
 
 
 Lore M a écrit :
 
 
 
 
 
 
  Hi,
   
  I'm trying to realise a repport with R and Latex (TeXnicCenter and Miktex 
  for Windows) using Sweave(). 
  I'd like to save my plots in a given size. How can I do that ? The code is :
   
  \SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE}
  partI, echo=FALSE ,fig=TRUE, include=FALSE=  
  plotFunction()
  @
  \includepdf[pages=-]{figs/plot-partI}
 
  When I use par(pin=c(width,height)), I get the plot with the right size but 
  saved in a too big pdf page (7in x 7in, the default size of the window).
  So I tried to change the size of the window with the command windows() but 
  then, Sweave can't save the plot correctly.
 
  Thanks everyone.
   
  Lore.
  _
 
  ? Lancez-vous !
 
  [[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.
 
 

 
 
 -- 
 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
 Wolfgang Raffelsberger, PhD
 Laboratoire de BioInformatique et Génomique Intégratives
 CNRS UMR7104, IGBMC 
 1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
 Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
 wolfgang.raffelsberger (at) igbmc.fr 
 
 
 

_

[[elided Hotmail spam]]

[[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] utils lacking namespace?

2009-04-15 Thread Gustaf Rydevik
On Wed, Apr 15, 2009 at 12:20 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 Gustaf Rydevik wrote:

 Hi all,
 A colleague of mine tried to install the package EMV, which had been
 removed from CRAN.
 she ran into some kind of trouble, R locked up, and she closed the
 program.
 Now when she starts R, utils can't be loaded which of course create
 an unworkable environment.
 Below I've copy-pasted the error message she gets when starting R.
 Any ideas on what went wrong, and more importantly, how to fix it?


 No idea of the details of what went wrong, but it looks as though your
 colleague has some bad startup file (Renviron, Rprofile, etc; see ?Startup
 for the full list) or has actually damaged her R installation.  I'd try
 re-installing it first, because that's easy, then work through ?Startup and
 see if there are some bad files or environment variables messing things up.

 Duncan Murdoch

Hi, and thanks for the help!

It turned out after a bit of searching among the libraries file
structrure that the utils catalogue had somehow been moved to the
catalogue belonging to package NADA. It must have been some
installation script (of the EMV package?) that for some reason moved
it there, but heavens know why.

Oh well, things got sorted out in the end anyhow, and all's well now!

regards,

Gustaf




-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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


Re: [R] using Sweave, how to save a plot in a given size

2009-04-15 Thread ONKELINX, Thierry
Dear Lore,

The easiest thing to do is to write a function that saves your plot to a file 
and generates the latex code.

label=fig1, fig=FALSE, result = tex=
pdf(fig1.pdf, width = wid, heigth = hei)
plot(1:10)
dev.off()
cat(\begin{figure}\)
cat(\includegraphics[width = , wid, , height = , hei, ]{proj1-fig1}\}
cat(\end{figure})
@

HTH,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Lore M
Verzonden: woensdag 15 april 2009 13:46
Aan: wolfgang.raffelsber...@igbmc.fr; R Help
Onderwerp: Re: [R] using Sweave, how to save a plot in a given size


Yes it works, but I still have a problem.
The thing is that I know the dimensions of my plot but in the R code, not in 
the latex code. So I tried to do :

\SweaveOpts{prefix.string=proj1}

label=fig1,fig=T,include=F,width=\Sexpr{wid}, height=\Sexpr{hei}=
plot(1:10)
@

\begin{figure}
\includegraphics {proj1-fig1}   %% show
\end{figure}

But Latex doen't find the value of wid and hei when it creates the chunk 
code. But in the Latex code, it works and I do have the right value for wid 
and hei.

Lore.


 Date: Tue, 14 Apr 2009 12:42:16 +0200
 From: wr...@titus.u-strasbg.fr
 To: tchiba...@hotmail.com
 CC: r-help@r-project.org
 Subject: Re: [R] using Sweave, how to save a plot in a given size
 
 Hi I do somthing like:
 
 \SweaveOpts{prefix.string=proj1}
 
 label=fig1,fig=T,include=F,width=8, height=12=
 plot(1:10)
 @
 
 \begin{figure}
 \includegraphics {proj1-fig1}   %% show
 \label{..}
 \end{figure}
 
 
 Wolfgang
 
 
 Lore M a écrit :
 
 
 
 
 
 
  Hi,
   
  I'm trying to realise a repport with R and Latex (TeXnicCenter and Miktex 
  for Windows) using Sweave(). 
  I'd like to save my plots in a given size. How can I do that ? The code is :
   
  \SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE}
  partI, echo=FALSE ,fig=TRUE, include=FALSE= 
  plotFunction()
  @
  \includepdf[pages=-]{figs/plot-partI}
 
  When I use par(pin=c(width,height)), I get the plot with the right size but 
  saved in a too big pdf page (7in x 7in, the default size of the window).
  So I tried to change the size of the window with the command windows() but 
  then, Sweave can't save the plot correctly.
 
  Thanks everyone.
   
  Lore.
  _
 
  ? Lancez-vous !
 
  [[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.
 
 

 
 
 -- 
 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
 Wolfgang Raffelsberger, PhD
 Laboratoire de BioInformatique et Génomique Intégratives
 CNRS UMR7104, IGBMC 
 1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
 Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
 wolfgang.raffelsberger (at) igbmc.fr 
 
 
 

_

[[elided Hotmail spam]]

[[alternative HTML version deleted]]


Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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

2009-04-15 Thread Katrien Baert

Dear all,

I have been looking for possibilities to read and write Excel 2007-files 
in and from R.

The 'reading' part is ok through odbcConnectExcel2007 and sqlFetch(RODBC).

For 'writing' I thought of using sqlSave in the same package, but it 
does not work (I think because this function starts from an existing 
file). Is there a workaround for this, or are there other plausible 
options for writing .xlsx files?


With kind regards,

Katrien

PS: I found some information about RExcelInstaller, if this is something 
that would solve my problems could someone describe how it works (the 
user manual did not help me very much).


--
Katrien Baert
Statistical Consultant
IOF valorisatieconsortium Stat-Gent

T 32 9 264 47 66

http://www.statgent.org/

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

2009-04-15 Thread Gabor Grothendieck
Using string from another responder's post here are two
solutions:

1. The first converts to numeric and manipulates that:

cbind(part1 = floor(as.numeric(string)), part2 = 100 * as.numeric(string) %% 1)

2.  The second uses strapply from the gsubfn package.
It matches from the beginning ( ^ ) a string
of digits ( [0-9]+ ) followed by a dot ( [.] ) followed by a string of digits
to the end ( $ ) or ( | ) an NA possibly surrounded with spaces
(  *NA * ) and concatenates the result into a vector ( c ) and
simplifies all that by rbind'ing that together.   We still have character
data so in the second line we make it numeric:

library(gsubfn)
s - strapply(string, ^([0-9]+)[.]([0-9]+)$|^ *NA *$, c, simplify = rbind)
apply(s, 2, as.numeric)


On Wed, Apr 15, 2009 at 4:02 AM, Peter Kraglund Jacobsen
pe...@kraglundjacobsen.dk wrote:
 (FICB[,temp])
  [1] 0.30 0.55 0.45 2.30 0.45 0.30 0.25 0.30 0.30
 1.05 1.00 1.00
 [13] 0.30 0.30 0.30 0.55 0.30 0.30 0.30 0.25 1.00
 0.30 0.30 0.45
 [25] 0.30 1.30 0.30 0.30 0.45 0.30 0.30 0.30   NA
 NA   NA   NA
 [37] 0.30   NA 0.30 0.30 0.30 0.30   NA   NA 0.35
 NA 0.35 0.30
 [49] 0.30 0.40   NA 0.40 0.30   NA 0.30 0.30 0.30
 0.30 0.45 0.30
 [61] 0.30 0.30 0.30 0.50 0.30 0.30 0.45 0.30

 How do I output the number to the left of . to variable X and the
 two numbers to the right of . to variable Y?

 FICB[,x] - substr(FICB[,temp2],1,1)
 Works, but

 FICB[,y] - substr(FICB[,temp2],3,2)
 only returns . temp is class character.

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

2009-04-15 Thread per243

I have 3 layouts differents each others and I need make a layout with these 3
layouts, someone can me help???
-- 
View this message in context: 
http://www.nabble.com/composition-of-layouts-tp23057309p23057309.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] nls factor

2009-04-15 Thread Manuel Gutierrez
I want to fit the model y=a*x^b using nls; where a should be different for
each level of a factor.
What is the easiest way to fit it? Can i do it with nls?
I've looked the help pages and the MASS example in page 249 but the formula
is different and I don't know how to specify it for my model.
Thanks,
Manuel

[[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] Function call error in cph/survest (package Design)

2009-04-15 Thread Frank E Harrell Jr

Dieter Menne wrote:


Dieter Menne wrote:

I do not know if this a problem with me, my data or cph/survest in package
design. The example below works with a standard data set, but not with my
data, but I cannot locate the problem.



Dieter Menne found out after hours, that in one case and explicit cast is
required, but none in the other, and has no idea why.

#---
library(Design)
data(ovarian)
dd = datadist(ovarian)
options(datadist=dd)
ovarian$rx = as.factor(ovarian$rx)
cp = cph(Surv(futime,fustat)~rx,data=ovarian,surv=TRUE,x=TRUE,y=TRUE)
summary(cp)
survplot(cp,rx=NA)
# works ok, without casting to a data frame
survest(cp,newdata=levels(ovarian$rx),what=survival,times=500)


It's just an accident that it ever worked without making it a data frame.

Frank



# Small data set, 223 rows, 3650 bytes
cc = read.table(http://www.menne-biomed.de/uni/cc.csv,header=TRUE)
#cc = read.table(cc.csv,header=TRUE)
dd = datadist(cc)
cp = cph(Surv(DaysToEvent,event)~ITTGroup,data=cc,surv=TRUE,x=TRUE,y=TRUE)
survplot(cp,ITTGroup=NA)
summary(cp)

survest(cp,newdata=levels(cc$ITTGroup),times=200)
#Error in survfit.cph(list(coefficients = c(0.435291247251185,
-0.143015493753166 :
#  NA/NaN/Inf in foreign function call (arg 13)
#In addition: Warning message:
#NAs introduced by coercion

# Works when explicitly converted to a data frame
survest(cp,newdata=data.frame(ITTGroup=levels(cc$ITTGroup)),times=200)

 




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


[R] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer

Hi,

Algorithm question: I have two sets of intervals, where an interval is 
an ordered pair [a,b] of two numbers. Is there an efficient way in R to 
generate the intersection of two lists of same?


For concreteness: I'm representing a set of intervals with a data.frame:

 list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
 list1
  open close
11 2
2510

 list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
 list2
  open close
1  1.5   2.5
2  3.0  10.0

How do I get the intersection which would be something like:
  open close
1  1.5   2.0
2  5.0  10.0

I wonder if there's some ready-built functionality that might help me 
out. I'm new to R and am still learning to vectorize my code and my 
thinking. Or maybe there's a package for interval arithmetic that I can 
just pull off the shelf.


Thanks,

-tom

--
Thomas Meyer

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

2009-04-15 Thread Gabor Grothendieck
Check out:

http://tolstoy.newcastle.edu.au/R/help/05/07/8950.html

but use

wkbk$SaveAs(\\test.xlsx)

instead of the corresponding line there.

You must have Excel 2007 on your machine for this to work.

On Wed, Apr 15, 2009 at 8:43 AM, Katrien Baert katrien.ba...@ugent.be wrote:
 Dear all,

 I have been looking for possibilities to read and write Excel 2007-files in
 and from R.
 The 'reading' part is ok through odbcConnectExcel2007 and sqlFetch(RODBC).

 For 'writing' I thought of using sqlSave in the same package, but it does
 not work (I think because this function starts from an existing file). Is
 there a workaround for this, or are there other plausible options for
 writing .xlsx files?

 With kind regards,

 Katrien

 PS: I found some information about RExcelInstaller, if this is something
 that would solve my problems could someone describe how it works (the user
 manual did not help me very much).

 --
 Katrien Baert
 Statistical Consultant
 IOF valorisatieconsortium Stat-Gent

 T 32 9 264 47 66

 http://www.statgent.org/

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Darker markers for symbols in lattice

2009-04-15 Thread Naomi B. Robbins
Adding

par.settings = list(grid.pars = list(lwd = 3)) 

to my code which uses simpleKey gives exactly what I want.

However, if I use auto.key, I lose all the formatting and get
default colors and symbols. 

I am indebted to Deepayan for once again providing the key 
(pun intended) to a solution.

My figure is a superposed dotplot similar to the barley example.
I like to vary the symbols even if I use color as an aid to those
with color vision deficiencies and choose my colors with color
vision deficiency in mind.

Naomi


Deepayan Sarkar wrote:
 On Mon, Apr 13, 2009 at 9:37 AM, Naomi B. Robbins
 nbrgra...@optonline.net wrote:
   
 Now that I have the markers the weight I want using lex, I'm having trouble
 making the key
 match the markers. Any suggestions? BTW, I'm using R2.8.1 with Windows
 Vista.
 

 There's no real solution, but for some reason, the following seems to work:

 xyplot(1:10 ~ 1:10, groups = gl(3, 1), auto.key = TRUE, lex = 3,
 par.settings = list(grid.pars = list(lwd = 3)))

 -Deepayan


   

/
http://www.nbr-graphs.com/bookframe.html/


[[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] Search for a graph package - solved

2009-04-15 Thread Knut Krueger

Dear Gábor,
thank you for your help, I tried the 0.5.2 Version.
It works fine.
The team is very satisfied with the curved graph.

Regards Knut

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Building GUI for custom R application

2009-04-15 Thread Michael Lawrence
On Tue, Apr 14, 2009 at 1:23 AM, Harsh singhal...@gmail.com wrote:

 HI R users,
 I would appreciate information/examples/suggestions on building GUIs
 for R applications.
 I am currently working on a project that would require the following
 functionalities :

 1) Display a  window to the user. Provide a function to scan local
 drive and choose dataset file.
 2) Display the column names for the user to choose the dependent
 variable and the independent variables.
 3) Fit regression and display statistics.

 While researching the possibility of creating a GUI which would allow
 for the above mentioned computations, I came across:

 1) rpanel: Simple Interactive Controls for R Functions Using the tcltk
 Package
 Found In: Journal of Statistical Software, January 2007, Volume 17, Issue
 9.


 2) Putting RGtk to Work, James Robison-Cox
 Found In:Proceedings of the 3rd International Workshop on Distributed
 Statistical Computing (DSC 2003),March 20–22, Vienna, Austria ISSN
 1609-395X
 http://www.ci.tuwien.ac.at/Conferences/DSC-2003/

 Item 2 provides an example of creating a regression application with
 slider controls for a parameter in loess function used in the example
 application in that paper.
 For documentation on RGtk the author recommends reading the Gtk
 tutorial and documentation. I seem to have difficulty in making sense
 of the Gtk documentation since most of it is in C and documentation is
 available for use of Gtk with Perl and Python. I am not a
 C/Perl/Python programmer.


RGtk2 is completely documented within the R help system, with all code
examples converted to R code. There are also a couple dozen demos. For a
simple GUI like the one above, try gWidgets. The pmg package implements a
gWidgets GUI that includes functionality much like what you describe.



 Moreover, I am creating a Windows Application and is using RGtk2 the
 only way to create a GUI for an R application?
 Or should I use the the VB approach and create the GUI separately and
 call R scripts where required to do the back-end computation?

 Another approach (to make the visualization more rich and dynamic) is
 to use Adobe FLEX front end and communicate with R using the RSOAP
 library. There is very sparse documentation relevant to using RSOAP. I
 have not been able to find examples or tutorials using RSOAP. Any
 information in this regard will be highly appreciated.

 The Biocep project provides 'R for cloud computing' but unfortunately
 I have not been able to extract relevant 'juice' from their webpage.
 What i did get is their R workbench, but that has not answered my
 above mentioned queries.

 Regards,

 Harsh Singhal

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Intersection of two sets of intervals

2009-04-15 Thread Duncan Murdoch

On 4/15/2009 8:59 AM, Thomas Meyer wrote:

Hi,

Algorithm question: I have two sets of intervals, where an interval is 
an ordered pair [a,b] of two numbers. Is there an efficient way in R to 
generate the intersection of two lists of same?


For concreteness: I'm representing a set of intervals with a data.frame:

  list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
  list1
   open close
11 2
2510

  list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
  list2
   open close
1  1.5   2.5
2  3.0  10.0

How do I get the intersection which would be something like:
   open close
1  1.5   2.0
2  5.0  10.0

I wonder if there's some ready-built functionality that might help me 
out. I'm new to R and am still learning to vectorize my code and my 
thinking. Or maybe there's a package for interval arithmetic that I can 
just pull off the shelf.


pmax and pmin should be helpful.  I don't know how you want to represent 
empty intersections, but I'd just compute the pmax of the lower bounds, 
the pmin of the upper bounds, and then if the new upper bound is less 
than the new lower bound, treat it as empty.


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Intersection of two sets of intervals

2009-04-15 Thread Dimitris Rizopoulos

one way is:

list1 - as.data.frame(list(open=c(1,5), close=c(2,10)))
list2 - as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))

data.frame(
open = pmax(list1$open, list2$open),
close = pmin(list1$close, list2$close)
)


I hope it helps.

Best,
Dimitris


Thomas Meyer wrote:

Hi,

Algorithm question: I have two sets of intervals, where an interval is 
an ordered pair [a,b] of two numbers. Is there an efficient way in R to 
generate the intersection of two lists of same?


For concreteness: I'm representing a set of intervals with a data.frame:

  list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
  list1
  open close
11 2
2510

  list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
  list2
  open close
1  1.5   2.5
2  3.0  10.0

How do I get the intersection which would be something like:
  open close
1  1.5   2.0
2  5.0  10.0

I wonder if there's some ready-built functionality that might help me 
out. I'm new to R and am still learning to vectorize my code and my 
thinking. Or maybe there's a package for interval arithmetic that I can 
just pull off the shelf.


Thanks,

-tom



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Intersection of two sets of intervals

2009-04-15 Thread ONKELINX, Thierry
Not of the self but still not complicated:

list1 - data.frame(open=c(1,5), close=c(2,10))
list2 - data.frame(open=c(1.5,3), close=c(2.5,10))

Intersec - data.frame(Open = pmax(list1$open, list2$open), Close =
pmin(list1$close, list2$close))
Intersec[Intersec$Open  Intersec$Close, ] - NA
Intersec

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Thomas Meyer
Verzonden: woensdag 15 april 2009 14:59
Aan: r-help@r-project.org
Onderwerp: [R] Intersection of two sets of intervals

Hi,

Algorithm question: I have two sets of intervals, where an interval is

an ordered pair [a,b] of two numbers. Is there an efficient way in R to 
generate the intersection of two lists of same?

For concreteness: I'm representing a set of intervals with a data.frame:

  list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
  list1
   open close
11 2
2510

  list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
  list2
   open close
1  1.5   2.5
2  3.0  10.0

How do I get the intersection which would be something like:
   open close
1  1.5   2.0
2  5.0  10.0

I wonder if there's some ready-built functionality that might help me 
out. I'm new to R and am still learning to vectorize my code and my 
thinking. Or maybe there's a package for interval arithmetic that I can 
just pull off the shelf.

Thanks,

-tom

-- 
Thomas Meyer

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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

2009-04-15 Thread Paul Smith
On Wed, Apr 15, 2009 at 1:27 PM, Manuel Gutierrez
manuelgutierrezlo...@gmail.com wrote:
 I want to fit the model y=a*x^b using nls; where a should be different for
 each level of a factor.
 What is the easiest way to fit it? Can i do it with nls?
 I've looked the help pages and the MASS example in page 249 but the formula
 is different and I don't know how to specify it for my model.

What about linearizing the model with log() and use lm() afterwards?

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] Intersection of two sets of intervals

2009-04-15 Thread Stavros Macrakis
There is a very nice intervals package in CRAN.  It is impressively
efficient even for intersections of many millions of intervals.  If I
remember correctly, it is purely in-core, so on a 32-bit R you'll be
limited to something like 100 million intervals.  Is that enough for
your application?

  -s

On Wed, Apr 15, 2009 at 8:59 AM, Thomas Meyer t...@cornell.edu wrote:
 Hi,

 Algorithm question: I have two sets of intervals, where an interval is an
 ordered pair [a,b] of two numbers. Is there an efficient way in R to
 generate the intersection of two lists of same?

 For concreteness: I'm representing a set of intervals with a data.frame:

 list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
 list1
  open close
 1    1     2
 2    5    10

 list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
 list2
  open close
 1  1.5   2.5
 2  3.0  10.0

 How do I get the intersection which would be something like:
  open close
 1  1.5   2.0
 2  5.0  10.0

 I wonder if there's some ready-built functionality that might help me out.
 I'm new to R and am still learning to vectorize my code and my thinking. Or
 maybe there's a package for interval arithmetic that I can just pull off the
 shelf.

 Thanks,

 -tom

 --
 Thomas Meyer

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

2009-04-15 Thread Paul Smith
On Wed, Apr 15, 2009 at 2:33 PM, Paul Smith phh...@gmail.com wrote:
 On Wed, Apr 15, 2009 at 1:27 PM, Manuel Gutierrez
 manuelgutierrezlo...@gmail.com wrote:
 I want to fit the model y=a*x^b using nls; where a should be different for
 each level of a factor.
 What is the easiest way to fit it? Can i do it with nls?
 I've looked the help pages and the MASS example in page 249 but the formula
 is different and I don't know how to specify it for my model.

 What about linearizing the model with log() and use lm() afterwards?

Oops, sorry, I misread your post -- 'a' changes with the level of a factor.

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] using Sweave, how to save a plot in a given size

2009-04-15 Thread Lore M

After few corrections, it does work. But I have several plots to include in my 
document and, because of those commands, they're all on the same line even if 
there are 20 plots. I mean that Latex doesn't car about textwidth anymore and I 
get an overfull box (too wide).
What could I do to correct that ?
Thanks. 

 Subject: RE: [R] using Sweave, how to save a plot in a given size
 Date: Wed, 15 Apr 2009 13:55:57 +0200
 From: thierry.onkel...@inbo.be
 To: tchiba...@hotmail.com; wolfgang.raffelsber...@igbmc.fr; 
 r-help@r-project.org
 
 Dear Lore,
 
 The easiest thing to do is to write a function that saves your plot to a file 
 and generates the latex code.
 
 label=fig1, fig=FALSE, result = tex=
 pdf(fig1.pdf, width = wid, heigth = hei)
   plot(1:10)
 dev.off()
 cat(\begin{figure}\)
 cat(\includegraphics[width = , wid, , height = , hei, ]{proj1-fig1}\}
 cat(\end{figure})
 @
 
 HTH,
 
 Thierry
 
 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] 
 Namens Lore M
 Verzonden: woensdag 15 april 2009 13:46
 Aan: wolfgang.raffelsber...@igbmc.fr; R Help
 Onderwerp: Re: [R] using Sweave, how to save a plot in a given size
 
 
 Yes it works, but I still have a problem.
 The thing is that I know the dimensions of my plot but in the R code, not in 
 the latex code. So I tried to do :
 
 \SweaveOpts{prefix.string=proj1}
  
 label=fig1,fig=T,include=F,width=\Sexpr{wid}, height=\Sexpr{hei}=
 plot(1:10)
 @
 
 \begin{figure}
 \includegraphics {proj1-fig1}   %% show
 \end{figure}
 
 But Latex doen't find the value of wid and hei when it creates the chunk 
 code. But in the Latex code, it works and I do have the right value for wid 
 and hei.
 
 Lore.
 
 
  Date: Tue, 14 Apr 2009 12:42:16 +0200
  From: wr...@titus.u-strasbg.fr
  To: tchiba...@hotmail.com
  CC: r-help@r-project.org
  Subject: Re: [R] using Sweave, how to save a plot in a given size
  
  Hi I do somthing like:
  
  \SweaveOpts{prefix.string=proj1}
  
  label=fig1,fig=T,include=F,width=8, height=12=
  plot(1:10)
  @
  
  \begin{figure}
  \includegraphics {proj1-fig1}   %% show
  \label{..}
  \end{figure}
  
  
  Wolfgang
  
  
  Lore M a écrit :
  
  
  
  
  
  
   Hi,

   I'm trying to realise a repport with R and Latex (TeXnicCenter and Miktex 
   for Windows) using Sweave(). 
   I'd like to save my plots in a given size. How can I do that ? The code 
   is :

   \SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE}
   partI, echo=FALSE ,fig=TRUE, include=FALSE=  
   plotFunction()
   @
   \includepdf[pages=-]{figs/plot-partI}
  
   When I use par(pin=c(width,height)), I get the plot with the right size 
   but saved in a too big pdf page (7in x 7in, the default size of the 
   window).
   So I tried to change the size of the window with the command windows() 
   but then, Sweave can't save the plot correctly.
  
   Thanks everyone.

   Lore.


_
Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger ! 

[[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] Kruskal's MDS results

2009-04-15 Thread Michael Denslow

Hi Dieter,

I'll take a shot at this.
As I understand it, the stress is telling you how the ordination distances 
compare with original dissimilarities that you calculated.

It is a measure how well your ordination has done in representing the 
relationship of your sites. Note that the stress will differ depending on how 
many dimensions are used. I believe the default is k = 2 in isoMDS.

Hope this helps,
Michael


 
 Dear List,
 
 I'm trying to interpret the results of the Kruskal's
 Non-metric Multidimensional Scaling algorithm (isoMDS, MASS
 package).
 
 The 'goodness of fit' is reported as The final stress
 achieved (in percent).
 
 What does this mean exactly? I've tried to google for an
 answer but I've not come up with a definitive answer.
 
 Regards,
 Dieter
 
 
 --
 Dieter Vanderelst
 PhD Student
 
 Active Perception Lab
 University of Antwerp
 http://batbits.webnode.com/
 
 Postal Address:
 Prinsstraat 13
 B-2000 Antwerp
 Belgium

Michael Denslow

Graduate Student
I.W. Carpenter Jr. Herbarium [BOON]
Department of Biology
Appalachian State University
Boone, North Carolina U.S.A.

-- AND --

Communications Manager
Southeast Regional Network of Expertise and Collections
sernec.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Reshuffle a distance object

2009-04-15 Thread Dale Steele
I would like to randomly shuffle a distance object, such as the one
created by ade4{dist.binary} below. My first attempt, using
sample(jc.dist) creates a shuffled vector, losing the lower triangular
structure of the distance object.  How can I Ishuffle the lower
triangular part of a distance matrix without losing the structure?
Thanks.  --Dale

x1 - c(rep(0,4),1)
x2 - c(rep(0,2),rep(1,3))
x3 - c(rep(1,3), rep(0,2))
X - rbind(x1,x2,x3)
X
X - as.data.frame(X)
library(ade4)
jc.dist  - dist.binary(X, method=1)
sample(jc.dist)

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

2009-04-15 Thread Vladan Arsenijevic

Hi all,

I am dealing with a big data frame. When printing something like


allData[[3]]


1  625.364  38.223 21.014 0.216 1.241411V 1050o 58.38065 -0.06178768
2  383.709  55.811 21.435 0.296 1.241411V 1050o 58.38308 -0.03328282
3  434.669  58.597 21.207 0.233 1.241411V 1050o 58.38334 -0.03930350
4  687.306  69.418 20.873 0.171 1.241411V 1050o 58.38425 -0.06914694
5  759.522 104.019 22.473 0.685 1.241411V 1050o 58.38824 -0.07772423

1   58.43595 -0.04950218NA
2   58.43595 -0.04950218NA
3   58.43595 -0.04950218NA
4   58.43595 -0.04950218NA
5   58.43595 -0.04950218NA

I get the following. Oddly, the output looks like a word wrap was  
performed and is the same whether I run R from emacs or terminal.  
Since I want to print the whole data frame, I need some tips to solve  
this format problem.


Cheers!

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


Re: [R] Creating a graphics window (in Windows, with RGui) that is not constrained to the RGui Window

2009-04-15 Thread Joseph Voelkel
Thanks, Uwe. This is exactly what I wanted.

Joe


-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: Wednesday, April 15, 2009 3:42 AM
To: Joseph Voelkel
Cc: r-help@r-project.org
Subject: Re: [R] Creating a graphics window (in Windows,with RGui) that
is not constrained to the RGui Window



Joseph Voelkel wrote:
 Hi, all,
 
 Using RGui, is it possible to create a graphics window that can be
moved
 outside of the RGui window? (This can be done--in fact must be
 done--using Rterm, but I wish to use RGui.)
 
 My interest for this is to use two monitors: in my private monitor I
 wish to execute R code in the Rgui window; in the public monitor I
 want the audience to see the results in the graphic window.

Start RGui in sdi mode: either by setting it in the GUI preferences or 
by calling RGui with option --sdi.

Uwe Ligges



 Thanks,
 
 Joe Voelkel
 Rochester Institute of Technology
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] performing function on data frame

2009-04-15 Thread Karin Lagesen

Hi!

First, pardon me if this is a faq. I think I should be using some sort
of apply, but I am not managing to figure those out.

I have a data frame similar to this:

 d - data.frame(x = LETTERS[1:5], y = rnorm(5), z = rnorm(5))
 d
  x  y  z
1 A  0.1605464 -0.2719820
2 B -0.9258660  1.2623117
3 C -0.3602656  1.5470351
4 D  1.2621797  1.2996500
5 E  0.6021728  0.5027095
 

From this I want to get a new data frame which contains the z scores
based on the values found in each row. For instance for element [C,y],
I would like to calculate (-0.3602656 - mean(column y)/stddev(column
y)).

Thanks!
-- 
Karin Lagesen, Ph.D.
karin.lage...@medisin.uio.no
http://folk.uio.no/karinlag

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

2009-04-15 Thread ONKELINX, Thierry
Have a look at the width argument in ?options 

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Vladan Arsenijevic
Verzonden: woensdag 15 april 2009 16:13
Aan: r-help@r-project.org
Onderwerp: [R] data frame display

Hi all,

I am dealing with a big data frame. When printing something like

 allData[[3]]

1  625.364  38.223 21.014 0.216 1.241411V 1050o 58.38065 -0.06178768
2  383.709  55.811 21.435 0.296 1.241411V 1050o 58.38308 -0.03328282
3  434.669  58.597 21.207 0.233 1.241411V 1050o 58.38334 -0.03930350
4  687.306  69.418 20.873 0.171 1.241411V 1050o 58.38425 -0.06914694
5  759.522 104.019 22.473 0.685 1.241411V 1050o 58.38824 -0.07772423

1   58.43595 -0.04950218NA
2   58.43595 -0.04950218NA
3   58.43595 -0.04950218NA
4   58.43595 -0.04950218NA
5   58.43595 -0.04950218NA

I get the following. Oddly, the output looks like a word wrap was  
performed and is the same whether I run R from emacs or terminal.  
Since I want to print the whole data frame, I need some tips to solve  
this format problem.

Cheers!

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] shift/lag when merge zoo

2009-04-15 Thread j.k

Hello alltogheter,
I have a little problem regarding merging to zoo series.
I want to merge two zoo series to reduce the timegaps between the stamps.
I use the following code:

data.test -
as.POSIXct(seq(data.input01[1,1],data.input01[nrow(data.input01),1],900),tz=GMT)
data.troughput01 - as.zoo(data.input01$V2)
index(data.troughput01) - as.POSIXct(data.input01$V1,tz=GMT)
data.output01 -merge(data.troughput01,zoo(,data.test))

They look like that:

head(data.test)
[1] 2008-01-01 00:00:00 GMT 2008-01-01 00:15:00 GMT 2008-01-01 00:30:00
GMT
[4] 2008-01-01 00:45:00 GMT 2008-01-01 01:00:00 GMT 2008-01-01 01:15:00
GMT

 head(data.troughput01)
2008-01-01 00:00:00 2008-01-01 00:30:00 2008-01-01 01:00:00 2008-01-01
01:30:00 
   12.2418011.2734010.30500
9.33654 
2008-01-01 02:00:00 2008-01-01 02:30:00 
8.36811 7.62456 

 head(data.output01)
2008-01-01 01:00:00 2008-01-01 01:15:00 2008-01-01 01:30:00 2008-01-01
01:45:00 
12.2418  NA 11.2734 
NA 
2008-01-01 02:00:00 2008-01-01 02:15:00 
10.3050  NA 


Are there any ideas why I have a lag of one hour?

At last I fill the NAs with na.approx:

data.output01 -merge(data.troughput01,zoo(,data.test))

 head(data.output01)
2008-01-01 01:00:00 2008-01-01 01:15:00 2008-01-01 01:30:00 2008-01-01
01:45:00 
   12.2418011.7576011.27340   
10.78920 
2008-01-01 02:00:00 2008-01-01 02:15:00 
   10.30500 9.82077 
 

Maybe there are suggestions for other solutions of achieving the increase of
the resolution.

Thanks in advance
Johannes

-- 
View this message in context: 
http://www.nabble.com/shift-lag-when-merge-zoo-tp23057867p23057867.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] nls factor

2009-04-15 Thread Ravi Varadhan
Hi,

Here is one-way to do it (the following code shows a simulation example):

n - 200

set.seed(123)

x - runif(n)

f - gl(n=2, k=n/2)  # a two-level factor

x1 - x * (f == 1)

x2 - x * (f == 2)

a - c(rep(2, n/2), rep(5, n/2))

b - 0.5

nsim - 100

nls.coef - matrix(NA, nsim, 3)

for (i in 1:nsim) {

eps - rnorm(n, sd=0.5)

y - a * x^b + eps

ans.nls - try(nls(y ~ a1*x1^b + a2*x2^b, start=list(a1=1, a2=1, b=0.25)),
silent=TRUE)

if (class(ans.nls) != try-error) nls.coef[i, ] - coef(ans.nls)

}

apply(nls.coef, 2, summary)  
 
Hope this helps,
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: rvarad...@jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Manuel Gutierrez
Sent: Wednesday, April 15, 2009 8:27 AM
To: r-help@r-project.org
Subject: [R] nls factor

I want to fit the model y=a*x^b using nls; where a should be different for
each level of a factor.
What is the easiest way to fit it? Can i do it with nls?
I've looked the help pages and the MASS example in page 249 but the formula
is different and I don't know how to specify it for my model.
Thanks,
Manuel

[[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] performing function on data frame

2009-04-15 Thread David Hajage
Hi Karin,

I'm not sure I understand... Is this what you want ?

d$y - mean(d$y)/sd(d$y)

2009/4/15 Karin Lagesen karin...@ifi.uio.no


 Hi!

 First, pardon me if this is a faq. I think I should be using some sort
 of apply, but I am not managing to figure those out.

 I have a data frame similar to this:

  d - data.frame(x = LETTERS[1:5], y = rnorm(5), z = rnorm(5))
  d
  x  y  z
 1 A  0.1605464 -0.2719820
 2 B -0.9258660  1.2623117
 3 C -0.3602656  1.5470351
 4 D  1.2621797  1.2996500
 5 E  0.6021728  0.5027095
 

 From this I want to get a new data frame which contains the z scores
 based on the values found in each row. For instance for element [C,y],
 I would like to calculate (-0.3602656 - mean(column y)/stddev(column
 y)).

 Thanks!
 --
 Karin Lagesen, Ph.D.
 karin.lage...@medisin.uio.no
 http://folk.uio.no/karinlag

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] How to Reshuffle a distance object

2009-04-15 Thread Sarah Goslee
You don't say what your intent is, but for most applications it's
important to preserve the pairwise matches. Here's one way
to do that.

library(ecodist) # for the convenient functions lower() and full()
library(ade4)
x1 - c(rep(0,4),1)
x2 - c(rep(0,2),rep(1,3))
x3 - c(rep(1,3), rep(0,2))
X - as.data.frame(rbind(x1, x2, x3))
jc.dist  - dist.binary(X, method=1)

jc.full - full(jc.dist)
dim(jc.full) # 3 x 3
randsample - sample(1:nrow(jc.full))
jc.randfull - jc.full[randsample, randsample]
jc.randdist - lower(jc.randfull)

# if it needs to be of class dist
attributes(jc.randdist) - attributes(jc.dist)

If just putting the distances in a random order is really all right for
your application, you can skip everything except the last step.
jc.new - sample(jc.dist)
attributes(jc.new) - attributes(jc.dist)

Sarah

On Wed, Apr 15, 2009 at 10:02 AM, Dale Steele dale.w.ste...@gmail.com wrote:
 I would like to randomly shuffle a distance object, such as the one
 created by ade4{dist.binary} below. My first attempt, using
 sample(jc.dist) creates a shuffled vector, losing the lower triangular
 structure of the distance object.  How can I Ishuffle the lower
 triangular part of a distance matrix without losing the structure?
 Thanks.  --Dale

 x1 - c(rep(0,4),1)
 x2 - c(rep(0,2),rep(1,3))
 x3 - c(rep(1,3), rep(0,2))
 X - rbind(x1,x2,x3)
 X
 X - as.data.frame(X)
 library(ade4)
 jc.dist  - dist.binary(X, method=1)
 sample(jc.dist)




-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] labcon(adehabitat) large number of patches

2009-04-15 Thread milton ruser
Dear all,

I have about 20,000 binary images, on the sense of habitat / non-habitat.
I am running labcon() on these images (512x512pix), but when the
number of patches is very large, the labcon stop, without error, and
never end.
I am running on a Linux machine, with 6Gb ram (memory is not problem,
because when the labcon run one image, it takes 7seconds).

 sessionInfo()
R version 2.8.1 (2008-12-22)
x86_64-pc-linux-gnu

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

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

other attached packages:
[1] gpclib_1.4-3 adehabitat_1.8.2 ade4_1.4-10

Any help are welcome.

milton
brazil-toronto

[[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] using Sweave, how to save a plot in a given size

2009-04-15 Thread ONKELINX, Thierry
This seems more a LaTeX problem than an R problem. But can you provide us (an 
sample example of) the LaTeX code the yields the overfull box.
 


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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






Van: Lore M [mailto:tchiba...@hotmail.com] 
Verzonden: woensdag 15 april 2009 15:44
Aan: ONKELINX, Thierry; R Help
Onderwerp: RE: [R] using Sweave, how to save a plot in a given size


After few corrections, it does work. But I have several plots to include in my 
document and, because of those commands, they're all on the same line even if 
there are 20 plots. I mean that Latex doesn't car about textwidth anymore and I 
get an overfull box (too wide).
What could I do to correct that ?
Thanks. 

 Subject: RE: [R] using Sweave, how to save a plot in a given size
 Date: Wed, 15 Apr 2009 13:55:57 +0200
 From: thierry.onkel...@inbo.be
 To: tchiba...@hotmail.com; wolfgang.raffelsber...@igbmc.fr; 
 r-help@r-project.org
 
 Dear Lore,
 
 The easiest thing to do is to write a function that saves your plot to a file 
 and generates the latex code.
 
 label=fig1, fig=FALSE, result = tex=
 pdf(fig1.pdf, width = wid, heigth = hei)
 plot(1:10)
 dev.off()
 cat(\begin{figure}\)
 cat(\includegraphics[width = , wid, , height = , hei, ]{proj1-fig1}\}
 cat(\end{figure})
 @
 
 HTH,
 
 Thierry
 
 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] 
 Namens Lore M
 Verzonden: woensdag 15 april 2009 13:46
 Aan: wolfgang.raffelsber...@igbmc.fr; R Help
 Onderwerp: Re: [R] using Sweave, how to save a plot in a given size
 
 
 Yes it works, but I still have a problem.
 The thing is that I know the dimensions of my plot but in the R code, not in 
 the latex code. So I tried to do :
 
 \SweaveOpts{prefix.string=proj1}
 
 label=fig1,fig=T,include=F,width=\Sexpr{wid}, height=\Sexpr{hei}=
 plot(1:10)
 @
 
 \begin{figure}
 \includegraphics {proj1-fig1} %% show
 \end{figure}
 
 But Latex doen't find the value of wid and hei when it creates the chunk 
 code. But in the Latex code, it works and I do have the right value for wid 
 and hei.
 
 Lore.
 
 
  Date: Tue, 14 Apr 2009 12:42:16 +0200
  From: wr...@titus.u-strasbg.fr
  To: tchiba...@hotmail.com
  CC: r-help@r-project.org
  Subject: Re: [R] using Sweave, how to save a plot in a given size
  
  Hi I do somthing like:
  
  \SweaveOpts{prefix.string=proj1}
  
  label=fig1,fig=T,include=F,width=8, height=12=
  plot(1:10)
  @
  
  \begin{figure}
  \includegraphics {proj1-fig1} %% show
  \label{..}
  \end{figure}
  
  
  Wolfgang
  
  
  Lore M a écrit :
  
  
  
  
  
  
   Hi,
   
   I'm trying to realise a repport with R and Latex (TeXnicCenter and Miktex 
   for Windows) using Sweave(). 
   I'd like to save my plots in a given size. How can I do that ? The code 
   is :
   
   \SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE}
   partI, echo=FALSE ,fig=TRUE, include=FALSE= 
   plotFunction()
   @
   \includepdf[pages=-]{figs/plot-partI}
  
   When I use par(pin=c(width,height)), I get the plot with the right size 
   but saved in a too big pdf page (7in x 7in, the default size of the 
   window).
   So I tried to change the size of the window with the command windows() 
   but then, Sweave can't save the plot correctly.
  
   Thanks everyone.
   
   Lore.





Souhaitez vous  « être au bureau sans y être » ? Oui je le veux ! 
http://www.microsoft.com/france/windows/bts/default.mspx  

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

[[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] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer

pmax/pmin did the trick nicely -- the right-size tool I was hoping for.

Thanks to all,

-tom

On 4/15/2009 9:14 AM, ONKELINX, Thierry wrote:

Not of the self but still not complicated:

list1 - data.frame(open=c(1,5), close=c(2,10))
list2 - data.frame(open=c(1.5,3), close=c(2.5,10))

Intersec - data.frame(Open = pmax(list1$open, list2$open), Close =
pmin(list1$close, list2$close))
Intersec[Intersec$Open  Intersec$Close, ] - NA
Intersec

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 


To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Thomas Meyer
Verzonden: woensdag 15 april 2009 14:59
Aan: r-help@r-project.org
Onderwerp: [R] Intersection of two sets of intervals

Hi,

Algorithm question: I have two sets of intervals, where an interval is

an ordered pair [a,b] of two numbers. Is there an efficient way in R to 
generate the intersection of two lists of same?


For concreteness: I'm representing a set of intervals with a data.frame:

  list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
  list1
   open close
11 2
2510

  list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
  list2
   open close
1  1.5   2.5
2  3.0  10.0

How do I get the intersection which would be something like:
   open close
1  1.5   2.0
2  5.0  10.0

I wonder if there's some ready-built functionality that might help me 
out. I'm new to R and am still learning to vectorize my code and my 
thinking. Or maybe there's a package for interval arithmetic that I can 
just pull off the shelf.


Thanks,

-tom



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


[R] GEEs - custom link functions

2009-04-15 Thread Mark Edmondson-Jones
Dear All,

Is it possible to run a GEE analysis with a custom link function in R?

In particular I'm wanting to use a mafc.logit() generated link function
(using the package psyphy).  I can use this with a GLM, but it looks like
the gee package only accepts predefined link functions.

Thanks,
Mark


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extending a vector to length n

2009-04-15 Thread hadley wickham
In general, how can I increase a vector of length m ( n) to length n
by padding it with m - n missing values, without losing attributes?
The two approaches I've tried, using length- and adding missings with
c, do not work in general:

 a - as.Date(2008-01-01)
 c(a, NA)
[1] 2008-01-01 NA
 length(a) - 2
 a
[1] 13879NA


 b - factor(a)
 c(b, NA)
[1]  1 NA
 length(b) - 2
 b
[1] aNA
Levels: a

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] using Sweave, how to save a plot in a given size

2009-04-15 Thread Lore M

You're right, I'm sorry to disturb you with my Latex problem. 
If anyone has an idea, here is the Latex code that I get : 

\begin{figure}
\multido{\i=1+1}{7}{\includegraphics[page=\i,width=1.5in, height = 
1.5in]{image.pdf} \\ }
\end{figure}

I tried to break the line with \\ or with \linebreak but it still doesn't 
want to work.

Subject: RE: [R] using Sweave, how to save a plot in a given size
Date: Wed, 15 Apr 2009 16:29:38 +0200
From: thierry.onkel...@inbo.be
To: tchiba...@hotmail.com; r-help@r-project.org










This seems more a LaTeX problem than an R problem. But can you 
provide us (an sample example of) the LaTeX code the yields the overfull 
box.
  



Van: Lore M [mailto:tchiba...@hotmail.com] 

Verzonden: woensdag 15 april 2009 15:44
Aan: ONKELINX, 
Thierry; R Help
Onderwerp: RE: [R] using Sweave, how to save a plot in 
a given size


After few corrections, it does work. But I have several plots to 
include in my document and, because of those commands, they're all on the same 
line even if there are 20 plots. I mean that Latex doesn't car about textwidth 
anymore and I get an overfull box (too wide).
What could I do to correct that 
?
Thanks. 

 Subject: RE: [R] using Sweave, how to save a plot in a 
given size
 Date: Wed, 15 Apr 2009 13:55:57 +0200
 From: 
thierry.onkel...@inbo.be
 To: tchiba...@hotmail.com; 
wolfgang.raffelsber...@igbmc.fr; r-help@r-project.org
 
 Dear 
Lore,
 
 The easiest thing to do is to write a function that saves 
your plot to a file and generates the latex code.
 
 
label=fig1, fig=FALSE, result = tex=
 pdf(fig1.pdf, 
width = wid, heigth = hei)
 plot(1:10)
 dev.off()
 
cat(\begin{figure}\)
 cat(\includegraphics[width = , wid, , height = 
, hei, ]{proj1-fig1}\}
 cat(\end{figure})
 @
 
 
HTH,
 
 Thierry
 
 -Oorspronkelijk 
bericht-
 Van: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] Namens Lore M
 Verzonden: woensdag 
15 april 2009 13:46
 Aan: wolfgang.raffelsber...@igbmc.fr; R Help
 
Onderwerp: Re: [R] using Sweave, how to save a plot in a given size
 

 
 Yes it works, but I still have a problem.
 The thing is 
that I know the dimensions of my plot but in the R code, not in the latex code. 
So I tried to do :
 
 \SweaveOpts{prefix.string=proj1}
 

 label=fig1,fig=T,include=F,width=\Sexpr{wid}, 
height=\Sexpr{hei}=
 plot(1:10)
 @
 
 
\begin{figure}
 \includegraphics {proj1-fig1} %% show
 
\end{figure}
 
 But Latex doen't find the value of wid and hei 
when it creates the chunk code. But in the Latex code, it works and I do have 
the right value for wid and hei.
 
 Lore.
 
 

  Date: Tue, 14 Apr 2009 12:42:16 +0200
  From: 
wr...@titus.u-strasbg.fr
  To: tchiba...@hotmail.com
  CC: 
r-help@r-project.org
  Subject: Re: [R] using Sweave, how to save a 
plot in a given size
  
  Hi I do somthing like:
 
 
  \SweaveOpts{prefix.string=proj1}
  
  
label=fig1,fig=T,include=F,width=8, height=12=
  
plot(1:10)
  @
  
  \begin{figure}
  
\includegraphics {proj1-fig1} %% show
  \label{..}
  
\end{figure}
  
  
  Wolfgang
  

  
  Lore M a écrit :
  
  

  
  
  
  

   Hi,
   
   I'm trying to 
realise a repport with R and Latex (TeXnicCenter and Miktex for Windows) using 
Sweave(). 
   I'd like to save my plots in a given size. How can 
I do that ? The code is :
   
   
\SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE}
  
 partI, echo=FALSE ,fig=TRUE, include=FALSE= 
  
 plotFunction()
   @
   
\includepdf[pages=-]{figs/plot-partI}
  
   When I 
use par(pin=c(width,height)), I get the plot with the right size but saved in a 
too big pdf page (7in x 7in, the default size of the window).
   
So I tried to change the size of the window with the command windows() but 
then, 
Sweave can't save the plot correctly.
  
   Thanks 
everyone.
   
   Lore.


_
Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger ! 

[[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] issue with L-BFGS-B in optim (optim just hangs)

2009-04-15 Thread Tiago Marques

Dear R-Help List,

I am using optim, with method=L-BFGS-B, to maximize a likelihood inside 
a large simulation exercise. This runs fine for most simulated data 
sets, but for some reason, about 1 out of 100 times, optim will just hang.
Using a dumb approach to the problem (i.e. printing the parameter values 
each time the function being maximized is evaluated), I tracked down 
when this happens, and although I do not understand optim's behavior or 
what triggers it, it seems to happen specifically when one of the 
parameter boundaries is reached - and then the function just stops being 
evaluated.


But there is nothing special with the parameter boundary, i.e., if  I 
decrease or increase the boundary using say lower and upper arguments in 
optim, the function seems to hang at the new values. So it does not seem 
to be a specific value that triggers the behavior, but the fact that the 
value is the boundary defined in the function call.


As anyone seen this behavior before? Is it me missing something or is 
this some bug in method=L-BFGS-B? Any suggestions on how to deal with it?


Many thanks for any useful feedback,

Tiago

--
 


Tiago André Marques
Research Unit for Wildlife Population Assessment
Centre for Research into Ecological and Environmental Modelling
University of St Andrews
The Observatory
Buchanan Gardens
St Andrews
Fife KY16 9LZ
Scotland

Tel: 00441334461842 Fax: 00441334461800 (Scotland office)
Tel: 00351210198736 (Portugal home)

http://www-maths.mcs.st-andrews.ac.uk/homepages/tam2.html
http://www.creem.st-and.ac.uk/tiago/

The University of St Andrews is a charity registered in Scotland : No 
SC013532


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


Re: [R] using Sweave, how to save a plot in a given size

2009-04-15 Thread Lore M

I just want to add that I didn't have any overful box before I use :

label=fig1, fig=FALSE, results = tex=
pdf(fig1.pdf, 
width = wid, heigth = hei)
plot(1:10)
plot(1:10)
dev.off()
cat(\\begin{figure}[h])
cat(\\centering)
cat(\\multido{\i=1+1}{7}{\includegraphics[page=\i,width=1.5in, height = 
1.5in]{images.pdf}}) 
cat(\\end{figure})
@

but just :

\SweaveOpts{prefix.string=proj1} 
label=fig1,fig=T,include=F,width=1.5, height=1.5=
plot(1:10)
@
\begin{figure}[h]
\multido{\i=1+1}{7}{\includegraphics[page=\i,width=1.5in, height = 
1.5in]{images.pdf}}
\end{figure}

I don't know if this information can help... Thanks a lot everyone.


Subject: RE: [R] using Sweave, how to save a plot in a given size
Date: Wed, 15 Apr 2009 16:29:38 +0200
From: thierry.onkel...@inbo.be
To: tchiba...@hotmail.com; r-help@r-project.org










This seems more a LaTeX problem than an R problem. But can you 
provide us (an sample example of) the LaTeX code the yields the overfull 
box.
 
Van: Lore M [mailto:tchiba...@hotmail.com] 

Verzonden: woensdag 15 april 2009 15:44
Aan: ONKELINX, 
Thierry; R Help
Onderwerp: RE: [R] using Sweave, how to save a plot in 
a given size


After few corrections, it does work. But I have several plots to 
include in my document and, because of those commands, they're all on the same 
line even if there are 20 plots. I mean that Latex doesn't car about textwidth 
anymore and I get an overfull box (too wide).
What could I do to correct that 
?
Thanks. 

 Subject: RE: [R] using Sweave, how to save a plot in a 
given size
 Date: Wed, 15 Apr 2009 13:55:57 +0200
 From: 
thierry.onkel...@inbo.be
 To: tchiba...@hotmail.com; 
wolfgang.raffelsber...@igbmc.fr; r-help@r-project.org
 
 Dear 
Lore,
 
 The easiest thing to do is to write a function that saves 
your plot to a file and generates the latex code.
 
 
label=fig1, fig=FALSE, result = tex=
 pdf(fig1.pdf, 
width = wid, heigth = hei)
 plot(1:10)
 dev.off()
 
cat(\begin{figure}\)
 cat(\includegraphics[width = , wid, , height = 
, hei, ]{proj1-fig1}\}
 cat(\end{figure})
 @
 
 
HTH,
 
 Thierry
 
 -Oorspronkelijk 
bericht-
 Van: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] Namens Lore M
 Verzonden: woensdag 
15 april 2009 13:46
 Aan: wolfgang.raffelsber...@igbmc.fr; R Help
 
Onderwerp: Re: [R] using Sweave, how to save a plot in a given size
 

 
 Yes it works, but I still have a problem.
 The thing is 
that I know the dimensions of my plot but in the R code, not in the latex code. 
So I tried to do :
 
 \SweaveOpts{prefix.string=proj1}
 

 label=fig1,fig=T,include=F,width=\Sexpr{wid}, 
height=\Sexpr{hei}=
 plot(1:10)
 @
 
 
\begin{figure}
 \includegraphics {proj1-fig1} %% show
 
\end{figure}
 
 But Latex doen't find the value of wid and hei 
when it creates the chunk code. But in the Latex code, it works and I do have 
the right value for wid and hei.
 
 Lore.
 
 

  Date: Tue, 14 Apr 2009 12:42:16 +0200
  From: 
wr...@titus.u-strasbg.fr
  To: tchiba...@hotmail.com
  CC: 
r-help@r-project.org
  Subject: Re: [R] using Sweave, how to save a 
plot in a given size
  
  Hi I do somthing like:
 
 
  \SweaveOpts{prefix.string=proj1}
  
  
label=fig1,fig=T,include=F,width=8, height=12=
  
plot(1:10)
  @
  
  \begin{figure}
  
\includegraphics {proj1-fig1} %% show
  \label{..}
  
\end{figure}
  
  
  Wolfgang
  

  
  Lore M a écrit :
  
  

  
  
  
  

   Hi,
   
   I'm trying to 
realise a repport with R and Latex (TeXnicCenter and Miktex for Windows) using 
Sweave(). 
   I'd like to save my plots in a given size. How can 
I do that ? The code is :
   
   
\SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE}
  
 partI, echo=FALSE ,fig=TRUE, include=FALSE= 
  
 plotFunction()
   @
   
\includepdf[pages=-]{figs/plot-partI}
  
   When I 
use par(pin=c(width,height)), I get the plot with the right size but saved in a 
too big pdf page (7in x 7in, the default size of the window).
   
So I tried to change the size of the window with the command windows() but 
then, 
Sweave can't save the plot correctly.
  
   Thanks 
everyone.
   
   Lore.




Souhaitez vous  « être au bureau sans y être » ? Oui 
je le veux ! 

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.
_
Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger ! 

[[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, 

Re: [R] Decomposition of time series with forecast package

2009-04-15 Thread bogaso.christofer
If I am right then you must get the seasonal factor etc (if any) out before
fitting ant ARIMA (or statistical model) i.e. fit ARIMA on residual series
not original series.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of djhurio
Sent: 14 April 2009 17:41
To: r-help@r-project.org
Subject: [R] Decomposition of time series with forecast package

Hi!

I am exploring the forecast package (http://www.robjhyndman.com/
index.php?option=com_contenttask=viewid=55Itemid=71).

I am doing ARIMA modelling with auto.arima() function. Is it possible
to get the decomposition of a time series using the model found by
auto.arima()? I would like to decompose a time series in trend,
seasonal and irregular components according to the model.

I have looked at the decompose() and stl() functions. But these
function do not take into account the specific model found by
auto.arima().


Thanks!
Martins

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

2009-04-15 Thread Manuel Morales
A more compact way to code factors in nls is to use the syntax factor[].

Here's an example using a simplified version of Ravi's example:

n - 200
set.seed(123)
x - runif(n)
a - gl(n=2, k=n/2)  # a two-level factor
eps - rnorm(n, sd=0.5)
y - as.numeric(a) * x^.5 + eps

nls(y ~ a[]*x^b, start=list(a=c(1,1), b=0.25))


Wed, 2009-04-15 at 10:22 -0400, Ravi Varadhan wrote:
 Hi,
 
 Here is one-way to do it (the following code shows a simulation example):
 
 n - 200
 
 set.seed(123)
 
 x - runif(n)
 
 f - gl(n=2, k=n/2)  # a two-level factor
 
 x1 - x * (f == 1)
 
 x2 - x * (f == 2)
 
 a - c(rep(2, n/2), rep(5, n/2))
 
 b - 0.5
 
 nsim - 100
 
 nls.coef - matrix(NA, nsim, 3)
 
 for (i in 1:nsim) {
 
 eps - rnorm(n, sd=0.5)
 
 y - a * x^b + eps
 
 ans.nls - try(nls(y ~ a1*x1^b + a2*x2^b, start=list(a1=1, a2=1, b=0.25)),
 silent=TRUE)
 
 if (class(ans.nls) != try-error) nls.coef[i, ] - coef(ans.nls)
 
 }
 
 apply(nls.coef, 2, summary)  
  
 Hope this helps,
 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: rvarad...@jhmi.edu
 
 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
 
  
 
 
 
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of Manuel Gutierrez
 Sent: Wednesday, April 15, 2009 8:27 AM
 To: r-help@r-project.org
 Subject: [R] nls factor
 
 I want to fit the model y=a*x^b using nls; where a should be different for
 each level of a factor.
 What is the easiest way to fit it? Can i do it with nls?
 I've looked the help pages and the MASS example in page 249 but the formula
 is different and I don't know how to specify it for my model.
 Thanks,
 Manuel
 
   [[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.
-- 
http://mutualism.williams.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] issue with L-BFGS-B in optim (optim just hangs)

2009-04-15 Thread Paul Smith
On Wed, Apr 15, 2009 at 3:57 PM, Tiago Marques ti...@mcs.st-and.ac.uk wrote:
 I am using optim, with method=L-BFGS-B, to maximize a likelihood inside a
 large simulation exercise. This runs fine for most simulated data sets, but
 for some reason, about 1 out of 100 times, optim will just hang.
 Using a dumb approach to the problem (i.e. printing the parameter values
 each time the function being maximized is evaluated), I tracked down when
 this happens, and although I do not understand optim's behavior or what
 triggers it, it seems to happen specifically when one of the parameter
 boundaries is reached - and then the function just stops being evaluated.

 But there is nothing special with the parameter boundary, i.e., if  I
 decrease or increase the boundary using say lower and upper arguments in
 optim, the function seems to hang at the new values. So it does not seem to
 be a specific value that triggers the behavior, but the fact that the value
 is the boundary defined in the function call.

 As anyone seen this behavior before? Is it me missing something or is this
 some bug in method=L-BFGS-B? Any suggestions on how to deal with it?

Can you provide us with a minimal example exhibiting the problem you
are mentioning?

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.


[R] Survreg and censored observations

2009-04-15 Thread David S. Schwarz
How does one indicate that a particular survival time is right censored in
the Survreg routine?


[[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] nls factor

2009-04-15 Thread Manuel Morales
Oops! I made a mistake. Corrected below.

On Wed, 2009-04-15 at 11:05 -0400, Manuel Morales wrote:
 A more compact way to code factors in nls is to use the syntax factor[].
 
 Here's an example using a simplified version of Ravi's example:
 
 n - 200
 set.seed(123)
 x - runif(n)
 a - gl(n=2, k=n/2)  # a two-level factor
call the factor f instead of a:
f - gl(n=2, k=n/2) # a two-level factor
 eps - rnorm(n, sd=0.5)
 y - as.numeric(a) * x^.5 + eps
change equation to reflect above change:
y - as.numeric(f) * x^.5 + eps
 
 nls(y ~ a[]*x^b, start=list(a=c(1,1), b=0.25))
most importantly, fix syntax:
nls(y ~ a[fac]*x^b, start=list(a=c(1,1), b=0.25))

Altogether:
n - 200
set.seed(123)
x - runif(n)
f - gl(n=2, k=n/2) # a two-level factor 
eps - rnorm(n, sd=0.5)
y - as.numeric(f) * x^.5 + eps 

nls(y ~ a[fac]*x^b, start=list(a=c(1,1), b=0.25))

Sorry for any confusion!

Manuel

 Wed, 2009-04-15 at 10:22 -0400, Ravi Varadhan wrote:
  Hi,
  
  Here is one-way to do it (the following code shows a simulation example):
  
  n - 200
  
  set.seed(123)
  
  x - runif(n)
  
  f - gl(n=2, k=n/2)  # a two-level factor
  
  x1 - x * (f == 1)
  
  x2 - x * (f == 2)
  
  a - c(rep(2, n/2), rep(5, n/2))
  
  b - 0.5
  
  nsim - 100
  
  nls.coef - matrix(NA, nsim, 3)
  
  for (i in 1:nsim) {
  
  eps - rnorm(n, sd=0.5)
  
  y - a * x^b + eps
  
  ans.nls - try(nls(y ~ a1*x1^b + a2*x2^b, start=list(a1=1, a2=1, b=0.25)),
  silent=TRUE)
  
  if (class(ans.nls) != try-error) nls.coef[i, ] - coef(ans.nls)
  
  }
  
  apply(nls.coef, 2, summary)  
   
  Hope this helps,
  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: rvarad...@jhmi.edu
  
  Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
  
   
  
  
  
  
  
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
  Behalf Of Manuel Gutierrez
  Sent: Wednesday, April 15, 2009 8:27 AM
  To: r-help@r-project.org
  Subject: [R] nls factor
  
  I want to fit the model y=a*x^b using nls; where a should be different for
  each level of a factor.
  What is the easiest way to fit it? Can i do it with nls?
  I've looked the help pages and the MASS example in page 249 but the formula
  is different and I don't know how to specify it for my model.
  Thanks,
  Manuel
  
  [[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.
-- 
http://mutualism.williams.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] AICs from lmer different with summary and anova

2009-04-15 Thread Jonathan Williams
Dear R Helpers,

I have noticed that when I use lmer to analyse data, the summary function
gives different values for the AIC, BIC and log-likelihood compared with the
anova function.

Here is a sample program

#make some data
set.seed(1);
datx=data.frame(array(runif(720),c(240,3),dimnames=list(NULL,c('x1','x2','y'

id=rep(1:120,2); datx=cbind(id,datx)

#give x1 a slight relation with y (only necessary to make the random effects
non-zero in this artificial example)
datx$x1=(datx$y*0.1)+datx$x1

library(lme4)

#fit the data
fit0=lmer(y~x1+x2+(1|id), data=datx); print(summary(fit0),corr=F)
fit1=lmer(y~x1+x2+(1+x1|id), data=datx); print(summary(fit1),corr=F)

#compare the models
anova(fit0,fit1)


Now, look at the output, below. You can see that the AIC from
print(summary(fit0)) is 87.34, but the AIC for fit0 in anova(fit0,fit1)
is 73.965. There are similar changes for the values of BIC and logLik.

Am I doing something wrong, here? If not, which are the real AIC and logLik
values for the different models?

Thanks for your help,

Jonathan Williams


Output:-

 fit0=lmer(y~x1+x2+(1|id), data=datx); print(summary(fit0),corr=F)
Linear mixed model fit by REML 
Formula: y ~ x1 + x2 + (1 | id) 
   Data: datx 
   AIC   BIC logLik deviance REMLdev
 87.34 104.7 -38.6763.96   77.34
Random effects:
 Groups   NameVariance Std.Dev.
 id   (Intercept) 0.016314 0.12773 
 Residual 0.062786 0.25057 
Number of obs: 240, groups: id, 120

Fixed effects:
Estimate Std. Error t value
(Intercept)  0.503760.05219   9.652
x1   0.089790.06614   1.358
x2  -0.066500.06056  -1.098
 fit1=lmer(y~x1+x2+(1+x1|id), data=datx); print(summary(fit1),corr=F)
Linear mixed model fit by REML 
Formula: y ~ x1 + x2 + (1 + x1 | id) 
   Data: datx 
   AIC   BIC logLik deviance REMLdev
 90.56 114.9 -38.2863.18   76.56
Random effects:
 Groups   NameVariance  Std.Dev. Corr  
 id   (Intercept) 0.0076708 0.087583   
  x1  0.0056777 0.075351 1.000 
 Residual 0.0618464 0.248689   
Number of obs: 240, groups: id, 120

Fixed effects:
Estimate Std. Error t value
(Intercept)  0.500780.05092   9.835
x1   0.092360.06612   1.397
x2  -0.065150.06044  -1.078
 anova(fit0,fit1)
Data: datx
Models:
fit0: y ~ x1 + x2 + (1 | id)
fit1: y ~ x1 + x2 + (1 + x1 | id)
 Df AIC BIC  logLik  Chisq Chi Df Pr(Chisq)
fit0  5  73.965  91.368 -31.982 
fit1  7  77.181 101.545 -31.590 0.7839  2 0.6757

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extending a vector to length n

2009-04-15 Thread Richard . Cotton
 In general, how can I increase a vector of length m ( n) to length n
 by padding it with m - n missing values, without losing attributes?
 The two approaches I've tried, using length- and adding missings with
 c, do not work in general:
 
  a - as.Date(2008-01-01)
  c(a, NA)
 [1] 2008-01-01 NA
  length(a) - 2
  a
 [1] 13879NA
 
 
  b - factor(a)
  c(b, NA)
 [1]  1 NA
  length(b) - 2
  b
 [1] aNA
 Levels: a

You can save the attributes to a new variable, increase the length, then 
reapply the attributes, e.g.

extend - function(x, n)
{
   att - attributes(x)
   length(x) - n
   attributes(x) - att
   x
}

a - as.Date(2008-01-01)
extend(a, 2)
# [1] 2008-01-01 NA

b - factor(a)
extend(b, 2)
# [1] aNA
# Levels: a

It would, perhaps, be nicer if length had an option to preserve 
attributes.

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

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

2009-04-15 Thread Peter Kraglund Jacobsen
What are the R equivalents to the Stata command egen?

egen temp = anycount(t0vas t30vas t60vas t120vas t240vas t360vas),
values(0,1,2,3,4,5,6,7,8,9,10)
egen temp2 = rowtotal(t0vas t30vas t60vas t120vas t240vas t360vas)

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

2009-04-15 Thread jim holtman
Also consider the View function for looking at the dataframe

On Wed, Apr 15, 2009 at 10:13 AM, Vladan Arsenijevic
arsen...@ist.utl.pt wrote:
 Hi all,

 I am dealing with a big data frame. When printing something like

 allData[[3]]

 1  625.364  38.223 21.014 0.216 1.241411    V 1050o 58.38065 -0.06178768
 2  383.709  55.811 21.435 0.296 1.241411    V 1050o 58.38308 -0.03328282
 3  434.669  58.597 21.207 0.233 1.241411    V 1050o 58.38334 -0.03930350
 4  687.306  69.418 20.873 0.171 1.241411    V 1050o 58.38425 -0.06914694
 5  759.522 104.019 22.473 0.685 1.241411    V 1050o 58.38824 -0.07772423

 1   58.43595 -0.04950218    NA
 2   58.43595 -0.04950218    NA
 3   58.43595 -0.04950218    NA
 4   58.43595 -0.04950218    NA
 5   58.43595 -0.04950218    NA

 I get the following. Oddly, the output looks like a word wrap was performed
 and is the same whether I run R from emacs or terminal. Since I want to
 print the whole data frame, I need some tips to solve this format problem.

 Cheers!

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




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

What is the problem that you are trying to solve?

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


Re: [R] issue with L-BFGS-B in optim (optim just hangs)

2009-04-15 Thread Ravi Varadhan
Hi Tiago,

It is hard for me to speculate without knowing more about your problem.  

Here is what I would suggest, assuming your problem specification and its
computer implementation are correct:

(1) You may try to terminate the algorithm by specifying a different
stopping criterion than the default values, and see whether the solution is
of acceptable accuracy.  You can increase factr and/or pgtol to see if
this problem goes away.  

(2) Another option is to increase lmm parameter, which is the number of
BFGS updates saved for approximating the hessian.  Results in Zhu et al.
(ACM 1997) show that increasing lmm tends to improve the reliability of
the algorithm.  Try, for example, lmm=17 (default is lmm = 5).  Also, try
using trace to get more information on what goes on. 

I can also suggest some alternative solutions:

(3).  An easy solution is to try a different optimization algorithm: YOU can
try either nlminb() or spg() in package BB. 

(4).  If it is easy to do so, specify analytic score function, i.e. the
gradient of log-likelohood, and re-run optim() or nlminb() or spg().


Hope this helps,
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: rvarad...@jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html







-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Tiago Marques
Sent: Wednesday, April 15, 2009 10:57 AM
To: r-help@r-project.org
Subject: [R] issue with L-BFGS-B in optim (optim just hangs)

Dear R-Help List,

I am using optim, with method=L-BFGS-B, to maximize a likelihood inside a
large simulation exercise. This runs fine for most simulated data sets, but
for some reason, about 1 out of 100 times, optim will just hang.
Using a dumb approach to the problem (i.e. printing the parameter values
each time the function being maximized is evaluated), I tracked down when
this happens, and although I do not understand optim's behavior or what
triggers it, it seems to happen specifically when one of the parameter
boundaries is reached - and then the function just stops being evaluated.

But there is nothing special with the parameter boundary, i.e., if  I
decrease or increase the boundary using say lower and upper arguments in
optim, the function seems to hang at the new values. So it does not seem to
be a specific value that triggers the behavior, but the fact that the value
is the boundary defined in the function call.

As anyone seen this behavior before? Is it me missing something or is this
some bug in method=L-BFGS-B? Any suggestions on how to deal with it?

Many thanks for any useful feedback,

Tiago

--

 

Tiago André Marques
Research Unit for Wildlife Population Assessment Centre for Research into
Ecological and Environmental Modelling University of St Andrews The
Observatory Buchanan Gardens St Andrews Fife KY16 9LZ Scotland

Tel: 00441334461842 Fax: 00441334461800 (Scotland office)
Tel: 00351210198736 (Portugal home)

http://www-maths.mcs.st-andrews.ac.uk/homepages/tam2.html
http://www.creem.st-and.ac.uk/tiago/

The University of St Andrews is a charity registered in Scotland : No
SC013532

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Controlling widths in write.fwf()

2009-04-15 Thread Vemuri, Aparna
Duncan
I tried writeLines. But I need to print about 23 lines and it is
really slow. 

Thanks
Aparna 

-Original Message-
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Sent: Tuesday, April 14, 2009 4:34 PM
To: Vemuri, Aparna
Cc: r-help@r-project.org
Subject: Re: [R] Controlling widths in write.fwf()

On 14/04/2009 7:28 PM, Vemuri, Aparna wrote:
 Is there a way to handle the widths of values being written to a file
 using wrtite.fwf() ?
 
 For example, I used read.fwf(file, width.vector) to read a file. After
 making the necessary data manipulation, I want to write the data to a
 new file in the same width.vector format. Is there a way to specify
 this?

There is no write.fwf function, but you can use sprintf() to convert 
things to strings and writeLines to write those strings.  There's a lot 
of flexibility in the formats allowed; see the man page.

Duncan Murdoch

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

2009-04-15 Thread Bert Gunter
How about: 

xx[,-match(x2,names(xx))]

or

xx[,names(xx) != x2]

etc. 


Bert Gunter
Genentech Nonclinical Biostatistics
650-467-7374

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Erin Hodgess
Sent: Tuesday, April 14, 2009 10:39 PM
To: R help
Subject: [R] excluding a column from a data frame

Dear R People:

Suppose I have the following data frame:

  x1 x2   x3
1 -0.1582116 0.06635783 1.765448
2 -1.1407422 0.47235664 0.615931
3  0.8702362 2.32301341 2.653805
 str(xx)
'data.frame':   3 obs. of  3 variables:
 $ x1: num  -0.158 -1.141 0.87
 $ x2: num  0.0664 0.4724 2.323
 $ x3: num  1.765 0.616 2.654

I can exclude the second column nicely via:
 xx[,-2]
  x1   x3
1 -0.1582116 1.765448
2 -1.1407422 0.615931
3  0.8702362 2.653805

Now suppose I wanted to exclude the column called x2.  If I try:
 xx[,-x2]
Error in -x2 : invalid argument to unary operator


things don't work.  Is there a simple way to do this by name rather
than number, please?

Thanks,
Erin



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

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

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


Re: [R] Extending a vector to length n

2009-04-15 Thread Gabor Grothendieck
This may not be everything you would like but perhaps its sufficient:

 structure(length-(a, 2), class = class(a))
[1] 2008-01-01 NA

Your second example looks ok as is.  Can't tell what you don't
like about it.

On Wed, Apr 15, 2009 at 10:55 AM, hadley wickham h.wick...@gmail.com wrote:
 In general, how can I increase a vector of length m ( n) to length n
 by padding it with m - n missing values, without losing attributes?
 The two approaches I've tried, using length- and adding missings with
 c, do not work in general:

 a - as.Date(2008-01-01)
 c(a, NA)
 [1] 2008-01-01 NA
 length(a) - 2
 a
 [1] 13879    NA


 b - factor(a)
 c(b, NA)
 [1]  1 NA
 length(b) - 2
 b
 [1] a    NA
 Levels: a

 Hadley



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

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] False convergence error with lmer (package lme4) - What does it mean?

2009-04-15 Thread Peter H Singleton
Hello,

I've run 7 candidate models using mixed-effects logistic regression with 
the lmer function from the lme4 package, and I'm getting the following 
error for 5 of those models: Warning message: In mer_finalize(ans : false 
convergence (8). The candidate models all run with the same data, just 
slightly different formulas (for AIC model selection). Can anyone explain 
this error to me? 

This is the command line syntax I'm using: 
ful1 - lmer(dependent variable ~ formula + (1 | effect), data = cv, 
family=binomial, na.action = na.omit)

The random intercept effect has 14 groups. 

Is there anything I can do to address this error?

---
Peter Singleton
E-mail: psingle...@fs.fed.us
[[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] Lattice xyplot with text under x-axis

2009-04-15 Thread kate.m

Hi All, 

I have a data set which I need to plot and show the values of one of the
variables as a second x-axis. 

library(lattice) 
year-c(2001,2002,2003,2004,2005,2006) 
fac-c(arts,arts,arts,sci,sci,sci) 
staff-c(95,98,99,32,31,36) 
part-c(32,31,33,15,16,14) 
df1-data.frame(year,fac,staff,part) 

xyplot(part~year, type=o, xlab=, ylab=) 

n.val.text-paste(n = , df1$staff, sep = ) 
mtext(n.val.text, side = 1, line = 3, at = axTicks(1), cex = 0.9) 

This works OK. The problem comes in when I plot the data in panels. 

xyplot(part~year | fac, as.table=TRUE, type=o, between=list(x=1,y=1),
xlab=, ylab=, 
scales=list(x=list(alternating=3),y=list(alternating=3), relation=free)) 

The mtext code doesn't work anymore. I think it needs some sort of panel
function (panel.groups?) which would tell it to show the appropriate values
of staff under their respective year for each fac and each panel. 

Could anyone please give me some pointers? I'm very new to R and completely
in the dark on this task. 
Thanks. 

-- 
View this message in context: 
http://www.nabble.com/Lattice-xyplot-with-text-under-x-axis-tp23061842p23061842.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] nls factor

2009-04-15 Thread Michael A. Miller
 Manuel == Manuel Morales manuel.a.mora...@williams.edu writes:

 nls(y ~ a[fac]*x^b, start=list(a=c(1,1), b=0.25))

Did you mean a[f]?

nls(y ~ a[f]*x^b, start=list(a=c(1,1), b=0.25))

Mike

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cross-Validation for Zero-Inflated Models

2009-04-15 Thread lara harrup (IAH-P)
Hi all
 
I have developed a zero-inflated negative binomial model using the
zeroinfl function from the pscl package, which I have carried out model
selection based on AIC and have used likelihood ratio tests (lrtest from
the lmtest package) to compare the nested models  [My end model contains
2 factors and 4 continuous variables in the count model plus one
continuous variable in the zero-inflated portion].
 
But for model assessment I would like to carry out some form of internal
cross-validation along the lines of leave one out cv etc, to gauge the
predictive ability of my final model just wondering if there is any
technique within r for doing this with zero-inflated models/negative
binomial models.
 
n.b. my data set is not large enough to split the data at the start and
only fit the model to a subset of data.
I am using r 2.8.1
 
Many Thanks in Advance
 
Lara

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer
Stavros, you are quite correct -- I discovered that the hard way a 
little while ago when testing my two-line solution. Use of pmin/pmax 
don't handle, for instance, cases where more than one interval in one 
set is wholly contained by an interval in the other. (I have a 
mis-posted msg awaiting moderator approval in R-help with a concrete 
example.)


Your tip to check out the intervals pkg looks promising. FYI, there the 
general intersection is computed as the complement of the union of the 
complements, i.e. A*B = (A'+B')' , aka DeMorgan.


Thanks for the help,

-tom

On 4/15/2009 11:27 AM, Stavros Macrakis wrote:

I can see how pmax/pmin would easily allow the intersection of
corresponding elements of two sequences of intervals, but I don't see
how they help in intersecting two *sets* of intervals, which was the
original problem statement.

-s



On Wed, Apr 15, 2009 at 9:14 AM, ONKELINX, Thierry
thierry.onkel...@inbo.be wrote:

Not of the self but still not complicated:

list1 - data.frame(open=c(1,5), close=c(2,10))
list2 - data.frame(open=c(1.5,3), close=c(2.5,10))

Intersec - data.frame(Open = pmax(list1$open, list2$open), Close =
pmin(list1$close, list2$close))
Intersec[Intersec$Open  Intersec$Close, ] - NA
Intersec

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Thomas Meyer
Verzonden: woensdag 15 april 2009 14:59
Aan: r-help@r-project.org
Onderwerp: [R] Intersection of two sets of intervals

Hi,

Algorithm question: I have two sets of intervals, where an interval is

an ordered pair [a,b] of two numbers. Is there an efficient way in R to
generate the intersection of two lists of same?

For concreteness: I'm representing a set of intervals with a data.frame:

  list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
  list1
  open close
11 2
2510

  list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
  list2
  open close
1  1.5   2.5
2  3.0  10.0

How do I get the intersection which would be something like:
  open close
1  1.5   2.0
2  5.0  10.0

I wonder if there's some ready-built functionality that might help me
out. I'm new to R and am still learning to vectorize my code and my
thinking. Or maybe there's a package for interval arithmetic that I can
just pull off the shelf.

Thanks,

-tom

--
Thomas Meyer

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message
and any annex are purely those of the writer and may not be regarded as stating
an official position of INBO, as long as the message is not confirmed by a duly
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Forcing the extrapolation of loess through the origin

2009-04-15 Thread Charles C. Berry

On Tue, 14 Apr 2009, jimm-pa...@gmx.de wrote:


Hi all,

I'm fitting a line to my dataset. Later I want to predict missing values that exceed the 
[min,max] interval of my empirical data, therefore I choose surface=direct 
for extrapolation.

l1-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface=direct))

In my application it is highly important that the fitted line intercepts at the 
point of origin. Is it possible to do this in R?



Well, yes, but as Burt suggests it may not be sensible.

There are several ways. For one, include a reflection of the 
(x,y) data into opposite quandrants as well as the original data.


Something like

l1-loess( y ~ x , span=0.1, data.frame(x = c(-x1,x1), y = c(-y1,y1)),
control=loess.control(surface=direct))

will force the prediction through the origin.

(I corrected what seems to be as typo in your code, too.)

Of course, if any( x  0 ) it is hard to see how the substantive results 
would make any sense.


HTH,

Chuck



Thanks in advance.

Cheers,
Torsten
--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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:cbe...@tajo.ucsd.edu   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.


[R] clustering, don't understand this error

2009-04-15 Thread Ana M Aparicio Carrasco
Hello,
I am using the dunn metric, but something is wrong and I dont understand
what or what that this error mean. Please can you help me with this?

The instructions are:

 #Indice de Dunn
 disbupa=dist(bupa[,1:6])
 a=hclust(disbupa)
 cluster.stats(disbupa,a,bupa[,7])$dunn

And the error is:

Error in max(clustering) : invalid 'type' (list) of argument

thank you so much.

Ana Maria Aparicio.

[[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] Survreg and censored observations

2009-04-15 Thread Frank E Harrell Jr

David S. Schwarz wrote:

How does one indicate that a particular survival time is right censored in
the Survreg routine?


Read the documentation?   :-)

--
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] Intersection of two sets of intervals

2009-04-15 Thread jim holtman
Here is one way to find the overlaps:

 l1 - rbind(c(1,3), c(5,10), c(13,24))
 l2 - rbind(c(2,4), c(7,14), c(20,30))
 l1
 [,1] [,2]
[1,]13
[2,]5   10
[3,]   13   24
 l2
 [,1] [,2]
[1,]24
[2,]7   14
[3,]   20   30
 # create matrix for overlaps
 start - cbind(c(l1[,1], l2[,1]), 1)
 end - cbind(c(l1[,2], l2[, 2]), -1)
 over - rbind(start, end)
 # order
 over - over[order(over[,1]),]
 # get overlap count
 over - cbind(over, overlap=cumsum(over[,2]))
 # create the overlap matrix
 inter - cbind(start=over[(over[,2] == 1)  (over[,3] == 2), 1],
+end=over[(over[,2] == -1)  (over[, 3] == 1), 1])

 inter
 start end
[1,] 2   3
[2,] 7  10
[3,]13  14
[4,]20  24



On Wed, Apr 15, 2009 at 12:06 PM, Thomas Meyer t...@cornell.edu wrote:
 Stavros, you are quite correct -- I discovered that the hard way a little
 while ago when testing my two-line solution. Use of pmin/pmax don't handle,
 for instance, cases where more than one interval in one set is wholly
 contained by an interval in the other. (I have a mis-posted msg awaiting
 moderator approval in R-help with a concrete example.)

 Your tip to check out the intervals pkg looks promising. FYI, there the
 general intersection is computed as the complement of the union of the
 complements, i.e. A*B = (A'+B')' , aka DeMorgan.

 Thanks for the help,

 -tom

 On 4/15/2009 11:27 AM, Stavros Macrakis wrote:

 I can see how pmax/pmin would easily allow the intersection of
 corresponding elements of two sequences of intervals, but I don't see
 how they help in intersecting two *sets* of intervals, which was the
 original problem statement.

            -s



 On Wed, Apr 15, 2009 at 9:14 AM, ONKELINX, Thierry
 thierry.onkel...@inbo.be wrote:

 Not of the self but still not complicated:

 list1 - data.frame(open=c(1,5), close=c(2,10))
 list2 - data.frame(open=c(1.5,3), close=c(2.5,10))

 Intersec - data.frame(Open = pmax(list1$open, list2$open), Close =
 pmin(list1$close, list2$close))
 Intersec[Intersec$Open  Intersec$Close, ] - NA
 Intersec

 HTH,

 Thierry

 
 
 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for Nature
 and Forest
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 Gaverstraat 4
 9500 Geraardsbergen
 Belgium
 tel. + 32 54/436 185
 thierry.onkel...@inbo.be
 www.inbo.be

 To call in the statistician after the experiment is done may be no more
 than asking him to perform a post-mortem examination: he may be able to
 say what the experiment died of.
 ~ Sir Ronald Aylmer Fisher

 The plural of anecdote is not data.
 ~ Roger Brinner

 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

 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 Namens Thomas Meyer
 Verzonden: woensdag 15 april 2009 14:59
 Aan: r-help@r-project.org
 Onderwerp: [R] Intersection of two sets of intervals

 Hi,

 Algorithm question: I have two sets of intervals, where an interval is

 an ordered pair [a,b] of two numbers. Is there an efficient way in R to
 generate the intersection of two lists of same?

 For concreteness: I'm representing a set of intervals with a data.frame:

   list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
   list1
  open close
 1    1     2
 2    5    10

   list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
   list2
  open close
 1  1.5   2.5
 2  3.0  10.0

 How do I get the intersection which would be something like:
  open close
 1  1.5   2.0
 2  5.0  10.0

 I wonder if there's some ready-built functionality that might help me
 out. I'm new to R and am still learning to vectorize my code and my
 thinking. Or maybe there's a package for interval arithmetic that I can
 just pull off the shelf.

 Thanks,

 -tom

 --
 Thomas Meyer

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

 Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver
 weer
 en binden het INBO onder geen enkel beding, zolang dit bericht niet
 bevestigd is
 door een geldig ondertekend document. The views expressed in  this
 message
 and any annex are purely those of the writer and may not be regarded as
 stating
 an official position of INBO, as long as the message is not confirmed by
 a duly
 signed document.

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

Re: [R] Controlling widths in write.fwf()

2009-04-15 Thread Duncan Murdoch

On 4/15/2009 11:45 AM, Vemuri, Aparna wrote:

Duncan
I tried writeLines. But I need to print about 23 lines and it is
really slow. 


This took about 1 second here:

writeLines(as.character(1:23), C:/temp/test.txt)

I can't see how to make it much faster than that.

Duncan Murdoch



Thanks
Aparna 


-Original Message-
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Sent: Tuesday, April 14, 2009 4:34 PM

To: Vemuri, Aparna
Cc: r-help@r-project.org
Subject: Re: [R] Controlling widths in write.fwf()

On 14/04/2009 7:28 PM, Vemuri, Aparna wrote:

Is there a way to handle the widths of values being written to a file
using wrtite.fwf() ?

For example, I used read.fwf(file, width.vector) to read a file. After
making the necessary data manipulation, I want to write the data to a
new file in the same width.vector format. Is there a way to specify
this?


There is no write.fwf function, but you can use sprintf() to convert 
things to strings and writeLines to write those strings.  There's a lot 
of flexibility in the formats allowed; see the man page.


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] How to apply a function to all combinations of the values of 2 or more variables?

2009-04-15 Thread Lane, Jim
Hi, All 

Forgive me if this is a stupid newbie question. I'm having no luck
googling an answer to this, probably because I don't know the right R
terminology to frame my question. I want to know how to run an R
function on each combination of the values of 2 or more variables. In
SAS-speak this is multiple BY variables or CLASS variables. 

In R I've figured out how to do what I want with one by value. 

by(mf,mf$centre,summary)

Centre is one of the columns in the data frame mf which looks like
this:

names(mf)
[1] centre   complex  appl pool monthalloc_gb

I'd like to analyze, for example, by complex within centre. This has a
manageable number of combinations:

table(mf$centre,mf$complex)
  
   A  B  C  D  E  F  G  H
I  J  K  L
  B 0  0  0  0  0  0  0  0  0
0  0  60574  0
  G44209  0  94613  0156  0   2541  0
748  0  0 215511
  O 0  0  0  0  0  0   3446  0676
0  84400  0  0
  Q 0  0298  0  66277  0  0  0  0
0  0  0  0

In SAS what I'm after is something like:

Proc summary nway;
 class centre complex;
 var alloc_gb;
 output out=s sum=; 
 run;

How do I get something similar in R?

Jim Lane
Capacity Planner
RBC Financial Group
315 Front St W
6th Floor - H14
Toronto, Ontario CANADA
M5V 3A4
416-348-6024

Display of superior knowledge is as great a vulgarity
as display of superior wealth - greater indeed, inasmuch 
as knowledge should tend more definitely than wealth
towards discretion and good manners.

- H. W. Fowler, Modern English Usage


___

This e-mail may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains 
by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or 
otherwise) immediately.  

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce 
pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il 
contient par une personne autre que le (les) destinataire(s) désigné(s) est 
interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser 
immédiatement, par retour de courrier électronique ou par un autre moyen.

[[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] Fedora 10 KDE plasma font rendering issue

2009-04-15 Thread Stefan Grosse
On Tue, 31 Mar 2009 13:02:23 -0700 (PDT) dfermin dfer...@umich.edu
wrote:

D Has anyone else got this problem? If so do you have a work around or
D a solution?
D 
D I'm using R version 2.8.1 installed from the Fedora 10 repositories
D if that helps.

I have Fedora 10 and R 2.8.1 as well and have no problems. On KDE I see
the text in the histogram plot. 

R has been updated quite some times recently. Have you ensured you have
the latest package installed via yum?

Stefan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Kruskal's MDS results

2009-04-15 Thread Dieter Vanderelst

Hi Michael,

Thanks for the reply.

I understand that the stress is a measure of how good the algorithm managed to represent the ordinal distances between items. And I also see why it's dependent on the number of dimensions. 


I was hoping someone could tell me exactly what the formula for the percentual 
stress is. To me it's not clear how this metric is calculated.

Regards,
Dieter


Michael Denslow wrote:

Hi Dieter,

I'll take a shot at this. As I understand it, the stress is telling
you how the ordination distances compare with original
dissimilarities that you calculated.

It is a measure how well your ordination has done in representing the
relationship of your sites. Note that the stress will differ
depending on how many dimensions are used. I believe the default is k
= 2 in isoMDS.

Hope this helps, Michael



Dear List,

I'm trying to interpret the results of the Kruskal's Non-metric
Multidimensional Scaling algorithm (isoMDS, MASS package).

The 'goodness of fit' is reported as The final stress achieved (in
percent).

What does this mean exactly? I've tried to google for an answer but
I've not come up with a definitive answer.

Regards, Dieter


-- Dieter Vanderelst PhD Student

Active Perception Lab University of Antwerp 
http://batbits.webnode.com/


Postal Address: Prinsstraat 13 B-2000 Antwerp Belgium


Michael Denslow

Graduate Student I.W. Carpenter Jr. Herbarium [BOON] Department of
Biology Appalachian State University Boone, North Carolina U.S.A.

-- AND --

Communications Manager Southeast Regional Network of Expertise and
Collections sernec.org





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 apply a function to all combinations of the values of 2 or more variables?

2009-04-15 Thread baptiste auguie

I think you want to have a look at the plyr or doBy packages.

It would be easier to give a precise answer with a minimal example.

HTH,

baptiste

On 15 Apr 2009, at 18:03, Lane, Jim wrote:


Hi, All

Forgive me if this is a stupid newbie question. I'm having no luck
googling an answer to this, probably because I don't know the right R
terminology to frame my question. I want to know how to run an R
function on each combination of the values of 2 or more variables. In
SAS-speak this is multiple BY variables or CLASS variables.

In R I've figured out how to do what I want with one by value.

by(mf,mf$centre,summary)

Centre is one of the columns in the data frame mf which looks like
this:

names(mf)
[1] centre   complex  appl pool monthalloc_gb

I'd like to analyze, for example, by complex within centre. This has a
manageable number of combinations:

table(mf$centre,mf$complex)

  A  B  C  D  E  F  G  H
I  J  K  L
 B 0  0  0  0  0  0  0  0  0
0  0  60574  0
 G44209  0  94613  0156  0   2541  0
748  0  0 215511
 O 0  0  0  0  0  0   3446  0676
0  84400  0  0
 Q 0  0298  0  66277  0  0  0  0
0  0  0  0

In SAS what I'm after is something like:

Proc summary nway;
class centre complex;
var alloc_gb;
output out=s sum=;
run;

How do I get something similar in R?

Jim Lane
Capacity Planner
RBC Financial Group
315 Front St W
6th Floor - H14
Toronto, Ontario CANADA
M5V 3A4
416-348-6024

Display of superior knowledge is as great a vulgarity
as display of superior wealth - greater indeed, inasmuch
as knowledge should tend more definitely than wealth
towards discretion and good manners.

- H. W. Fowler, Modern English Usage


___

This e-mail may be privileged and/or confidential, and the sender  
does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information  
it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e- 
mail or otherwise) immediately.


Ce courrier électronique est confidentiel et protégé. L'expéditeur  
ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des  
renseignements qu'il contient par une personne autre que le (les)  
destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en  
aviser immédiatement, par retour de courrier électronique ou par un  
autre moyen.


[[alternative HTML version deleted]]

ATT1.txt


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 apply a function to all combinations of the values of 2 or more variables?

2009-04-15 Thread Mike Lawrence
Check out plyr:

http://had.co.nz/plyr/

On Wed, Apr 15, 2009 at 2:03 PM, Lane, Jim jim.l...@rbc.com wrote:
 Hi, All

 Forgive me if this is a stupid newbie question. I'm having no luck
 googling an answer to this, probably because I don't know the right R
 terminology to frame my question. I want to know how to run an R
 function on each combination of the values of 2 or more variables. In
 SAS-speak this is multiple BY variables or CLASS variables.

 In R I've figured out how to do what I want with one by value.

 by(mf,mf$centre,summary)

 Centre is one of the columns in the data frame mf which looks like
 this:

 names(mf)
 [1] centre   complex  appl     pool     month    alloc_gb

 I'd like to analyze, for example, by complex within centre. This has a
 manageable number of combinations:

 table(mf$centre,mf$complex)

                   A      B      C      D      E      F      G      H
 I      J      K      L
  B         0      0      0      0      0      0      0      0      0
 0      0  60574      0
  G        44    209      0  94613      0    156      0   2541      0
 748      0      0 215511
  O         0      0      0      0      0      0   3446      0    676
 0  84400      0      0
  Q         0      0    298      0  66277      0      0      0      0
 0      0      0      0

 In SAS what I'm after is something like:

 Proc summary nway;
  class centre complex;
  var alloc_gb;
  output out=s sum=;
  run;

 How do I get something similar in R?

 Jim Lane
 Capacity Planner
 RBC Financial Group
 315 Front St W
 6th Floor - H14
 Toronto, Ontario CANADA
 M5V 3A4
 416-348-6024

 Display of superior knowledge is as great a vulgarity
 as display of superior wealth - greater indeed, inasmuch
 as knowledge should tend more definitely than wealth
 towards discretion and good manners.

 - H. W. Fowler, Modern English Usage


 ___

 This e-mail may be privileged and/or confidential, and the sender does not 
 waive any related rights and obligations.
 Any distribution, use or copying of this e-mail or the information it 
 contains by other than an intended recipient is unauthorized.
 If you received this e-mail in error, please advise me (by return e-mail or 
 otherwise) immediately.

 Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce 
 pas aux droits et obligations qui s'y rapportent.
 Toute diffusion, utilisation ou copie de ce message ou des renseignements 
 qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) 
 est interdite.
 Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser 
 immédiatement, par retour de courrier électronique ou par un autre moyen.

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





-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Intersection of two sets of intervals

2009-04-15 Thread Thomas Meyer
That does it perfectly -- and it's pretty much the same technique as 
used in the intervals pkg.


-tom

On 4/15/2009 12:43 PM, jim holtman wrote:

Here is one way to find the overlaps:


l1 - rbind(c(1,3), c(5,10), c(13,24))
l2 - rbind(c(2,4), c(7,14), c(20,30))
l1

 [,1] [,2]
[1,]13
[2,]5   10
[3,]   13   24

l2

 [,1] [,2]
[1,]24
[2,]7   14
[3,]   20   30

# create matrix for overlaps
start - cbind(c(l1[,1], l2[,1]), 1)
end - cbind(c(l1[,2], l2[, 2]), -1)
over - rbind(start, end)
# order
over - over[order(over[,1]),]
# get overlap count
over - cbind(over, overlap=cumsum(over[,2]))
# create the overlap matrix
inter - cbind(start=over[(over[,2] == 1)  (over[,3] == 2), 1],

+end=over[(over[,2] == -1)  (over[, 3] == 1), 1])

inter

 start end
[1,] 2   3
[2,] 7  10
[3,]13  14
[4,]20  24


On Wed, Apr 15, 2009 at 12:06 PM, Thomas Meyer t...@cornell.edu wrote:

Stavros, you are quite correct -- I discovered that the hard way a little
while ago when testing my two-line solution. Use of pmin/pmax don't handle,
for instance, cases where more than one interval in one set is wholly
contained by an interval in the other. (I have a mis-posted msg awaiting
moderator approval in R-help with a concrete example.)

Your tip to check out the intervals pkg looks promising. FYI, there the
general intersection is computed as the complement of the union of the
complements, i.e. A*B = (A'+B')' , aka DeMorgan.

Thanks for the help,

-tom

On 4/15/2009 11:27 AM, Stavros Macrakis wrote:

I can see how pmax/pmin would easily allow the intersection of
corresponding elements of two sequences of intervals, but I don't see
how they help in intersecting two *sets* of intervals, which was the
original problem statement.

   -s



On Wed, Apr 15, 2009 at 9:14 AM, ONKELINX, Thierry
thierry.onkel...@inbo.be wrote:

Not of the self but still not complicated:

list1 - data.frame(open=c(1,5), close=c(2,10))
list2 - data.frame(open=c(1.5,3), close=c(2.5,10))

Intersec - data.frame(Open = pmax(list1$open, list2$open), Close =
pmin(list1$close, list2$close))
Intersec[Intersec$Open  Intersec$Close, ] - NA
Intersec

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Thomas Meyer
Verzonden: woensdag 15 april 2009 14:59
Aan: r-help@r-project.org
Onderwerp: [R] Intersection of two sets of intervals

Hi,

Algorithm question: I have two sets of intervals, where an interval is

an ordered pair [a,b] of two numbers. Is there an efficient way in R to
generate the intersection of two lists of same?

For concreteness: I'm representing a set of intervals with a data.frame:

  list1 = as.data.frame(list(open=c(1,5), close=c(2,10)))
  list1
 open close
11 2
2510

  list2 = as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))
  list2
 open close
1  1.5   2.5
2  3.0  10.0

How do I get the intersection which would be something like:
 open close
1  1.5   2.0
2  5.0  10.0

I wonder if there's some ready-built functionality that might help me
out. I'm new to R and am still learning to vectorize my code and my
thinking. Or maybe there's a package for interval arithmetic that I can
just pull off the shelf.

Thanks,

-tom

--
Thomas Meyer

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver
weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet
bevestigd is
door een geldig ondertekend document. The views expressed in  this
message
and any annex are purely those of the writer and may not be regarded as
stating
an official position of INBO, as long as the message is not confirmed by
a duly
signed document.

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

  1   2   >