[R] How to find out the trend during a time period?

2010-10-28 Thread Lao Meng
Hi all:
I have a dataset which contains two variables: Y and time
y-c(228,189,232,198,252,315)
time-2003:2008

How can I find out the trend(increase/decrease) of y along the time period?

If I use:
lm(y~time)

The lm command treats time as natural number,but not date.
So maybe lm isn't appropriate.

Then,which function could be used?

Thanks a lot for your help.

My best

[[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] times

2010-10-28 Thread thoeb

Hi! I have an input table with a column Dates in the format
month/day/year (eg. 5/11/1999 and a column Times in the format
hours/minutes (eg. 15:20). In R I need to convert them into chron
objects to extract colums only containing months, days, minutes, ..

For the dates it is no problem if I write:
dmy.lwc-chron(dates=lwc.file[,1],format=(dates=m/d/y))

But it does not work the same way for the times if I write:
hm.lwc-chron(times=lwc.file[,2],format=(times=h:m))

Error-Message: Error in convert.times(times., fmt) : format h:m may be
incorrect
In addition: Warning message:
In is.na(out$s) : is.na() applied to non-(list or vector) of type 'NULL'

Why should the format h:m not be correct?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/times-tp3016621p3016621.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] Creating truly global variable within function within namespace

2010-10-28 Thread Murray Stokely
I am trying to create a function with a package with a NAMESPACE that
will save() some variables, distribute an Rdata file to another
computer, where it will be load()ed.  The problem is that this load()
tries to load the namespace of the package on the original computer
that created the .Rdata file, but this package need not be loaded on
the new computer.

This example function is in a package in a namespace :

create.global.function - function(x, FUN, ...) {
  environment(FUN) - .GlobalEnv
  assign(.GLOBAL.FUN, function(x) { FUN(x, ...) }, env=.GlobalEnv)
  environment(.GLOBAL.FUN) - .GlobalEnv
  save(list = ls(envir = .GlobalEnv, all.names = TRUE),
   file = /tmp/.Rdata,
   envir = .GlobalEnv)
}

And then if I quit my session and then try to load(/tmp/.Rdata)
without loading the package, it will try to loadNamespace from the
.Rdata file and then fail.

Is it possible to fully strip the namespace out of the .GLOBAL.FUN
before I save() it such that it can be loaded into other R instances
without trying to load the namespace?

Thanks for any pointers ..

 - Murray

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


Re: [R] add diagonal line

2010-10-28 Thread Gavin Simpson
On Wed, 2010-10-27 at 13:17 -0200, Marcelo Lima wrote:
 Hi,
 
 I would like to add a line on the diagonal of a covariance matrix, is there
 a quick way to do it besides abline?
 
 Thanks!

What's wrong with abline()? It does exactly what you want.

By the way,  reproducible example such as requested by David would
something like:

cmat - matrix(rnorm(100), ncol = 10)
diag(cmat) - 1
contour(1:10, 1:10, cmat)
abline(11, -1, col = red, lwd = 2)
box()

I.e. some code with example data that shows us what you are trying to
do. It is not always possible to grep the meaning from a textual
description sufficiently well to be able to move from there to code.
This is discussed in the posting guide.

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 find out the trend during a time period?

2010-10-28 Thread Uwe Ligges



On 28.10.2010 06:50, Lao Meng wrote:

Hi all:
I have a dataset which contains two variables: Y and time
y-c(228,189,232,198,252,315)
time-2003:2008

How can I find out the trend(increase/decrease) of y along the time period?

If I use:
lm(y~time)

The lm command treats time as natural number,but not date.


What is date? WHere is the reproducible example?

Uwe Ligges




So maybe lm isn't appropriate.

Then,which function could be used?

Thanks a lot for your help.

My best

[[alternative HTML version deleted]]

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


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


[R] overloading the generic primitive functions + and [

2010-10-28 Thread Mark Heckmann

How can I add a new method to the generic function [ or +

I want to create a S3 and S4 class that will use the [ and + method in a 
different way.
How can I overload the generic primitive [ or + so the method dispatch will 
work correctly for my class?

I saw an example of this in the ggplot2 package where different objects are 
joined using the + primitive.
Still, I could not figure out how to do that. 

Can someone give a small code example to show how that works?

TIA
Mark

–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstraße 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com





[[alternative HTML version deleted]]

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


[R] Tukeys after(g)lmer

2010-10-28 Thread Henrik Thurfjell
Hello, I have a model I made with a binomially distributed response, 2 vectors 
and two factors with 5 and 12 levels respectively, and a random effect 
(intercept). What I am interested in is doing a post-hoc test to tell which 
levels of the factors differ from each other.

crfk-lmer((Ro~1+mhr+tra+h+m+(1|PubName)),
family=binomial,data=t1)

Ro is binomial

mhr is a vector

tra is a vector

h is a factor

m is a factor

PubName is a factor(obviously)



I have found this;

https://stat.ethz.ch/pipermail/r-help/attachments/20081223/f3dd4d21/attachment.pl

These work:
glht(mod1, linfct=mcp(category=Tukey)
glht(mod1, linfct=mcp(comp=Tukey)

And figured out as much as that the problem is my binomial response.

Now I am trying to weigh my alternatives, and find the best way to present the 
data.

As far as I have read, it seems post-hoc tests are not implemented (yet?), 
maybe due to that they are murky at best in theese circumstances at least 
according to what I could read of the net.

An alternative would be to re fit the model with other contrasts (shifting the 
base in the pre specified contrasts would do the trick, or specifying not 
orthogonal tukey contrasts going from high to low estimates) The third 
alternative would be to just fit some other orthogonal contrasts structure, but 
that would not make all the comparisons I am interested in.

A third option is to do a stepwise deletion and combine the closest levels and 
test the models in a likelihood ratio test (models fit with ML since the fixed 
effects change) and see which could be combined.

Are there better alternatives?

/Henrik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] overloading the generic primitive functions + and [

2010-10-28 Thread Barry Rowlingson
On Thu, Oct 28, 2010 at 9:31 AM, Mark Heckmann mark.heckm...@gmx.de wrote:

 How can I add a new method to the generic function [ or +

 I want to create a S3 and S4 class that will use the [ and + method in a 
 different way.
 How can I overload the generic primitive [ or + so the method dispatch 
 will work correctly for my class?

 I saw an example of this in the ggplot2 package where different objects are 
 joined using the + primitive.
 Still, I could not figure out how to do that.

 Can someone give a small code example to show how that works?

 With S3 method stuff, to override + its as easy as writing Ops.{class}:

  a=hello
  b=world
  a+b
 Error in a + b : non-numeric argument to binary operator
  class(a)=ss
  class(b)=ss
  Ops.ss=function(e1,e2){paste(e1,e2)}
  a+b
 [1] hello world

 better make sure I haven't broken anything:

  c=1
  d=2
  c+d
 [1] 3   *phew*

The Ops function should really have a handler for all possible
operators (*, /, - etc) or fail with an error - see Ops.Date for
example.

With S4 classes... umm.. signatures... setMethod... setGeneric...
errr. something... representations... setClass this that... yeah.
Something like that.

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] updating a local package

2010-10-28 Thread Robert Kinley
Hi folks

I have inherited a package which was created before release 2.10 and I 
need to have it working in release 2.12

There is a folder containing the Man, Data and R subfolders, and the 
description 
file, and there is also the corresponding zip file.

I can install the package from the zip file, but when I try to load it  I 
get the message :-
Error: package   was built before R 2.10.0: please re-install it

If I try to rebuild the zip file using 
C:\Program Files\R\R-2.12.0\bin\R.exe CMD build my.library.folder  

I get pages and pages of warnings and error messages, many of which seem 
to  refer
to the Man folder.

Having never built a formal package before, I'm a bit  stuck for what to 
do next ...

Presumably the expected structure of the folders has changed but the 
documentation
on packages looks scary - can anyone suggest the best way forward - even 
if
its only RTFM !
 
thanks  Bob Kinley 


 
 

[[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] replace text at certain positions in a file

2010-10-28 Thread RINNER Heinrich
Hello,

I am working with R version 2.10.1 under windows.
In a text file, I need to replace all characters at certain column positions 
with blanks.
For example, say the file contains two lines and looks like this:

ab34cd78e
fg3 hi78j

I'd like to replace everything at positions 3-4 and 7-8 with blanks, so the 
output should be:

ab  cd  e
fg  hi  j

[I'm not sure if this is really an R question(?), solutions outside of R - 
maybe via shell() or so - are welcome!]

Thanks,
Heinrich.

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

2010-10-28 Thread Uwe Ligges
Essential infrastructure work has been done in the meantime, both ion 
the documentation system and on the location of binaries.
That means you really need to reinstall the package and hence you need 
to start with a source package.
Details for installing from source are given in the manual R 
Installation and Administartion.


Uwe Ligges


On 28.10.2010 11:23, Robert Kinley wrote:

Hi folks

I have inherited a package which was created before release 2.10 and I
need to have it working in release 2.12

There is a folder containing the Man, Data and R subfolders, and the
description
file, and there is also the corresponding zip file.

I can install the package from the zip file, but when I try to load it  I
get the message :-
 Error: package   was built before R 2.10.0: please re-install it

If I try to rebuild the zip file using
 C:\Program Files\R\R-2.12.0\bin\R.exe CMD build my.library.folder

I get pages and pages of warnings and error messages, many of which seem
to  refer
to the Man folder.

Having never built a formal package before, I'm a bit  stuck for what to
do next ...

Presumably the expected structure of the folders has changed but the
documentation
on packages looks scary - can anyone suggest the best way forward - even
if
its only RTFM !

 thanks  Bob Kinley





[[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] replace text at certain positions in a file

2010-10-28 Thread Uwe Ligges

I'd just import the positions I like using

read.fwf()

or otherwise you can replace strings at certain positions, see ?substr

Uwe Ligges


On 28.10.2010 11:26, RINNER Heinrich wrote:

Hello,

I am working with R version 2.10.1 under windows.
In a text file, I need to replace all characters at certain column positions 
with blanks.
For example, say the file contains two lines and looks like this:

ab34cd78e
fg3 hi78j

I'd like to replace everything at positions 3-4 and 7-8 with blanks, so the 
output should be:

ab  cd  e
fg  hi  j

[I'm not sure if this is really an R question(?), solutions outside of R - 
maybe via shell() or so - are welcome!]

Thanks,
Heinrich.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Changing origin of line in radial plot

2010-10-28 Thread Jim Lemon

On 10/28/2010 07:14 AM, Gonzalo Garcia-Perate wrote:

I am creating radial plots to visualise popularity of a series of
topics, I was wondering if someone has come across a radial plot in
which the lines originate from the edge of the plot instead of the
centre, does anyone know how can this be achieved in R? Are there any
good reasons not to do it?


Hi Gonzalo,
This is an interesting suggestion. I suppose it could be done with an 
invert routine that swapped the center coordinates for those of the 
outer ring of the annular grid for each radial line. I think I have seen 
something like this to illustrate some sort of genetic information.


Yep, down about line 139 in my code you could define xposmax and yposmax 
if the new argument invert was TRUE, then


if(invert) {
 xposmax-cos(radial.pos[i,])*maxlength
 yposmax-sin(radial.pos[i,])*maxlength
}
if(match(r,rptype,0)) {
 if(invert)
  segments(xposmax,yposmax,xpos,ypos,
   col=linecol,lty=ltype,lwd=lwidth,...)
 else
  segments(0,0,xpos,ypos,col=linecol,
   lty=ltype,lwd=lwidth,...)

Untested, but it might do what you want.

Jim

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


[R] 0.3 is not 0.3, bug in seq() function?

2010-10-28 Thread Enrico R. Crema
Dear List,

I've been running a numerical simulation and I found this odd error in my code 
where the which command could not identify which rows of a column of data.frame 
were corresponding to the value 0.3. There are 7 unique values in this column 
(0.01,0.05,0.1,0.2,0.3,0.4,0.5), and this does not work only for 0.3. So I 
looked at the column and manually tried to use the which() command, and the 
results were all FALSE despite I could see those number. So I recreated my 
sequence of number and tested:

seq(0.1,0.5,0.1)[3]==0.3

which gave me FALSE!!! All the other numbers (0.1,0.2,0.4,0.5) give me TRUE, 
but 0.3 was not working. So I did:

seq(0.1,0.5,0.1)[3]-0.3

which gave me 5.551115e-17. If you run a similar sequence like:

seq(0.2,0.6,0.1)[2]==0.3

this will still give me FALSE. No, for my own purpose, I fixed the problem in 
this way:

zerothree=seq(0.1,0.5,0.1)[3]
which(data[,1]==zerothree)

but I guess this bug is a bit of problem...Apologies if it is the wrong place 
to post this bug, and apologies also if this was a known issue. My version of R 
is :

platform   x86_64-pc-linux-gnu  
arch   x86_64   
os linux-gnu
system x86_64, linux-gnu
status  
major  2
minor  10.1 
year   2009 
month  12   
day14   
svn rev50720
language   R
version.string R version 2.10.1 (2009-12-14)


Many Thanks,

Enrico

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

2010-10-28 Thread Robert Kinley
your advice to useR CMD INSTALL source.library did the trick

 and I now understand  packages a little better.

many thanks
 
 Bob Kinley 



 
 




Uwe Ligges lig...@statistik.tu-dortmund.de 
28/10/2010 10:30

To
Robert Kinley kinley_rob...@lilly.com
cc
r-help@r-project.org
Subject
Re: [R] updating a local package






Essential infrastructure work has been done in the meantime, both ion 
the documentation system and on the location of binaries.
That means you really need to reinstall the package and hence you need 
to start with a source package.
Details for installing from source are given in the manual R 
Installation and Administartion.

Uwe Ligges


On 28.10.2010 11:23, Robert Kinley wrote:
 Hi folks

 I have inherited a package which was created before release 2.10 and I
 need to have it working in release 2.12

 There is a folder containing the Man, Data and R subfolders, and the
 description
 file, and there is also the corresponding zip file.

 I can install the package from the zip file, but when I try to load it I
 get the message :-
  Error: package   was built before R 2.10.0: please re-install 
it

 If I try to rebuild the zip file using
  C:\Program Files\R\R-2.12.0\bin\R.exe CMD build 
my.library.folder

 I get pages and pages of warnings and error messages, many of which seem
 to  refer
 to the Man folder.

 Having never built a formal package before, I'm a bit  stuck for what to
 do next ...

 Presumably the expected structure of the folders has changed but the
 documentation
 on packages looks scary - can anyone suggest the best way forward - even
 if
 its only RTFM !

  thanks  Bob Kinley





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


[[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] times

2010-10-28 Thread Thomas Levine
I couldn't figure that out, but you can work around it by adding the seconds

chron(dates=lwc.file[,1],times=paste(lwc.file[,2],':00',sep=''))

Tom

2010/10/28 thoeb t.hoebin...@gmail.com:

 Hi! I have an input table with a column Dates in the format
 month/day/year (eg. 5/11/1999 and a column Times in the format
 hours/minutes (eg. 15:20). In R I need to convert them into chron
 objects to extract colums only containing months, days, minutes, ..

 For the dates it is no problem if I write:
 dmy.lwc-chron(dates=lwc.file[,1],format=(dates=m/d/y))

 But it does not work the same way for the times if I write:
 hm.lwc-chron(times=lwc.file[,2],format=(times=h:m))

 Error-Message: Error in convert.times(times., fmt) : format h:m may be
 incorrect
 In addition: Warning message:
 In is.na(out$s) : is.na() applied to non-(list or vector) of type 'NULL'

 Why should the format h:m not be correct?
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/times-tp3016621p3016621.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] 0.3 is not 0.3, bug in seq() function?

2010-10-28 Thread Rubén Roa
Enrico,

The same happens with other numbers/sequences.
seq(0.1,0.9,0.1)[7]==0.7
[1] FALSE
seq(0.1,1.3,0.1)[12]==1.2
[1] FALSE

Rounding seems to fix it,

round(seq(0.1,0.5,0.1),1)[3]==0.3
round(seq(0.1,0.9,0.1),1)[7]==0.7
round(seq(0.1,1.3,0.1),1)[12]==1.2

They all return TRUE.


 

Dr. Rubén Roa-Ureta
AZTI - Tecnalia / Marine Research Unit
Txatxarramendi Ugartea z/g
48395 Sukarrieta (Bizkaia)
SPAIN



 -Mensaje original-
 De: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] En nombre de Enrico R. Crema
 Enviado el: jueves, 28 de octubre de 2010 12:24
 Para: r-help@r-project.org
 Asunto: [R] 0.3 is not 0.3, bug in seq() function?
 
 Dear List,
 
 I've been running a numerical simulation and I found this odd 
 error in my code where the which command could not identify 
 which rows of a column of data.frame were corresponding to 
 the value 0.3. There are 7 unique values in this column 
 (0.01,0.05,0.1,0.2,0.3,0.4,0.5), and this does not work only 
 for 0.3. So I looked at the column and manually tried to use 
 the which() command, and the results were all FALSE despite I 
 could see those number. So I recreated my sequence of number 
 and tested:
 
 seq(0.1,0.5,0.1)[3]==0.3
 
 which gave me FALSE!!! All the other numbers 
 (0.1,0.2,0.4,0.5) give me TRUE, but 0.3 was not working. So I did:
 
 seq(0.1,0.5,0.1)[3]-0.3
 
 which gave me 5.551115e-17. If you run a similar sequence like:
 
 seq(0.2,0.6,0.1)[2]==0.3
 
 this will still give me FALSE. No, for my own purpose, I 
 fixed the problem in this way:
 
 zerothree=seq(0.1,0.5,0.1)[3]
 which(data[,1]==zerothree)
 
 but I guess this bug is a bit of problem...Apologies if it is 
 the wrong place to post this bug, and apologies also if this 
 was a known issue. My version of R is :
 
 platform   x86_64-pc-linux-gnu  
 arch   x86_64   
 os linux-gnu
 system x86_64, linux-gnu
 status  
 major  2
 minor  10.1 
 year   2009 
 month  12   
 day14   
 svn rev50720
 language   R
 version.string R version 2.10.1 (2009-12-14)
 
 
 Many Thanks,
 
 Enrico
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] 0.3 is not 0.3, bug in seq() function?

2010-10-28 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 28/10/10 12:23, Enrico R. Crema wrote:
 Dear List,
 
 I've been running a numerical simulation and I found this odd error in my 
 code where the which command could not identify which rows of a column of 
 data.frame were corresponding to the value 0.3. There are 7 unique values in 
 this column (0.01,0.05,0.1,0.2,0.3,0.4,0.5), and this does not work only for 
 0.3. So I looked at the column and manually tried to use the which() command, 
 and the results were all FALSE despite I could see those number. So I 
 recreated my sequence of number and tested:
 
 seq(0.1,0.5,0.1)[3]==0.3
 
 which gave me FALSE!!! All the other numbers (0.1,0.2,0.4,0.5) give me TRUE, 
 but 0.3 was not working. So I did:
 
 seq(0.1,0.5,0.1)[3]-0.3
 
 which gave me 5.551115e-17. If you run a similar sequence like:
 
 seq(0.2,0.6,0.1)[2]==0.3
 
 this will still give me FALSE. No, for my own purpose, I fixed the problem in 
 this way:
 
 zerothree=seq(0.1,0.5,0.1)[3]
 which(data[,1]==zerothree)
 
 but I guess this bug is a bit of problem...Apologies if it is the wrong place 
 to post this bug, and apologies also if this was a known issue. My version of 
 R is :
 
 platform   x86_64-pc-linux-gnu  
 arch   x86_64   
 os linux-gnu
 system x86_64, linux-gnu
 status  
 major  2
 minor  10.1 
 year   2009 
 month  12   
 day14   
 svn rev50720
 language   R
 version.string R version 2.10.1 (2009-12-14)

This is not a bug, but based on the internal representation of numbers
in the binary format. Numbers like 0.3 can not be represented as exactly
0.3, wherefore errors accumulate in a sequence.

I can't provide you a link for more details, but the topic comes up
every now and then in this mailing list.

Cheers,

Rainer

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


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:+33 - (0)9 53 10 27 44
Cell:   +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzJVOEACgkQoYgNqgF2egpVXACeNO9GyRh9XKLg1g4EhcFs4Qa5
WXgAmgOdNB/xgmRS4UsMaEtunxS6NB/u
=azme
-END PGP SIGNATURE-

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

2010-10-28 Thread Uwe Ligges



On 28.10.2010 12:26, Robert Kinley wrote:

your advice to useR CMD INSTALL source.library


It's a *package*, not a library.

Uwe


did the trick


  and I now understand  packages a little better.

 many thanks

  Bob Kinley









Uwe Liggeslig...@statistik.tu-dortmund.de
28/10/2010 10:30

To
Robert Kinleykinley_rob...@lilly.com
cc
r-help@r-project.org
Subject
Re: [R] updating a local package






Essential infrastructure work has been done in the meantime, both ion
the documentation system and on the location of binaries.
That means you really need to reinstall the package and hence you need
to start with a source package.
Details for installing from source are given in the manual R
Installation and Administartion.

Uwe Ligges


On 28.10.2010 11:23, Robert Kinley wrote:

Hi folks

I have inherited a package which was created before release 2.10 and I
need to have it working in release 2.12

There is a folder containing the Man, Data and R subfolders, and the
description
file, and there is also the corresponding zip file.

I can install the package from the zip file, but when I try to load it I
get the message :-
  Error: package   was built before R 2.10.0: please re-install

it


If I try to rebuild the zip file using
  C:\Program Files\R\R-2.12.0\bin\R.exe CMD build

my.library.folder


I get pages and pages of warnings and error messages, many of which seem
to  refer
to the Man folder.

Having never built a formal package before, I'm a bit  stuck for what to
do next ...

Presumably the expected structure of the folders has changed but the
documentation
on packages looks scary - can anyone suggest the best way forward - even
if
its only RTFM !

  thanks  Bob Kinley





[[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] 0.3 is not 0.3, bug in seq() function?

2010-10-28 Thread Enrico R. Crema
Well...thanks to everybody for suggestions and reading...I guess I have to 
study more!

Enrico
On 28 Oct 2010, at 11:48, Rainer M Krug wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 28/10/10 12:23, Enrico R. Crema wrote:
 Dear List,
 
 I've been running a numerical simulation and I found this odd error in my 
 code where the which command could not identify which rows of a column of 
 data.frame were corresponding to the value 0.3. There are 7 unique values in 
 this column (0.01,0.05,0.1,0.2,0.3,0.4,0.5), and this does not work only for 
 0.3. So I looked at the column and manually tried to use the which() 
 command, and the results were all FALSE despite I could see those number. So 
 I recreated my sequence of number and tested:
 
 seq(0.1,0.5,0.1)[3]==0.3
 
 which gave me FALSE!!! All the other numbers (0.1,0.2,0.4,0.5) give me TRUE, 
 but 0.3 was not working. So I did:
 
 seq(0.1,0.5,0.1)[3]-0.3
 
 which gave me 5.551115e-17. If you run a similar sequence like:
 
 seq(0.2,0.6,0.1)[2]==0.3
 
 this will still give me FALSE. No, for my own purpose, I fixed the problem 
 in this way:
 
 zerothree=seq(0.1,0.5,0.1)[3]
 which(data[,1]==zerothree)
 
 but I guess this bug is a bit of problem...Apologies if it is the wrong 
 place to post this bug, and apologies also if this was a known issue. My 
 version of R is :
 
 platform   x86_64-pc-linux-gnu  
 arch   x86_64   
 os linux-gnu
 system x86_64, linux-gnu
 status  
 major  2
 minor  10.1 
 year   2009 
 month  12   
 day14   
 svn rev50720
 language   R
 version.string R version 2.10.1 (2009-12-14)
 
 This is not a bug, but based on the internal representation of numbers
 in the binary format. Numbers like 0.3 can not be represented as exactly
 0.3, wherefore errors accumulate in a sequence.
 
 I can't provide you a link for more details, but the topic comes up
 every now and then in this mailing list.
 
 Cheers,
 
 Rainer
 
 
 
 Many Thanks,
 
 Enrico
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 - -- 
 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
 Biology, UCT), Dipl. Phys. (Germany)
 
 Centre of Excellence for Invasion Biology
 Natural Sciences Building
 Office Suite 2039
 Stellenbosch University
 Main Campus, Merriman Avenue
 Stellenbosch
 South Africa
 
 Tel:+33 - (0)9 53 10 27 44
 Cell:   +27 - (0)8 39 47 90 42
 Fax (SA):   +27 - (0)8 65 16 27 82
 Fax (D) :   +49 - (0)3 21 21 25 22 44
 Fax (FR):   +33 - (0)9 58 10 27 44
 email:  rai...@krugs.de
 
 Skype:  RMkrug
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iEYEARECAAYFAkzJVOEACgkQoYgNqgF2egpVXACeNO9GyRh9XKLg1g4EhcFs4Qa5
 WXgAmgOdNB/xgmRS4UsMaEtunxS6NB/u
 =azme
 -END PGP SIGNATURE-

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

2010-10-28 Thread Robert Kinley
I stand corrected   :0) 
 
  Robert Kinley 
 

 
 




Uwe Ligges lig...@statistik.tu-dortmund.de 
28/10/2010 11:54

To
Robert Kinley kinley_rob...@lilly.com
cc
r-help@r-project.org
Subject
Re: [R] updating a local package








On 28.10.2010 12:26, Robert Kinley wrote:
 your advice to useR CMD INSTALL source.library

It's a *package*, not a library.

Uwe


 did the trick

   and I now understand  packages a little better.

  many thanks

   Bob Kinley









 Uwe Liggeslig...@statistik.tu-dortmund.de
 28/10/2010 10:30

 To
 Robert Kinleykinley_rob...@lilly.com
 cc
 r-help@r-project.org
 Subject
 Re: [R] updating a local package






 Essential infrastructure work has been done in the meantime, both ion
 the documentation system and on the location of binaries.
 That means you really need to reinstall the package and hence you need
 to start with a source package.
 Details for installing from source are given in the manual R
 Installation and Administartion.

 Uwe Ligges


 On 28.10.2010 11:23, Robert Kinley wrote:
 Hi folks

 I have inherited a package which was created before release 2.10 and I
 need to have it working in release 2.12

 There is a folder containing the Man, Data and R subfolders, and the
 description
 file, and there is also the corresponding zip file.

 I can install the package from the zip file, but when I try to load it 
I
 get the message :-
   Error: package   was built before R 2.10.0: please re-install
 it

 If I try to rebuild the zip file using
   C:\Program Files\R\R-2.12.0\bin\R.exe CMD build
 my.library.folder

 I get pages and pages of warnings and error messages, many of which 
seem
 to  refer
 to the Man folder.

 Having never built a formal package before, I'm a bit  stuck for what 
to
 do next ...

 Presumably the expected structure of the folders has changed but the
 documentation
 on packages looks scary - can anyone suggest the best way forward - 
even
 if
 its only RTFM !

   thanks  Bob Kinley





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




[[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] overloading the generic primitive functions + and [

2010-10-28 Thread Christofer Bogaso
Dear Barry, this is really interesting. However I could not understand
this line:

Ops.ss=function(e1,e2){paste(e1,e2)}

Where you have told R to behave + function differently when it faces
ss class?
What should be the ideal approach if I what to use * function?

Thanks,

On Thu, Oct 28, 2010 at 2:47 PM, Barry Rowlingson
b.rowling...@lancaster.ac.uk wrote:
 On Thu, Oct 28, 2010 at 9:31 AM, Mark Heckmann mark.heckm...@gmx.de wrote:

 How can I add a new method to the generic function [ or +

 I want to create a S3 and S4 class that will use the [ and + method in a 
 different way.
 How can I overload the generic primitive [ or + so the method dispatch 
 will work correctly for my class?

 I saw an example of this in the ggplot2 package where different objects are 
 joined using the + primitive.
 Still, I could not figure out how to do that.

 Can someone give a small code example to show how that works?

  With S3 method stuff, to override + its as easy as writing Ops.{class}:

   a=hello
   b=world
   a+b
  Error in a + b : non-numeric argument to binary operator
   class(a)=ss
   class(b)=ss
   Ops.ss=function(e1,e2){paste(e1,e2)}
   a+b
  [1] hello world

  better make sure I haven't broken anything:

   c=1
   d=2
   c+d
  [1] 3   *phew*

 The Ops function should really have a handler for all possible
 operators (*, /, - etc) or fail with an error - see Ops.Date for
 example.

 With S4 classes... umm.. signatures... setMethod... setGeneric...
 errr. something... representations... setClass this that... yeah.
 Something like that.

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


Re: [R] Changing origin of line in radial plot

2010-10-28 Thread Gonzalo Garcia-Perate
Jim, thanks for your reply, it works! but the results are not what I
expected. What the code does now is completely reverse the central
chart area, so what was coloured before now is white, see here
http://www.flickr.com/photos/gonzillaaa/

What I was hoping for, was having the same length lines (very short
ones and very long ones) but stemming from the edge of the plot. Any
suggestions?


Thank you,

On 28 October 2010 10:42, Jim Lemon j...@bitwrit.com.au wrote:
 On 10/28/2010 07:14 AM, Gonzalo Garcia-Perate wrote:

 I am creating radial plots to visualise popularity of a series of
 topics, I was wondering if someone has come across a radial plot in
 which the lines originate from the edge of the plot instead of the
 centre, does anyone know how can this be achieved in R? Are there any
 good reasons not to do it?

 Hi Gonzalo,
 This is an interesting suggestion. I suppose it could be done with an
 invert routine that swapped the center coordinates for those of the outer
 ring of the annular grid for each radial line. I think I have seen something
 like this to illustrate some sort of genetic information.

 Yep, down about line 139 in my code you could define xposmax and yposmax if
 the new argument invert was TRUE, then

 if(invert) {
  xposmax-cos(radial.pos[i,])*maxlength
  yposmax-sin(radial.pos[i,])*maxlength
 }
 if(match(r,rptype,0)) {
  if(invert)
  segments(xposmax,yposmax,xpos,ypos,
   col=linecol,lty=ltype,lwd=lwidth,...)
  else
  segments(0,0,xpos,ypos,col=linecol,
   lty=ltype,lwd=lwidth,...)

 Untested, but it might do what you want.

 Jim




-- 
Gonzalo Garcia-Perate
PhD candidate, Bartlett School of Architecture, Building,
Environmental Design  Planning.
University College London. Gower Street, London WC1E 6BT
g.garcia-per...@ucl.ac.uk

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


Re: [R] replace text at certain positions in a file

2010-10-28 Thread Gabor Grothendieck
On Thu, Oct 28, 2010 at 5:26 AM, RINNER Heinrich
heinrich.rin...@tirol.gv.at wrote:
 Hello,

 I am working with R version 2.10.1 under windows.
 In a text file, I need to replace all characters at certain column positions 
 with blanks.
 For example, say the file contains two lines and looks like this:

 ab34cd78e
 fg3 hi78j

 I'd like to replace everything at positions 3-4 and 7-8 with blanks, so the 
 output should be:

 ab  cd  e
 fg  hi  j

 [I'm not sure if this is really an R question(?), solutions outside of R - 
 maybe via shell() or so - are welcome!]


Try this:

 s - c(ab34cd78e, fg3 hi78j)
 sub(^(..)..(..).., \\1  \\2  , s)
[1] ab  cd  e fg  hi  j


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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.


Re: [R] times

2010-10-28 Thread Gabor Grothendieck
On Thu, Oct 28, 2010 at 1:06 AM, thoeb t.hoebin...@gmail.com wrote:

 Hi! I have an input table with a column Dates in the format
 month/day/year (eg. 5/11/1999 and a column Times in the format
 hours/minutes (eg. 15:20). In R I need to convert them into chron
 objects to extract colums only containing months, days, minutes, ..

 For the dates it is no problem if I write:
 dmy.lwc-chron(dates=lwc.file[,1],format=(dates=m/d/y))

 But it does not work the same way for the times if I write:
 hm.lwc-chron(times=lwc.file[,2],format=(times=h:m))

 Error-Message: Error in convert.times(times., fmt) : format h:m may be
 incorrect
 In addition: Warning message:
 In is.na(out$s) : is.na() applied to non-(list or vector) of type 'NULL'

 Why should the format h:m not be correct?

This has been discussed before.  See:

http://r.789695.n4.nabble.com/zoo-read-intraday-data-tp3010256p3010312.html


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] Install Error

2010-10-28 Thread Johannes Graumann
Hi,

I'm running into the error below when doing R CMD INSTALL 
MyPackage.tar.gz. This didn't use to be this way and I am at a loss as to 
where this might be coming from. Any pointers where to look?

Joh

** building package indices ...
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  
: 
  line 1 did not have 8 elements
ERROR: installing package indices failed

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 find out the trend during a time period?

2010-10-28 Thread Gabor Grothendieck
2010/10/28 Uwe Ligges lig...@statistik.tu-dortmund.de:


 On 28.10.2010 06:50, Lao Meng wrote:

 Hi all:
 I have a dataset which contains two variables: Y and time
 y-c(228,189,232,198,252,315)
 time-2003:2008

 How can I find out the trend(increase/decrease) of y along the time
 period?

 If I use:
 lm(y~time)

 The lm command treats time as natural number,but not date.

 What is date? WHere is the reproducible example?

The code the poster displayed is reproducible -- the problem is more
that its not entirely clear what is desired.  If the worry is that
there can be different numbers of days in different years due to leap
years then one could use the number of days between January 1st of
each year and January 1st of the first year like this (where y and
time are from the original post):

 d - as.Date(paste(time, 1, 1, sep = -))
 d - as.numeric(d - d[1])
 d
[1]0  365  731 1096 1461 1826
 lm(y ~ d)

Call:
lm(formula = y ~ d)

Coefficients:
(Intercept)d
  193.52454  0.04615



-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] Clustering

2010-10-28 Thread dpender

I am looking to use R in order to determine the number of extreme events for
a high frequency (20 minutes) dataset of wave heights that spans 25 years
(657,432) data points.

I require the number, spacing and duration of the extreme events as an
output.

I have briefly used the clusters function in evd package.

Can anyone suggest a more appropriate package to use for such a large
dataset?

Thanks,

Doug

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Clustering-tp3017056p3017056.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] Install Error

2010-10-28 Thread Duncan Murdoch

On 28/10/2010 7:54 AM, Johannes Graumann wrote:

Hi,

I'm running into the error below when doing R CMD INSTALL
MyPackage.tar.gz. This didn't use to be this way and I am at a loss as to
where this might be coming from. Any pointers where to look?

Joh

** building package indices ...
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
   line 1 did not have 8 elements
ERROR: installing package indices failed



You may get more informative error information if you do the install 
from within R.  Supposing you've used setwd() to go to the directory 
where your package lives, try


install.packages(MyPackage.tar.gz, repos=NULL, type=source)

If that fails, then traceback() will tell you where the failure happened.

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] 0.3 is not 0.3, bug in seq() function?

2010-10-28 Thread S Ellison


 Enrico R. Crema enryu_cr...@yahoo.it 28/10/2010 12:08:55 
Well...thanks to everybody for suggestions and reading...I guess I
have to study more!
 ... 
 On 28/10/10 12:23, Enrico R. Crema wrote:
  
 I can't provide you a link for more details, 

The canonical link is R FAQ 7.31 in the 'Frequently Asked Questions'
issued as part of the R HTML Help system.

Steve E


***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 0.3 is not 0.3, bug in seq() function?

2010-10-28 Thread Ivan Calandra

Hi,
It is a know issue, reported in the FAQ 7.31.
Ivan

Le 10/28/2010 13:08, Enrico R. Crema a écrit :

Well...thanks to everybody for suggestions and reading...I guess I have to 
study more!

Enrico
On 28 Oct 2010, at 11:48, Rainer M Krug wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 28/10/10 12:23, Enrico R. Crema wrote:

Dear List,

I've been running a numerical simulation and I found this odd error in my code 
where the which command could not identify which rows of a column of data.frame 
were corresponding to the value 0.3. There are 7 unique values in this column 
(0.01,0.05,0.1,0.2,0.3,0.4,0.5), and this does not work only for 0.3. So I 
looked at the column and manually tried to use the which() command, and the 
results were all FALSE despite I could see those number. So I recreated my 
sequence of number and tested:

seq(0.1,0.5,0.1)[3]==0.3

which gave me FALSE!!! All the other numbers (0.1,0.2,0.4,0.5) give me TRUE, 
but 0.3 was not working. So I did:

seq(0.1,0.5,0.1)[3]-0.3

which gave me 5.551115e-17. If you run a similar sequence like:

seq(0.2,0.6,0.1)[2]==0.3

this will still give me FALSE. No, for my own purpose, I fixed the problem in 
this way:

zerothree=seq(0.1,0.5,0.1)[3]
which(data[,1]==zerothree)

but I guess this bug is a bit of problem...Apologies if it is the wrong place 
to post this bug, and apologies also if this was a known issue. My version of R 
is :

platform   x86_64-pc-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  2
minor  10.1
year   2009
month  12
day14
svn rev50720
language   R
version.string R version 2.10.1 (2009-12-14)

This is not a bug, but based on the internal representation of numbers
in the binary format. Numbers like 0.3 can not be represented as exactly
0.3, wherefore errors accumulate in a sequence.

I can't provide you a link for more details, but the topic comes up
every now and then in this mailing list.

Cheers,

Rainer



Many Thanks,

Enrico

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


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation

Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:+33 - (0)9 53 10 27 44
Cell:   +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzJVOEACgkQoYgNqgF2egpVXACeNO9GyRh9XKLg1g4EhcFs4Qa5
WXgAmgOdNB/xgmRS4UsMaEtunxS6NB/u
=azme
-END PGP SIGNATURE-

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



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] Install Error

2010-10-28 Thread Johannes Graumann
Duncan Murdoch wrote:

 On 28/10/2010 7:54 AM, Johannes Graumann wrote:
 Hi,

 I'm running into the error below when doing R CMD INSTALL
 MyPackage.tar.gz. This didn't use to be this way and I am at a loss as
 to where this might be coming from. Any pointers where to look?

 Joh

 ** building package indices ...
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
 na.strings,
 :
line 1 did not have 8 elements
 ERROR: installing package indices failed

 
 You may get more informative error information if you do the install
 from within R.  Supposing you've used setwd() to go to the directory
 where your package lives, try
 
 install.packages(MyPackage.tar.gz, repos=NULL, type=source)
 
 If that fails, then traceback() will tell you where the failure happened.
 
 Duncan Murdoch

Thanks for the pointer, but there doesn't seem to be more information ...

 install.packages(MyPackage.tar.gz, repos=NULL, type=source)
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘MyPackage’ ...
** R
** data
** demo
** exec
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  
: 
  line 1 did not have 8 elements
ERROR: installing package indices failed
* removing ‘/usr/local/lib/R/site-library/MyPackage’
* restoring previous ‘/usr/local/lib/R/site-library/MyPackage’
Warning message:
In install.packages(MyPackage.tar.gz, repos = NULL, type = source) :
  installation of package 'MyPackage.tar.gz' had non-zero exit status
 traceback()
No traceback available

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] scatterplot3d; scaling point symbols to depth of graph

2010-10-28 Thread John Coulthard

Hi

I'm trying to scale the point symbols on a 3d plot so that the ones at the 
front are larger than the ones at the back.  I'm trying to give the image some 
perspective.

Given this code...

library(scatterplot3d)
data=array(c(0,5,9), c(3,3))
scatterplot3d(data, pch=19, cex.symbols=10-data[,2], 
color=c(red,blue,black));
 data


 [,1] [,2] [,3]


[1,]000


[2,]555


[3,]999



which gives a vector for  cex.symbols as
 10-data[,2]

[1] 10  5  1


 I would expect the largest point to be the red one at the origin but 
the image I get has the black symbol at co-ords 9,9,9 as the largest and red at 
0,0,0 the smallest.
  
Then if I do...
 data=array(c(0,9,5), c(3,3))
 data
 [,1] [,2] [,3]
[1,]000
[2,]999
[3,]555
 scatterplot3d(data, pch=19, cex.symbols=10-data[,2], 
 color=c(red,blue,black));
 10-data[,2]
[1] 10  1  5

I'd expect the position and size of the points to be the same but the colour of 
blue and black to be exchanged.  But the size of the points also changes such 
that the red point at 0,0,0 is the medium size and the black at 5,5,5 is the 
smallest. 

So is it possible to get the points described by each row in data to be scaled 
by the values in data[,2]?

Many thanks

John



 sessionInfo()
R version 2.11.1 (2010-05-31) 
i386-redhat-linux-gnu 

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C 
 [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8   
 [7] LC_PAPER=en_US.utf8   LC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C   
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C  

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

other attached packages:
[1] scatterplot3d_0.3-30

loaded via a namespace (and not attached):
[1] tools_2.11.1

  
[[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] Calculate percent occurrence of different values

2010-10-28 Thread Vanessa J

Hello,

I am relatively new to R. I am trying to do the following 
and cannot figure out a relatively fast, clean method of doing it in R. 
Here is a simple sample of what my data set looks like:

ID   TryNum   Dir
1  1 1   1
1  1 2   4
1  1 3   2
1  2 1   4

1  2 2   3
2  1 1   3
2  1 2   1
2  2 1   1

2  2 2   2
2  2 1   4

2  3 2   1
2  3 1   3
3  1 1   1
3  1 2   4
3  1 3   1
3  1 4   3
3  2 1   4

3  2 2   3

I would like to calculate the percent 
occurrence of each possible value of Dir (in this case, there are four: 
1, 2, 3 and 4) for each ID and Num. E.g., so the output would be a table
 with each row as a different value of ID (in this case, 1, 2 and 3), 
and there would be a separate column for each instance of Dir for each 
instance of Num (in this case, for each of the 4 values of Num, there 
would be 4 columns for Dir). In this case, the first entry of this table
 would be .5, since for ID 1, when Num=1, Dir=1 in one out of two cases.
Any help would be greatly appreciated!

Thank you.
  
[[alternative HTML version deleted]]

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


[R] R and Matlab

2010-10-28 Thread Santosh Srinivas
Dear Group,

I am looking for ways to use R and Matlab. Doing the data transformations in
R and using the data in Matlab to analyze with some pre-defined scripts.
Any good ways to transfer the data into matlab in its most recent version?
I tried using R.matlab but the writeMat output is not readable by Matlab.
I just need to output a data.frame and read it as is into matlab where I can
do any needed transformations on the variables.

Thanks,
S

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


Re: [R] Regular time series with irregular start and end dates

2010-10-28 Thread Wesley Roberts
Dear Gabor,

Many thanks for your suggestions, I could not get seq(as.Date(2005-09-13), 
as.Date(2006-10-15), by = 16) to work with ts so have chosen to use the 
zooreg solution you suggested. In the end, all I want to do is graph the values 
with the correct time scale on the x-axis. Later we may think about time series 
analyses.

Once again, many thanks.
Wesley


 Gabor Grothendieck ggrothendi...@gmail.com 27/10/2010 16:38 
On Wed, Oct 27, 2010 at 10:01 AM, Wesley Roberts wrobe...@csir.co.za wrote:
 Dear R users,

 I have a quick question regarding creating an index for a zoo object. I am 
 using R 2.12 on winxp.

 I have read through the R archives searching for information on dates and 
 time series analysis and nothing seems to cover my question.

 I am extracting data from a time series of remote sensing data. The frequency 
 of the data is 16 days which means I cant use ts (ts likes months single days 
 etc) and have thus been trying to replicate the following dates using 
 ISOdatetime.

 09/13/2005 09/29/2005 10/15/2005 10/31/2005 11/16/2005 12/02/2005 12/18/2005

 So far, the only method I have found to be successful is the following

 a-ISOdatetime(2005, 9, c(13,29), 0, 0, 0)
 b-ISOdatetime(2005, 10, c(15,31), 0, 0, 0)
 c-ISOdatetime(2005, 11, c(16), 0, 0, 0)
 d-ISOdatetime(2005, 12, c(2,18), 0, 0, 0)

 e-c(a,b,c,d)
 sort(e)
 [1] 2005-09-13 SAST 2005-09-29 SAST 2005-10-15 SAST 2005-10-31 SAST
 [5] 2005-11-16 SAST 2005-12-02 SAST 2005-12-18 SAST

 This is obviously highly convoluted and is not an appropriate solution.

 I would appreciate some advice as to how I would go about creating an index 
 that starts at date 2005-09-13 and creates the next date 16 days ahead till 
 the finishing date 2006-10-15. Also, given the nature of my time series would 
 I be able to use ts instead of zoo?


Try this:

   seq(as.Date(2005-09-13), as.Date(2006-10-15), by = 16)

or if the reason you want this is that you have 25 values and want to
make a zoo/zooreg series from them starting at the indicate Date then
just do this (were we use 1:25 for the values of the series for
purposes of example):

   zooreg(1:25, as.Date(2005-09-13), deltat = 16)




-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com


-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.

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

2010-10-28 Thread Henrique Dallazuanna
Try this:

prop.table(xtabs(~ paste(ID, Num) + Dir, x), 1)

On Thu, Oct 28, 2010 at 7:06 AM, Vanessa J vanja...@hotmail.com wrote:


 Hello,

 I am relatively new to R. I am trying to do the following
 and cannot figure out a relatively fast, clean method of doing it in R.
 Here is a simple sample of what my data set looks like:

 ID   TryNum   Dir
 1  1 1   1
 1  1 2   4
 1  1 3   2
 1  2 1   4

 1  2 2   3
 2  1 1   3
 2  1 2   1
 2  2 1   1

 2  2 2   2
 2  2 1   4

 2  3 2   1
 2  3 1   3
 3  1 1   1
 3  1 2   4
 3  1 3   1
 3  1 4   3
 3  2 1   4

 3  2 2   3

 I would like to calculate the percent
 occurrence of each possible value of Dir (in this case, there are four:
 1, 2, 3 and 4) for each ID and Num. E.g., so the output would be a table
  with each row as a different value of ID (in this case, 1, 2 and 3),
 and there would be a separate column for each instance of Dir for each
 instance of Num (in this case, for each of the 4 values of Num, there
 would be 4 columns for Dir). In this case, the first entry of this table
  would be .5, since for ID 1, when Num=1, Dir=1 in one out of two cases.
 Any help would be greatly appreciated!

 Thank you.

[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


[R] Please help me about Monte Carlo Permutation

2010-10-28 Thread Chitra

 Dear R experts,
I am sorry for my inability.
I have the following dataset:

  Qtot Itot
1   73  684
2   64  451
3   71  378
4   65  284
5   47  179
6   31  117
7   19   69

Now I need to perform Monte Carlo Pertutation test underlaying the
following condition.


Condition

In order to choose randomly (5000 times) for the Qtot in the interval 0 to
the maximum possible value of

Qtot for each observed value of the independent variable (Itot), Monte
Carlo tests needed to be perform to test the null hypothesis. The
maximum observed value is either the calculated size of the regional pool
(Interpolated value), or the measured size of the actual

pool. Each time correlation coefficient (r) between independent and
dependent variable has to be calculated in order to achieve

the empirical distribution of r for the null hypothesis conditions.

Now please help me how to do?
I have also intalled combinat library in R. But could not perform by
myself.
I will be highly grateful.
Thanks.

--
Chitra Bahadur Baniya (PhD)
Lecturer
Central Department of Botany
Tribhuvan University
Kirtipur
Kathmandu, Nepal

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Please-help-me-about-Monte-Carlo-Permutation-tp3017131p3017131.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] R and Matlab

2010-10-28 Thread Claudia Beleites

I am looking for ways to use R and Matlab. Doing the data transformations in
R and using the data in Matlab to analyze with some pre-defined scripts.
Any good ways to transfer the data into matlab in its most recent version?
I tried using R.matlab but the writeMat output is not readable by Matlab.
It used to work, but I didn't need it for quite a while (a year or so ago, and 
with Matlab either 2007 or 2008a).


I just tried, and neither does it work for me.
You should notify the maintainer of R.matlab and include an example (code and 
data, e.g. with dput).


I noticed that library (R.matlab) does not load the Rcompression package, but 
also after library (Rcompression), the resulting file was not read by Matlab.


I tried loading a saved data.frame in Matlab 2008b on an Win XP computer: it 
doesn't find any variables inside the .mat file (and whos -file ...) doesn't 
show a variable.


The other way round with a stupid little vector it worked.

An R session (with only the 2nd try, after library (Rcompression)) is attached 
below.




I just need to output a data.frame and read it as is into matlab where I can
do any needed transformations on the variables.

If you need to transfer the data right NOW, there's always csv.

Claudia



 library (hyperSpec)
Loading required package: lattice
Package hyperSpec, version 0.95

To get started, try
   vignette (introduction, package = hyperSpec)
   package?hyperSpec
   vignette (package = hyperSpec)

If you use this package please cite it appropriately.
   citation(hyperSpec)
will give you the correct reference.

The project is hosted on http://r-forge.r-project.org/projects/hyperspec/

 sessionInfo ()
R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C  LC_TIME=en_US.utf8
 [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] hyperSpec_0.95lattice_0.19-13   R.matlab_1.3.3R.oo_1.7.4 
R.methodsS3_1.2.1


loaded via a namespace (and not attached):
[1] grid_2.12.0
 library (Rcompression)
 x = flu[[]]
 writeMat (flu.mat, flu)
Error in dim(x) - length(x) : invalid first argument
 writeMat (flu.mat, x)
 sessionInfo ()
R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C  LC_TIME=en_US.utf8
 [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] Rcompression_0.8-0 hyperSpec_0.95 lattice_0.19-13R.matlab_1.3.3 
R.oo_1.7.4

[6] R.methodsS3_1.2.1

loaded via a namespace (and not attached):
[1] grid_2.12.0



--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RGTK2 - Entry Point not found

2010-10-28 Thread W Eryk Wolski
I have a  problem loading RGtk2

Platform:
Windows XP
R 2.11.1

In the popup window I get:

The procedure entry point cairo_clip_extends could not be located in
the dynamic link library libcairo-2.dll

and in the R command:

Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared library
'C:/PROGRA~1/R/R-211~1.1/library/RGtk2/libs/RGtk2.dll':
  LoadLibrary failure:  The specified procedure could not be found.

Eryk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [SOLVED] Re: Install Error

2010-10-28 Thread Johannes Graumann
Johannes Graumann wrote:

 Hi,
 
 I'm running into the error below when doing R CMD INSTALL
 MyPackage.tar.gz. This didn't use to be this way and I am at a loss as to
 where this might be coming from. Any pointers where to look?
 
 Joh
 
 ** building package indices ...
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
 : 
   line 1 did not have 8 elements
 ERROR: installing package indices failed

I was working on new functionality and had a no-zipped data file in the 
data directory ... chance finding in google put me on that track ...
Works again.

Joh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RGTK2 - Entry Point not found

2010-10-28 Thread W Eryk Wolski
I have a  problem loading RGtk2

Platform:
Windows XP
R 2.11.1

In the popup window I get:

The procedure entry point cairo_clip_extends could not be located in
the dynamic link library libcairo-2.dll

and in the R command:

Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared library
'C:/PROGRA~1/R/R-211~1.1/library/RGtk2/libs/RGtk2.dll':
  LoadLibrary failure:  The specified procedure could not be found.

Eryk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [SOLVED] Re: Install Error

2010-10-28 Thread Johannes Graumann
Johannes Graumann wrote:

 Johannes Graumann wrote:
 
 Hi,
 
 I'm running into the error below when doing R CMD INSTALL
 MyPackage.tar.gz. This didn't use to be this way and I am at a loss as
 to where this might be coming from. Any pointers where to look?
 
 Joh
 
 ** building package indices ...
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
 na.strings,
 : 
   line 1 did not have 8 elements
 ERROR: installing package indices failed
 
 I was working on new functionality and had a no-zipped data file in the
 data directory ... chance finding in google put me on that track ...
 Works again.
 
 Joh

Wishlist item here 
https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14426

Joh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] overloading the generic primitive functions + and [

2010-10-28 Thread Martin Morgan
On 10/28/2010 02:17 AM, Barry Rowlingson wrote:
 On Thu, Oct 28, 2010 at 9:31 AM, Mark Heckmann mark.heckm...@gmx.de wrote:

 How can I add a new method to the generic function [ or +

 I want to create a S3 and S4 class that will use the [ and + method in a 
 different way.
 How can I overload the generic primitive [ or + so the method dispatch 
 will work correctly for my class?

 I saw an example of this in the ggplot2 package where different objects are 
 joined using the + primitive.
 Still, I could not figure out how to do that.

 Can someone give a small code example to show how that works?
 
  With S3 method stuff, to override + its as easy as writing Ops.{class}:
 
   a=hello
   b=world
   a+b
  Error in a + b : non-numeric argument to binary operator
   class(a)=ss
   class(b)=ss
   Ops.ss=function(e1,e2){paste(e1,e2)}
   a+b
  [1] hello world
 
  better make sure I haven't broken anything:
 
   c=1
   d=2
   c+d
  [1] 3   *phew*
 
 The Ops function should really have a handler for all possible
 operators (*, /, - etc) or fail with an error - see Ops.Date for
 example.
 
 With S4 classes... umm.. signatures... setMethod... setGeneric...
 errr. something... representations... setClass this that... yeah.
 Something like that.

The more-or-less literal translation of your S3 to S4 is

setClass(SS, character)
setMethod(Ops, c(SS, SS), function(e1, e2) paste(e1, e2))

Not so hard, eh? Though then like your S3 implementation this makes all
'Ops' (see ?Ops) the same for SS objects. For + alone

setMethod(+, c(SS, SS), function(e1, e2) paste(e1, e2))

One might typically use a group generic like Ops (or Arith for a narrow
set of operations in S4) when wanting to delegate to a slot of a class,
e.g.,

setClass(Person, representation(age=numeric))
setMethod(Arith, c(Person, Person), function(e1, e2) {
callGeneric(e...@age, e...@age)
})

 Phred = new(Person, age=32)
 Phrank = new(Person, age=37)
 Phred - Phrank
[1] -5
 Phred * Phrank
[1] 1184

Martin

 
 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.


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RGTK2 - Entry Point not found

2010-10-28 Thread Łukasz Ręcławowicz
The stable version of RGtk2 requires GTK version 2.8.0 or higher (and its
dependencies).

-- 
Mi³ego dnia

[[alternative HTML version deleted]]

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


Re: [R] R and Matlab

2010-10-28 Thread Thomas Levine
Is there a particular reason you can't use csv?

write.csv() in R

It seems that you can read csv in Matlab with this
http://www.mathworks.com/help/techdoc/ref/importdata.html

Tom

2010/10/28 Claudia Beleites cbelei...@units.it:
 I am looking for ways to use R and Matlab. Doing the data transformations
 in
 R and using the data in Matlab to analyze with some pre-defined scripts.
 Any good ways to transfer the data into matlab in its most recent version?
 I tried using R.matlab but the writeMat output is not readable by Matlab.

 It used to work, but I didn't need it for quite a while (a year or so ago,
 and with Matlab either 2007 or 2008a).

 I just tried, and neither does it work for me.
 You should notify the maintainer of R.matlab and include an example (code
 and data, e.g. with dput).

 I noticed that library (R.matlab) does not load the Rcompression package,
 but also after library (Rcompression), the resulting file was not read by
 Matlab.

 I tried loading a saved data.frame in Matlab 2008b on an Win XP computer: it
 doesn't find any variables inside the .mat file (and whos -file ...) doesn't
 show a variable.

 The other way round with a stupid little vector it worked.

 An R session (with only the 2nd try, after library (Rcompression)) is
 attached below.


 I just need to output a data.frame and read it as is into matlab where I
 can
 do any needed transformations on the variables.

 If you need to transfer the data right NOW, there's always csv.

 Claudia

 

 library (hyperSpec)
 Loading required package: lattice
 Package hyperSpec, version 0.95

 To get started, try
   vignette (introduction, package = hyperSpec)
   package?hyperSpec
   vignette (package = hyperSpec)

 If you use this package please cite it appropriately.
   citation(hyperSpec)
 will give you the correct reference.

 The project is hosted on http://r-forge.r-project.org/projects/hyperspec/

 sessionInfo ()
 R version 2.12.0 (2010-10-15)
 Platform: x86_64-pc-linux-gnu (64-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C              LC_TIME=en_US.utf8
  [4] LC_COLLATE=en_US.utf8     LC_MONETARY=C
 LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=en_US.utf8       LC_NAME=C                 LC_ADDRESS=C
 [10] LC_TELEPHONE=C            LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

 other attached packages:
 [1] hyperSpec_0.95    lattice_0.19-13   R.matlab_1.3.3    R.oo_1.7.4
 R.methodsS3_1.2.1

 loaded via a namespace (and not attached):
 [1] grid_2.12.0
 library (Rcompression)
 x = flu[[]]
 writeMat (flu.mat, flu)
 Error in dim(x) - length(x) : invalid first argument
 writeMat (flu.mat, x)
 sessionInfo ()
 R version 2.12.0 (2010-10-15)
 Platform: x86_64-pc-linux-gnu (64-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C              LC_TIME=en_US.utf8
  [4] LC_COLLATE=en_US.utf8     LC_MONETARY=C
 LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=en_US.utf8       LC_NAME=C                 LC_ADDRESS=C
 [10] LC_TELEPHONE=C            LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

 other attached packages:
 [1] Rcompression_0.8-0 hyperSpec_0.95     lattice_0.19-13    R.matlab_1.3.3
 R.oo_1.7.4
 [6] R.methodsS3_1.2.1

 loaded via a namespace (and not attached):
 [1] grid_2.12.0



 --
 Claudia Beleites
 Dipartimento dei Materiali e delle Risorse Naturali
 Università degli Studi di Trieste
 Via Alfonso Valerio 6/a
 I-34127 Trieste

 phone: +39 0 40 5 58-37 68
 email: cbelei...@units.it

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] overloading the generic primitive functions + and [

2010-10-28 Thread Barry Rowlingson
On Thu, Oct 28, 2010 at 2:12 PM, Martin Morgan mtmor...@fhcrc.org wrote:

 Not so hard, eh? Though then like your S3 implementation this makes all
 'Ops' (see ?Ops)

 Except you have to re-run the set* things every R session:

  setClass(SS, character)
  setMethod(Ops, c(SS, SS), function(e1, e2) paste(e1, e2))
  a=new(SS,hello)
  b=new(SS,world)
  a+b
 [1] hello world
  q()
 Save workspace image? [y/n/c]: y

...start R again...

[Previously saved workspace restored]

  a=new(SS,hello)
  b=new(SS,world)
  a+b
 Error in a + b : non-numeric argument to binary operator

 It seems the SS class is preserved but the method definition isn't.
Otherwise new(SS,hello) fails.

 That's one of the things that confuses me about S4 - its use of
invisible global things. ls(all.names=TRUE) shows me the bits:

  ls(all.names=TRUE)
 [1] a  .__C__SS   .requireCachedGenerics

 It seems that .__C__SS is the class definition, and the
.requireCachedGenerics seems to imply I've done something with 'Ops':

  .requireCachedGenerics
[[1]]
[1] Ops

 but doesn't actually store and restore my definition.

 A bug? I dunno. Version 2.10.1 if anyone cares. I don't. I'll just go
back to my S3 method which is just as simple and works when I restore
the .RData I saved things to. Each to their own!


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.


Re: [R] overloading the generic primitive functions + and [

2010-10-28 Thread Barry Rowlingson
On Thu, Oct 28, 2010 at 12:14 PM, Christofer Bogaso
bogaso.christo...@gmail.com wrote:
 Dear Barry, this is really interesting. However I could not understand
 this line:

 Ops.ss=function(e1,e2){paste(e1,e2)}

 Where you have told R to behave + function differently when it faces
 ss class?
 What should be the ideal approach if I what to use * function?

 You can get the character string of the operator from '.Generic', for example:

Ops.ss=function(e1,e2){
   if(.Generic==+){
return(paste(e1,e2))
   }
   if(.Generic==*){
 return(rep(e1,e2))
   }
  stop(No definition for ,.Generic)
}

Giving:

  a*5
 [1] hello hello hello hello hello
  a+world
 [1] hello world
  a/2
 Error in Ops.ss(a, 2) : No definition for /

Note how S3 methods are dispatched only by reference to the first
argument (on the left of the operator). I think S4 beats this by
having signatures that can dispatch depending on both arguments.

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.


Re: [R] RGTK2 - Entry Point not found

2010-10-28 Thread W Eryk Wolski
Failed to load RGtk2 dynamic library, attempting to install it.
trying URL 'http://downloads.sourceforge.net/gladewin32/gtk-2.12.9-win32-2.exe'
Content type 'application/x-msdownload' length 7378984 bytes (7.0 Mb)

I run the complete setup of GTK .
Hence, I assume Version 2.12.9 is installed on my box.

My path variable starts with:
%GTK_BASEPATH%\bin;


Any other ideas?



2010/10/28 Łukasz Ręcławowicz lukasz.reclawow...@gmail.com:
 The stable version of RGtk2 requires GTK version 2.8.0 or higher (and its
 dependencies).

 --
 Miłego dnia








-- 
Witold Eryk Wolski

Heidmark str 5
D-28329 Bremen
tel.: 04215261837

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Key combination that removes all R objects

2010-10-28 Thread claire-c.jones
Dear readers, 

There is a combination of keys that I have (on several occasions now)
typed by accident into R (2.10.0) which removes all the objects in the
environment, and clears the console, as though I had typed
rm(list=ls()). 
Unfortunately I don't know what the combination of keys are, so I am
struggling to find out more about this behaviour on my own and I was
hoping that someone has come across it before.
Does anyone i) know what combination of keys this is (so that I am more
cautious around them in future) or better yet, ii) know how to disable
this shortcut?

Thanks for your time,
Claire



Issued by UBS AG or affiliates to professional investors for
information only and its accuracy/completeness is not guaranteed.
All opinions may change without notice and may differ to
opinions/recommendations expressed by other business areas of UBS.
UBS may maintain long/short positions and trade in instruments
referred to. Unless stated otherwise, this is not a personal
recommendation, offer or solicitation to buy/sell and any
prices/quotations are indicative only. UBS may provide investment
banking and other services to, and/or its employees may be directors
of, companies referred to. To the extent permitted by law, UBS does
not accept any liability arising from the use of this communication.

 \251 UBS 2010.  All rights reserved. Intended for recipient only and
not for further distribution without the consent of UBS.

UBS Limited is a company registered in England  Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.

UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.

UBS Clearing and Execution Services Limited is a company registered
in England  Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.

UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] bugs when using R-2.12.0 Please HELP!

2010-10-28 Thread Hao Wu
Hi, R-help group, I kinda meeting a question when using R-2.12.0(Previous
version is 2.10.0):

 

When I typed library(Biobase), everything is alright!

But when I type library(genefilter), it doesn't work! 

And echo this: 

 

Error in library.dynam(lib, package, package.lib) : 

  DLL 'RSQLite' not found: maybe not installed for this architecture?

Error: package/namespace load failed for 'genefilter' 

 

Please someone tell me what's wrong with this?

 

3ks a lot!

Tony


[[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] bugs when using R-2.12.0 Please HELP!

2010-10-28 Thread David Winsemius


On Oct 28, 2010, at 10:01 AM, Hao Wu wrote:

Hi, R-help group, I kinda meeting a question when using  
R-2.12.0(Previous

version is 2.10.0):

When I typed library(Biobase), everything is alright!
But when I type library(genefilter), it doesn't work!
And echo this:

Error in library.dynam(lib, package, package.lib) :

 DLL 'RSQLite' not found: maybe not installed for this architecture?

Error: package/namespace load failed for 'genefilter'

Please someone tell me what's wrong with this?


I guess the obvious question i: Have you have (re-?) installed RSQLiite?

Couple of other points:

You should post the results of sessionInfo(). It will automatically  
cure many of the remaining information deficiencies in your question.


Labeling user error or failure to read informative error messages as  
bugs is annoying to many of the authors and maintainers of R (a  
group of which I am not a member). A word which has less implication  
of software deficiencies would be problems.


This is really about BioConductor and it has its own mailing list.

--

David Winsemius, MD
West Hartford, CT

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


[R] Heatmap construction problems

2010-10-28 Thread Struchtemeyer, Chris
I am very new to R and don't have any computer program experience
whatsoever.  I am trying to generate a heatmap of the following data:

   
   
 Phylum,AI,AJT,BY,GA,Grt,Sm
 Acidobacteria,0.5,0.7,2.7,0.1,2.6,1.0
 Actinobacteria,33.7,65.1,9.7,2.0,3.9,2.1
 Bacteroidetes,9.7,5.6,0.7,13.2,41.1,21.6
 CCM11b,0.0,0.0,0.0,0.0,0.0,0.1
 Chlamydiae,0.1,0.1,0.0,0.0,1.0,0.2
 Chlorobi,0.0,0.0,0.0,0.0,0.7,1.0
 Chloroflexi,0.1,0.2,0.6,0.2,0.8,0.6
 Cyanobacteria,18.7,0.0,1.0,1.5,0.9,0.3
 Ellusimicrobiales,0.0,0.0,0.0,0.0,0.0,0.0
 Firmicutes,1.0,7.6,8.3,31.9,2.1,6.9
 Gemmatimonadetes,5.0,0.3,0.3,0.0,0.1,0.0
 GN02,0.0,0.0,0.0,0.0,0.0,0.5
 Nitrospirae,0.0,0.2,1.1,0.0,0.0,0.0
 NKB19,0.0,0.0,0.9,0.0,0.0,0.0
 OP8,0.0,0.1,0.0,0.0,0.0,0.0
 OP10,0.6,0.2,0.5,0.0,0.6,0.6
 Planctomycetes,0.9,0.5,6.5,2.2,2.0,2.3
 Alphaproteobacteria,7.8,10.7,21.8,12.2,5.3,26.8
 Betaproteobacteria,9.9,2.8,8.9,21.7,8.3,21.9
 Deltaproteobacteria,0.5,0.2,1.8,2.0,1.2,7.1
 Epsilonproteobacteria,0.0,0.0,0.0,0.1,0.0,0.2
 Gammaproteobacteria,4.0,2.5,8.0,9.4,24.7,5.4
 SC4,0.0,0.0,0.0,0.0,0.7,0.0
 SM2F11,0.0,0.0,0.0,0.0,0.2,0.0
 SPAM,0.0,0.1,0.0,0.0,0.1,0.1
 Synergistes,0.0,0.0,0.0,0.1,0.0,0.0
 Deinococcus-Thermus,0.0,0.0,0.0,0.0,0.0,0.0
 TM6,0.1,0.0,0.0,0.0,0.1,0.0
 TM7,0.0,0.1,0.4,0.0,0.4,0.1
 Verrucomicrobia,3.8,2.1,23.2,2.9,1.3,0.5
 WPS-2,0.0,0.0,0.1,0.0,0.0,0.0
 WS3,0.0,0.0,0.0,0.0,0.0,0.1
 Uncl Bacteria,3.7,1.2,3.7,0.4,1.9,0.8

I am a microbiologist.  What I want to do is construct a heatmap showing the
relative abundance of each phylum.  The far left column of my table contains
all of the phylum names I observed in a set of 6 water samples and each of
the columns to the right contains the relative abundance (%) of each phylum
in each water sample.  I have tried constructing a heatmap using the ggplot
guidelines listed at the following site:
http://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/

I can generate a heatmap using this method, but would like to alter the
scale.  I would like it so that I can have a little more complex gradient
ranging from 0% to the highest relative abundance that I observe in the
above table (65.1%).  The default scale I get using the link above is just a
relative intensity scale ranging from 1 to 5 (where white represent low
percentages and steelblue represented high percentages).  This is alright
but for phyla that are present at relative abundance of less than 5% all
appear to be white (or non-existant).  Is there anyway to fix this?  Any
help would be greatly appreciated.

Thanks,

Chris

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

2010-10-28 Thread Robert M. Flight
Hi All,

I am developing a package that requires information about the location
of a set of files that will be used often in the calculations. In my
current version, I define the location in the main file that calls all
the subfunctions. This works fine when you are installing from source,
but will not work so well if I want people to be able to install
binary versions of the package. Therefore, I think the best way to
encode the information would be through the use of an environment
variable, that could then be read by Sys.getenv(VARIABLE) when the
function is called.

In the help, I found a few different ways to set environment
variables, but the easiest way (from my reading anyways) seemed to be
by creating the file Renviron.site in the R_HOME/etc directory and
adding the variable there. I am interested in opinions from the list,
or other suggestions on how to do this.

For those who are interested, the package does a lot of parsing of
KEGG KGML files, and to speed up calculations I offer advice that they
should download a copy of the KGML directory for their organism to
their local machine, and I want the package to know where those files
are at runtime.

Thanks in advance,

-Robert

Robert M. Flight, Ph.D.
University of Louisville Bioinformatics Laboratory
University of Louisville
Louisville, KY

PH 502-852-0467
EM robert.fli...@louisville.edu
EM rfligh...@gmail.com

Williams and Holland's Law:
       If enough data is collected, anything may be proven by
statistical methods.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Please help me about Monte Carlo Permutation

2010-10-28 Thread Kjetil Halvorsen
This is one way. I read your two columns of data into
two variables, x and y. Then:

 test - replicate(5000, cor(x, sample(y)))
 hist(test)


Kjetil

On Thu, Oct 28, 2010 at 9:49 AM, Chitra cbban...@gmail.com wrote:

 Dear R experts,
I am sorry for my inability.
I have the following dataset:

   Qtot Itot
1   73  684
2   64  451
3   71  378
4   65  284
5   47  179
6   31  117
7   19   69

Now I need to perform Monte Carlo Pertutation test underlaying the
 following condition.


Condition

In order to choose randomly (5000 times) for the Qtot in the interval 0 to
 the maximum possible value of

Qtot for each observed value of the independent variable (Itot), Monte
 Carlo tests needed to be perform to test the null hypothesis. The
maximum observed value is either the calculated size of the regional pool
 (Interpolated value), or the measured size of the actual

pool. Each time correlation coefficient (r) between independent and
 dependent variable has to be calculated in order to achieve

the empirical distribution of r for the null hypothesis conditions.

Now please help me how to do?
I have also intalled combinat library in R. But could not perform by
 myself.
I will be highly grateful.
Thanks.

 --
 Chitra Bahadur Baniya (PhD)
 Lecturer
 Central Department of Botany
 Tribhuvan University
 Kirtipur
 Kathmandu, Nepal

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Please-help-me-about-Monte-Carlo-Permutation-tp3017131p3017131.html
 Sent from the R help mailing list archive at Nabble.com.

        [[alternative HTML version deleted]]

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


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

2010-10-28 Thread Bond, Stephen
To close the issue:

 S.ave - survfit(fit) # this is average survival
 S.1 - (S.ave$surv)^exp(fit$linear.predictors[1]) # get subject 1
 S.1
 [1] 0.848450223861993 0.696973203043377 0.530604282995790 0.391136296063732 
0.228370373409774 0.132991279576665 0.071742127376216
 [8] 0.030988671457923 0.012340713882587 0.004553665545169 0.000865566322530 
0.000135746409544

 survfit(fit,new=ovarian[1,])$surv   # subject 1 from survfit
 [1] 0.848450223861993 0.696973203043377 0.530604282995791 0.391136296063732 
0.228370373409774 0.132991279576665 0.071742127376216
 [8] 0.030988671457923 0.012340713882587 0.004553665545169 0.000865566322530 
0.000135746409544

A single call to survfit will suffice for thousands of subjects, avoiding the 
iterative loop calculations inside survfit.

Stephen Bond 

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Wednesday, October 27, 2010 1:15 PM
To: Bond, Stephen
Cc: r-help@r-project.org
Subject: Re: [R] coxph linear.predictors


On Oct 27, 2010, at 12:12 PM, Bond, Stephen wrote:

 I would like to be able to construct hazard rates (or unconditional  
 death prob)

Hazards are not probabilities (since probabilities are constrained to  
the range [0,1] and hazards are unbounded upward.)

 for many subjects from a given survfit.

 This will involve adjusting the ( n.event/n.risk)
 with (coxph object )$linear.predictors
 I must be having another silly day as I cannot reproduce the linear  
 predictor:

 fit - coxph(Surv(futime, fustat) ~ age, data = ovarian)
 fit$linear.predictors[1]
 [1] 2.612756

That's the linear predictor (the beta*X) and that particular number  
only applies to the first case.


 coef(fit)*model.matrix(fit)[1,1]
 age
 11.69021


I don't know what that might be and you are not telling us what you  
think it is.


 The above is based on the help listing for coxph.object
 coefficients: the coefficients of the linear predictor, which multiply
  the columns of the model matrix.  If the model is
  over-determined there will be missing values in the vector
  corresponding to the redundant columns in the model matrix.

 Also, please comment whether n.event/n.risk

The Nelson-Aalen estimator of the cumulative hazard as a function of  
intervals prior to t is sum( n-event(t)/ n.risk(t))

 gives the baseline hazard exp(alpha) ?

No. The baseline hazard, as you are calling this, would be an  
estimate for persons with all covariates = 0, so in this case is for  
women of age=0. (Not a particularly interpretable result in many  
situations. The baseline hazard following treated ovarian cancer for  
neonates is not medically sensible.)

What is the purpose of this request? Is someone telling you you need  
to provide estimates for instantaneous hazards?


-- 

David Winsemius, MD
West Hartford, CT

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


Re: [R] R and Matlab

2010-10-28 Thread Claudia Beleites

On 10/28/2010 03:16 PM, Thomas Levine wrote:

Is there a particular reason you can't use csv?

(Not sure whether I'm meant - as I also suggested csv to Santosh)

But:

- It used to work, so there may be code existing that is broken now (e.g. I do
have such code, but at least for the moment it doesn't matter). Thus the 
information may very well be of interest for the maintainer.


- csv is fine for a matrix (or a vector) or a data.frame. How about arrays,
lists, more than one variable?

I think the default file format changed to v7.3 (though I'm not sure whether
that is just for  large variables).
Unfortunately -v switch of load (that used e.g. to allow reading of V4 files) is
gone, and I can't see anything to specify the .mat file format version.
The curious thing is that readMat does accept the file produced by Matlab 2008b.
If it is a matter of writeMat writing an old file format, I'd have expected that
rather load should still be able to read the writeMat generated file than
readMat being able to read Matlab's .mat file.

my 2 ct

Claudia



write.csv() in R

It seems that you can read csv in Matlab with this
http://www.mathworks.com/help/techdoc/ref/importdata.html

Tom

2010/10/28 Claudia Beleitescbelei...@units.it:

I am looking for ways to use R and Matlab. Doing the data transformations
in
R and using the data in Matlab to analyze with some pre-defined scripts.
Any good ways to transfer the data into matlab in its most recent version?
I tried using R.matlab but the writeMat output is not readable by Matlab.


It used to work, but I didn't need it for quite a while (a year or so ago,
and with Matlab either 2007 or 2008a).

I just tried, and neither does it work for me.
You should notify the maintainer of R.matlab and include an example (code
and data, e.g. with dput).

I noticed that library (R.matlab) does not load the Rcompression package,
but also after library (Rcompression), the resulting file was not read by
Matlab.

I tried loading a saved data.frame in Matlab 2008b on an Win XP computer: it
doesn't find any variables inside the .mat file (and whos -file ...) doesn't
show a variable.

The other way round with a stupid little vector it worked.

An R session (with only the 2nd try, after library (Rcompression)) is
attached below.



I just need to output a data.frame and read it as is into matlab where I
can
do any needed transformations on the variables.


If you need to transfer the data right NOW, there's always csv.

Claudia




library (hyperSpec)

Loading required package: lattice
Package hyperSpec, version 0.95

To get started, try
   vignette (introduction, package = hyperSpec)
   package?hyperSpec
   vignette (package = hyperSpec)

If you use this package please cite it appropriately.
   citation(hyperSpec)
will give you the correct reference.

The project is hosted on http://r-forge.r-project.org/projects/hyperspec/


sessionInfo ()

R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C  LC_TIME=en_US.utf8
  [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C
LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=en_US.utf8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] hyperSpec_0.95lattice_0.19-13   R.matlab_1.3.3R.oo_1.7.4
R.methodsS3_1.2.1

loaded via a namespace (and not attached):
[1] grid_2.12.0

library (Rcompression)
x = flu[[]]
writeMat (flu.mat, flu)

Error in dim(x)- length(x) : invalid first argument

writeMat (flu.mat, x)
sessionInfo ()

R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C  LC_TIME=en_US.utf8
  [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C
LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=en_US.utf8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] Rcompression_0.8-0 hyperSpec_0.95 lattice_0.19-13R.matlab_1.3.3
R.oo_1.7.4
[6] R.methodsS3_1.2.1

loaded via a namespace (and not attached):
[1] grid_2.12.0



--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

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




--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 

Re: [R] Key combination that removes all R objects

2010-10-28 Thread Viechtbauer Wolfgang (STAT)
I am not aware of the existance of a shortcut that would do what you describe.

On Windows, one could hit Ctrl-M, followed by R, but then one gets a prompt, 
asking for confirmation to remove all objects, but this can't be what you are 
referring to.

Are you perhaps using Tinn-R and (accidentally) hitting F12 (which does in fact 
exactly what you describe)?

Best,

--
Wolfgang Viechtbauer
Department of Methodology and Statistics
School for Public Health and Primary Care
Maastricht University, P.O. Box 616
6200 MD Maastricht, The Netherlands
Tel: +31 (43) 388-2277
Fax: +31 (43) 361-8388
Web: http://www.wvbauer.com


Original Message
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of
claire-c.jo...@ubs.com Sent: Thursday, October 28, 2010 16:10 To:
r-help@r-project.org Subject: [R] Key combination that removes all R
objects

 Dear readers,

 There is a combination of keys that I have (on several occasions now)
 typed by accident into R (2.10.0) which removes all the objects in
 the environment, and clears the console, as though I had typed
 rm(list=ls()).
 Unfortunately I don't know what the combination of keys are, so I am
 struggling to find out more about this behaviour on my own and I was
 hoping that someone has come across it before. Does anyone i) know
 what combination of keys this is (so that I am more cautious around
 them in future) or better yet, ii) know how to disable this shortcut?

 Thanks for your time,
 Claire

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

2010-10-28 Thread Charles C. Berry

On Wed, 27 Oct 2010, Charles C. Berry wrote:


On Wed, 27 Oct 2010, Alex P. wrote:


 Hello All,

 I have multiple list of lists in the form of

 Mylist1[[N]][[K]]$Name_i,

 with N=1..6, K=1..3, and i=1..7. Each Name_i is a matrix. I have 30 of
 these objects Mylist1, Mylist2, ...

 I would like to merge these lists by each Name_i using rbind, but I
 couldn't figure out how to do it. What I want at the end is a single list
 of lists, again in the form of Mylist[[N]][[K]]$Name_i. Manually doing it
 is not feasible given the large number of Mylist objects.



Turn them into a single array of mode 'list', then do the rbind'ing, and save 
the result as an array (or see ?relist for imposing the nested structure of 
the orignal lists)


Something like:


I see a few hiccups below.

Maybe Alex P. should include a minimal, self-contained example that 
RespondeRs could try out...




objs - paste('MyList',1:30,sep='')
big.list - lapply( objs, get )
for (i in 1:4) big.list - unlist(big.list,recursive=FALSE)


for (i in 1:3) ...


dim( big.list ) - c(30, 6, 3, 7 )


dim( big.list ) - rev( c(30, 6, 3, 7 ) )


res - apply( big.list, 2:4, rbind )
dim(res) - c( 30, 3, 7 )


res - apply( big.list, 1:3, function(x) list( do.call( rbind, x ) ))


Chuck





HTH,

Chuck


 Thanks in advance,

 Alex

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



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] Rsolnp examples

2010-10-28 Thread Jan Theodore Galkowski
I'm interested in the Rsolnp package. For their primary function
solnp, one example is given, and there is a reference to unit
tests.  Anyone know where these can be found?  Also, Rsolnp is
used in a few other packages (e.g., depmixS4), but I cannot seem
to find source illustrating its call sequence, and the precise
definition of the functions passed.

Can anyone help?

Thanks,

 - Jan

[[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] runtime on ising model

2010-10-28 Thread Michael D
Mike, I'm not sure what you mean about removing foo but I think the method
is sound in diagnosing a program issue and the results speak for themselves.

I did invert my if statement at the suggestion of a CS professor (who also
suggested recoding in C, but I'm in an applied math program and haven't had
the time to take programming courses, which i know would be helpful)

Anyway, with the statement as:

if( !(k %in% c(10^4,10^5,10^6,10^7)) ){
#do nothing
} else {
q - q+1
Out[[q]] - M
}

run times were back to around 20 minutes. So as best I can tell something
happens in the if statement causing the computer to work ahead, as the
professor suggests. I'm no expert on R (and have no desire to try looking at
the R source code (it would only confuse me)) but if anyone can offer
guidance on how the if statement works (Does R try to work ahead? Under what
conditions does it try to work ahead so I can try to exploit this
behavior) I would greatly appreciate it.
If it would require too much knowledge of the computer system to understand
I doubt I would be able to make use of it, but maybe someone else could
benefit.



On Tue, Oct 26, 2010 at 3:24 PM, Mike Marchywka marchy...@hotmail.comwrote:








 
  Date: Tue, 26 Oct 2010 12:53:14 -0400
  From: mike...@gmail.com
  To: j...@bitwrit.com.au
  CC: r-help@r-project.org
  Subject: Re: [R] runtime on ising model
 
  I have an update on where the issue is coming from.
 
  I commented out the code for pos[k+1] - M[i,j] and the if statement
 for
  time = 10^4, 10^5, 10^6, 10^7 and the storage and everything ran
 fast(er).
  Next I added back in the pos statements and still runtimes were good
  (around 20 minutes).
 
  So I'm left with something is causing problems in:

 I haven't looked at this since some passing interest in magnetics
 decades ago, something about 8-tracks and cassettes, but you have
 to be careful with conclusions like  I removed foo and problem
 went away therefore problem was foo. Performance issues are often
 caused by memory, not CPU limitations. Removing anything with a big
 memory footprint could speed things up. IO can be a real bottleneck.
 If you are talking about things on minute timescales, look at task
 manager and see if you are even CPU limited. Look for page faults
 or IO etc. If you really need performance and have a task which
 is relatively simple, don't ignore c++ as a way to generate data
 points and then import these into R for analysis.

 In short, just because you are focusing on math it doesn't mean
 the computer is limited by that.


 
  ## Store state at time 10^4, 10^5, 10^6, 10^7
  if( k %in% c(10^4,10^5,10^6,10^7) ){
  q - q+1
  Out[[q]] - M
  }
 
  Would there be any reason R is executing the statements inside the if
  before getting to the logical check?
  Maybe R is written to hope for the best outcome (TRUE) and will just
 throw
  out its work if the logic comes up FALSE?
  I guess I can always break the for loop up into four parts and store the
  state at the end of each, but thats an unsatisfying solution to me.
 
 
  Jim, I like the suggestion of just pulling one big sample, but since I
 can
  get the runtimes under 30 minutes just by removing the storage piece I
 doubt
  I would see any noticeable changes by pulling large sample vectors.
 
  Thanks,
  Michael
 
  On Tue, Oct 26, 2010 at 6:22 AM, Jim Lemon  wrote:
 
   On 10/26/2010 04:50 PM, Michael D wrote:
  
   So I'm in a stochastic simulations class and I having issues with the
   amount
   of time it takes to run the Ising model.
  
   I usually don't like to attach the code I'm running, since it will
   probably
   make me look like a fool, but I figure its the best way I can find any
   bits
   I can speed up run time.
  
   As for the goals of the exercise:
   I need the state of the system at time=1, 10k, 100k, 1mill, and 10mill
   and the percentage of vertices with positive spin at all t
  
   Just to be clear, i'm not expecting anyone to tell me how to program
 this
   model, cause I know what I have works for this exercise, but it takes
 far
   too long to run and I'd like to speed it up by replacing slow
 operations
   wherever possible.
  
   Hi Michael,
   One bottleneck is probably the sampling. If it doesn't grab too much
   memory, setting up a vector of the samples (maybe a million at a time
 if 10
   million is too big - might be able to rewrite your sample vector when
 you
   store the state) and using k (and an offset if you don't have one big
   vector) to index it will give you some speed.
  
   Jim
  
  
 
  [[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.


[[alternative HTML version deleted]]


Re: [R] RGTK2 - Entry Point not found

2010-10-28 Thread Łukasz Ręcławowicz
W dniu 28 pa¼dziernika 2010 16:09 u¿ytkownik W Eryk Wolski 
wewol...@gmail.com napisa³:


 Any other ideas?


Restart R and then try load library :)

-- 
Mi³ego dnia

[[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] runtime on ising model

2010-10-28 Thread David Winsemius


On Oct 28, 2010, at 11:52 AM, Michael D wrote:

Mike, I'm not sure what you mean about removing foo but I think the  
method
is sound in diagnosing a program issue and the results speak for  
themselves.


I did invert my if statement at the suggestion of a CS professor  
(who also
suggested recoding in C, but I'm in an applied math program and  
haven't had

the time to take programming courses, which i know would be helpful)

Anyway, with the statement as:

if( !(k %in% c(10^4,10^5,10^6,10^7)) ){
#do nothing
} else {
q - q+1
Out[[q]] - M
}

run times were back to around 20 minutes.


Have you tried replacing all of those 10^x operations with their  
integer equivalents, c(1L, 10L, 100L)? Each time through  
the loop you are unnecessarily calling the ^ function 4 times. You  
could also omit the last one. 10^7,  during testing since M at the  
last iteration (k=10^7) would be the final value and you could just  
assign the state of M at the end. So we have eliminated 4*10^7  
unnecessary ^ calls and 10^7 unnecessary comparisons. (The CS  
professor is perhaps used to having the C compiler do all thinking of  
this sort for him.)


--
David


So as best I can tell something
happens in the if statement causing the computer to work ahead, as the
professor suggests. I'm no expert on R (and have no desire to try  
looking at

the R source code (it would only confuse me)) but if anyone can offer
guidance on how the if statement works (Does R try to work ahead?  
Under what

conditions does it try to work ahead so I can try to exploit this
behavior) I would greatly appreciate it.
If it would require too much knowledge of the computer system to  
understand
I doubt I would be able to make use of it, but maybe someone else  
could

benefit.

On Tue, Oct 26, 2010 at 3:24 PM, Mike Marchywka  
marchy...@hotmail.comwrote:





Date: Tue, 26 Oct 2010 12:53:14 -0400
From: mike...@gmail.com
To: j...@bitwrit.com.au
CC: r-help@r-project.org
Subject: Re: [R] runtime on ising model

I have an update on where the issue is coming from.

I commented out the code for pos[k+1] - M[i,j] and the if  
statement

for

time = 10^4, 10^5, 10^6, 10^7 and the storage and everything ran

fast(er).
Next I added back in the pos statements and still runtimes were  
good

(around 20 minutes).

So I'm left with something is causing problems in:


I haven't looked at this since some passing interest in magnetics
decades ago, something about 8-tracks and cassettes, but you have
to be careful with conclusions like  I removed foo and problem
went away therefore problem was foo. Performance issues are often
caused by memory, not CPU limitations. Removing anything with a big
memory footprint could speed things up. IO can be a real bottleneck.
If you are talking about things on minute timescales, look at task
manager and see if you are even CPU limited. Look for page faults
or IO etc. If you really need performance and have a task which
is relatively simple, don't ignore c++ as a way to generate data
points and then import these into R for analysis.

In short, just because you are focusing on math it doesn't mean
the computer is limited by that.




## Store state at time 10^4, 10^5, 10^6, 10^7
if( k %in% c(10^4,10^5,10^6,10^7) ){
q - q+1
Out[[q]] - M
}

Would there be any reason R is executing the statements inside the  
if

before getting to the logical check?
Maybe R is written to hope for the best outcome (TRUE) and will just

throw

out its work if the logic comes up FALSE?
I guess I can always break the for loop up into four parts and  
store the

state at the end of each, but thats an unsatisfying solution to me.


Jim, I like the suggestion of just pulling one big sample, but  
since I

can
get the runtimes under 30 minutes just by removing the storage  
piece I

doubt

I would see any noticeable changes by pulling large sample vectors.

Thanks,
Michael

On Tue, Oct 26, 2010 at 6:22 AM, Jim Lemon  wrote:


On 10/26/2010 04:50 PM, Michael D wrote:

So I'm in a stochastic simulations class and I having issues  
with the

amount
of time it takes to run the Ising model.

I usually don't like to attach the code I'm running, since it will
probably
make me look like a fool, but I figure its the best way I can  
find any

bits
I can speed up run time.

As for the goals of the exercise:
I need the state of the system at time=1, 10k, 100k, 1mill, and  
10mill

and the percentage of vertices with positive spin at all t

Just to be clear, i'm not expecting anyone to tell me how to  
program

this
model, cause I know what I have works for this exercise, but it  
takes

far

too long to run and I'd like to speed it up by replacing slow

operations

wherever possible.

Hi Michael,
One bottleneck is probably the sampling. If it doesn't grab too  
much
memory, setting up a vector of the samples (maybe a million at a  
time

if 10
million is too big - might be able to rewrite your sample vector  
when

you

[R] Returning highs and lows in R

2010-10-28 Thread Jason Kwok
I'm having trouble returning a rolling n period highest value for a data
set.  For each day I want to calculate the highest value over the last 3
days.  I am using the following packages: zoo, xts, quantmod and TTR.

Thanks, Jason

   GLD.Close
2010-10-01128.91
2010-10-04128.46
2010-10-05130.99
2010-10-06131.81
2010-10-07130.37
2010-10-08131.66
2010-10-11132.29
2010-10-12131.96
2010-10-13134.07
2010-10-14134.75
2010-10-15133.68
2010-10-18134.28
2010-10-19130.11
2010-10-20131.32
2010-10-21129.47
2010-10-22129.73
2010-10-25130.85
2010-10-26130.88
2010-10-27129.52


[[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] removing margin space between columns in lattice plots

2010-10-28 Thread Deepayan Sarkar
On Sat, Oct 23, 2010 at 9:25 AM, Stephen T. obsessiv...@hotmail.com wrote:

 Hi list,

 From the xyplot() documentation I'm guessing this may not be
 possible, but is there a way to specify a scale definition something
 between relation=free and relation=same such that the scales are
 fixed across rows and column margins are removed for a M x N
 conditioning plot (sort of like ggplot2 plots)? I find that the
 margin spacing in between each panel is taking up a lot of space and
 looking for a solution (and perhaps I'm doing something wrong but
 ggplot2 is extremely slow on my machine [Mac 10.5 running R 2.12] so
 I am unable to use it effectively...).

Check out ?combineLimits from the latticeExtra package.

-Deepayan

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


Re: [R] Returning highs and lows in R

2010-10-28 Thread Jorge Ivan Velez
Hi Jason,

Please consider the following example:

 require(zoo)
 z2 - zoo(rnorm(6))
 z2
  1   2   3   4   5   6
-0.53305704 -1.09374867  1.55171109 -0.05830751 -0.25987647 -0.02009973
 rollapply(z2, 3, max, by = 1)
  2   3   4   5
 1.55171109  1.55171109  1.55171109 -0.02009973

See ?rollapply for more information.

HTH,
Jorge

On Thu, Oct 28, 2010 at 12:27 PM, Jason Kwok  wrote:

 I'm having trouble returning a rolling n period highest value for a data
 set.  For each day I want to calculate the highest value over the last 3
 days.  I am using the following packages: zoo, xts, quantmod and TTR.

 Thanks, Jason

   GLD.Close
 2010-10-01128.91
 2010-10-04128.46
 2010-10-05130.99
 2010-10-06131.81
 2010-10-07130.37
 2010-10-08131.66
 2010-10-11132.29
 2010-10-12131.96
 2010-10-13134.07
 2010-10-14134.75
 2010-10-15133.68
 2010-10-18134.28
 2010-10-19130.11
 2010-10-20131.32
 2010-10-21129.47
 2010-10-22129.73
 2010-10-25130.85
 2010-10-26130.88
 2010-10-27129.52
 

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


[[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] Please help me about Monte Carlo Permutation

2010-10-28 Thread Chitra

Dear Kjetil,
Thanks a lot for your help. I could not get histogram when I ask by R. It
simply gave me blank plot between frequency and test. I want to plot sample
(y) verses xl. Can you please tell me are both variables were permuted or
only x?
Thanking your help,
Chitra
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Please-help-me-about-Monte-Carlo-Permutation-tp3017131p3017634.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] Returning highs and lows in R

2010-10-28 Thread Peter Ehlers

On 2010-10-28 09:27, Jason Kwok wrote:

I'm having trouble returning a rolling n period highest value for a data
set.  For each day I want to calculate the highest value over the last 3
days.  I am using the following packages: zoo, xts, quantmod and TTR.


Isn't that exactly what rollmax() does?

   -Peter Ehlers



Thanks, Jason

GLD.Close
2010-10-01128.91
2010-10-04128.46
2010-10-05130.99
2010-10-06131.81
2010-10-07130.37
2010-10-08131.66
2010-10-11132.29
2010-10-12131.96
2010-10-13134.07
2010-10-14134.75
2010-10-15133.68
2010-10-18134.28
2010-10-19130.11
2010-10-20131.32
2010-10-21129.47
2010-10-22129.73
2010-10-25130.85
2010-10-26130.88
2010-10-27129.52




[[alternative HTML version deleted]]

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


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


[R] adding copies of rows toa data frame based upon start and end dates

2010-10-28 Thread Grant Gillis
Hello All and thanks in advance for any advice.

I have a data frame with rows corresponding radio-collared animals (see
sample data below).  There is a start date (DATESTART), and end date
(DATEEND), and the number of days on air (DAYSONAIR).  What I would like to
do is add a column called DATE to so that each row ID has a row for every
day that the radio collar was on the air while copying all other data.  For
example ID 1001 would expand into 48 rows beginning with 4/17/91 and ending
with 6/4/91.  all other values would remain the same for each new
rowUnfortunately I have not gotten anywhere with my attempts


Thank you!!




IDGRIDFOODWB1WB2SADRUGFREQDATESTART
DATECOLLARDATEENDDAYSONAIR
100110319999FAI14824/17/91
4/17/916/4/9148.00
100210659671MAC14084/17/91
4/17/916/25/9169.00
100310325662FAI07694/17/91
4/17/916/4/93779.00
100410322655FAC15614/18/91
4/18/915/27/9139.00
93100510654899MAI12884/18/91
4/18/915/27/9139.00
94100610301651MAC15934/18/91
4/18/917/11/9184.00
95100710349669FAI15214/18/91
4/18/9111/2/91198.00

[[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] Returning highs and lows in R

2010-10-28 Thread Bert Gunter
Jason:

Please read AND FOLLOW the posting guide on how to ask clear
questions. Here, you need to more carefully define what you mean by
the last 3 days. Do you mean:(a) the last 3 values in the series
(including or excluding the present one?) or the last 3 calendar days
-- e.g. for 10-05, only 10-05 and 10-04, since 10-01 is not within the
last 3 calendar days.Also, do you have missing values, and, if so, how
do you want to handle them.

If you mean the former, for small amounts of data without any
missings(say 100 million numeric values or less) and small n (like
n=3), it's easy and should be pretty fast just to produce lagged
columns and use pmax rowwise. If you mean the latter and have missing
values, it may be considerably more difficult.

However, offering anything more seems pointless until you have
adequately specified what you want. Reproducible data and code for a
start.

Cheers,
Bert

On Thu, Oct 28, 2010 at 9:27 AM, Jason Kwok jayk...@gmail.com wrote:
 I'm having trouble returning a rolling n period highest value for a data
 set.  For each day I want to calculate the highest value over the last 3
 days.  I am using the following packages: zoo, xts, quantmod and TTR.

 Thanks, Jason

           GLD.Close
 2010-10-01    128.91
 2010-10-04    128.46
 2010-10-05    130.99
 2010-10-06    131.81
 2010-10-07    130.37
 2010-10-08    131.66
 2010-10-11    132.29
 2010-10-12    131.96
 2010-10-13    134.07
 2010-10-14    134.75
 2010-10-15    133.68
 2010-10-18    134.28
 2010-10-19    130.11
 2010-10-20    131.32
 2010-10-21    129.47
 2010-10-22    129.73
 2010-10-25    130.85
 2010-10-26    130.88
 2010-10-27    129.52


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




-- 
Bert Gunter
Genentech Nonclinical Biostatistics

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] overloading the generic primitive functions + and [

2010-10-28 Thread Hadley Wickham
 Note how S3 methods are dispatched only by reference to the first
 argument (on the left of the operator). I think S4 beats this by
 having signatures that can dispatch depending on both arguments.

That's somewhat of a simplification for primitive binary operators. R
actually looks up the method for both input classes, and returns a
error if they are different.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
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] ggplot2: facet_grid with only one level does not display the graph with the facet_grid level in title

2010-10-28 Thread Matthew Pettis
Hi All,

Here is the code that I'll be referring to:

p - ggplot(wastran.data, aes(PER_KEY, EVENTS))
(p - p +
facet_grid( pool.short ~ .) +
stat_summary(aes(y=EVENTS), fun.y = sum, geom=line) +
opts(axis.text.x = theme_text(angle = 90, hjust=1), title=Events
(15min.) vs. Time: Facet pool, strip.text.y = theme_text())
)


Now, depending on preceding parameters, the 'pool.short' factor variable in
'wastran.data' can have one distinct factor level or it can have more than
one.  When 'pool.short' has more than one factor level, the graph performs
as I expect, with multiple rows of graphs with the value of the 'pool.short'
variable displayed on the right-hand side of the graph.  When 'pool.short'
has only one factor level, the value is NOT displayed on the right-hand
side.  However, I'd still like it displayed, even though it has only one
value.

Can someone tell me how to tweak this code to make it still display when it
has only 1 factor level?  If this code is unclear, I will be happy to take
some time and generate an artificial but reproducible self-contained
example.  I left in the stat_summary layer in this code in case it is
interfering with the desired output (but I suspect is is superfluous, but I
am not confident enough to say that with absolute certainty).

Thanks,
Matt

[[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] lattice key subtitle

2010-10-28 Thread Deepayan Sarkar
On Tue, Oct 26, 2010 at 2:49 AM, Alexandru Dumitrescu
alexandru.dumitre...@gmail.com wrote:
 Hello everybody,
 Is there a way to add a subtitle to a lattice key?

None specifically for that purpose, but latticeExtra does have a
mergedTrellisLegendGrob() function that may help:

mylegend -
mergedTrellisLegendGrob(list(fun = draw.key,
 args = list(key = simpleKey(month.name[1:3],
 title = Months))),
list(fun = grid::textGrob,
 args = list(subtitle)),
vertical = TRUE)

xyplot(1 ~ 1,
   legend = list(top = list(fun = mylegend)))

mergedTrellisLegendGrob() was written as a helper function for
c.trellis(), but the plan is to eventually make it a bit more general
tool for combining legends.

-Deepayan

 It is important form me that the subtitle must be linked to the key
 because those graphs are produced on a daily temporal scale,
 and the numbers of  rectangles from the key may be different from day to
 day.

 Thank you,
 Alexandru Dumitrescu

        [[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] RGTK2 - Entry Point not found

2010-10-28 Thread Michael Lawrence
2010/10/28 W Eryk Wolski wewol...@gmail.com

 Failed to load RGtk2 dynamic library, attempting to install it.
 trying URL '
 http://downloads.sourceforge.net/gladewin32/gtk-2.12.9-win32-2.exe'
 Content type 'application/x-msdownload' length 7378984 bytes (7.0 Mb)

 I run the complete setup of GTK .
 Hence, I assume Version 2.12.9 is installed on my box.

 My path variable starts with:
 %GTK_BASEPATH%\bin;


 Any other ideas?


It may be that you have some other cairo DLL in your PATH that is somehow
conflicting with the one installed with GTK+...




 2010/10/28 £ukasz Rêc³awowicz lukasz.reclawow...@gmail.com:
  The stable version of RGtk2 requires GTK version 2.8.0 or higher (and
 its
  dependencies).
 
  --
  Mi³ego dnia
 
 
 
 
 



 --
 Witold Eryk Wolski

 Heidmark str 5
 D-28329 Bremen
 tel.: 04215261837

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

2010-10-28 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
 Sent: Thursday, October 28, 2010 9:20 AM
 To: Michael D
 Cc: r-help@r-project.org
 Subject: Re: [R] runtime on ising model
 
 
 On Oct 28, 2010, at 11:52 AM, Michael D wrote:
 
  Mike, I'm not sure what you mean about removing foo but I 
 think the  
  method
  is sound in diagnosing a program issue and the results speak for  
  themselves.
 
  I did invert my if statement at the suggestion of a CS professor  
  (who also
  suggested recoding in C, but I'm in an applied math program and  
  haven't had
  the time to take programming courses, which i know would be helpful)
 
  Anyway, with the statement as:
 
  if( !(k %in% c(10^4,10^5,10^6,10^7)) ){
  #do nothing
  } else {
  q - q+1
  Out[[q]] - M
  }
 
  run times were back to around 20 minutes.

Did that one change really make a difference?
R does not evaluate anything in the if or else
clauses of an if statement before evaluating
the condition.
 
 Have you tried replacing all of those 10^x operations with their  
 integer equivalents, c(1L, 10L, 100L)? Each time through  
 the loop you are unnecessarily calling the ^ function 4 times. You  
 could also omit the last one. 10^7,  during testing since M at the  
 last iteration (k=10^7) would be the final value and you could just  
 assign the state of M at the end. So we have eliminated 4*10^7  
 unnecessary ^ calls and 10^7 unnecessary comparisons. (The CS  
 professor is perhaps used to having the C compiler do all 
 thinking of  
 this sort for him.)

%in% is a relatively expensive function.  Use == if you
can.  E.g., compare the following 2 ways of stashing
something at times 1e4, 1e5, and 1e6:

  system.time({z - integer()
for(k in seq_len(1e6))
   if(k %in% set) z[length(z)+1]-k
print(z)})
[1]   1  10 100
   user  system elapsed
 46.790   0.023  46.844

 system.time({z - integer()
   nextCheckPoint - 10^4
   for(k in seq_len(1e6))
   if( k == nextCheckPoint ) {
   nextCheckPoint - nextCheckPoint * 10
   z[length(z)+1]-k
   }
   print(z)})
[1]   1  10 100
   user  system elapsed
  4.529   0.013   4.545

With such a large number of iterations it pays to
remove unneeded function calls in arithmetic expressions.
R does not optimize them out - it is up to you to
do that.  E.g.,

   system.time(for(i in seq_len(1e6)) sign(pi)*(-1))
 user  system elapsed
6.802   0.014   6.818
   system.time(for(i in seq_len(1e6)) -sign(pi))
 user  system elapsed
3.896   0.011   3.911

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
 -- 
 David
 
  So as best I can tell something
  happens in the if statement causing the computer to work 
 ahead, as the
  professor suggests. I'm no expert on R (and have no desire to try  
  looking at
  the R source code (it would only confuse me)) but if anyone 
 can offer
  guidance on how the if statement works (Does R try to work ahead?  
  Under what
  conditions does it try to work ahead so I can try to exploit this
  behavior) I would greatly appreciate it.
  If it would require too much knowledge of the computer system to  
  understand
  I doubt I would be able to make use of it, but maybe someone else  
  could
  benefit.
 
  On Tue, Oct 26, 2010 at 3:24 PM, Mike Marchywka  
  marchy...@hotmail.comwrote:
 
  
  Date: Tue, 26 Oct 2010 12:53:14 -0400
  From: mike...@gmail.com
  To: j...@bitwrit.com.au
  CC: r-help@r-project.org
  Subject: Re: [R] runtime on ising model
 
  I have an update on where the issue is coming from.
 
  I commented out the code for pos[k+1] - M[i,j] and the if  
  statement
  for
  time = 10^4, 10^5, 10^6, 10^7 and the storage and everything ran
  fast(er).
  Next I added back in the pos statements and still 
 runtimes were  
  good
  (around 20 minutes).
 
  So I'm left with something is causing problems in:
 
  I haven't looked at this since some passing interest in magnetics
  decades ago, something about 8-tracks and cassettes, but you have
  to be careful with conclusions like  I removed foo and problem
  went away therefore problem was foo. Performance issues are often
  caused by memory, not CPU limitations. Removing anything with a big
  memory footprint could speed things up. IO can be a real 
 bottleneck.
  If you are talking about things on minute timescales, look at task
  manager and see if you are even CPU limited. Look for page faults
  or IO etc. If you really need performance and have a task which
  is relatively simple, don't ignore c++ as a way to generate data
  points and then import these into R for analysis.
 
  In short, just because you are focusing on math it doesn't mean
  the computer is limited by that.
 
 
 
  ## Store state at time 10^4, 

[R] R shp(ESRI) point patterns and marks

2010-10-28 Thread Gary Nobles

I have a point dataset (ESRI shp file)
each point has an associated weight (grams)
These are the weights of animal bones recovered from an archaeological
excavation
I am trying to import the shp file and then do a density plot of the weight
data, so:

#Import shp file
library(spatstat)
library(maptools)
library(sp)

S - readShapePoints(flint.shp)
SP - as(S, SpatialPoints)
P - as(SP, ppp)

So that brings in the shp file but I want to assign the marks(m) so I can do
something like:

plot(density(P, 10))

But based on the weights (grams (not spatial weighting))

Can anyone help?

Thanks

Gary
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-shp-ESRI-point-patterns-and-marks-tp3017683p3017683.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] Control of axis limits in multiple panel lattice plots

2010-10-28 Thread Deepayan Sarkar
On Wed, Oct 27, 2010 at 6:45 AM, Peter Davenport pwdavenp...@gmail.com wrote:
 I've found the solution to this in an old post of Deepayan's:

 lattice.options(axis.padding = list(numeric=0))

Or

xyplot(a~b|c,data=test.df, scales = list(axs = i))

-Deepayan


 Best,
 Peter

 On 27 October 2010 09:28, Peter Davenport pwdavenp...@gmail.com wrote:
 Unwanted space (padding?) is introduced at the extremes of the x and y
 axes of my lattice plots.
 I've tried defining the scales using xlim, scale and num.limits in
 x.scale.components, but haven't succeded in getting overriding the
 introduction of extra space.
 Here's the problem:

 test.df-data.frame(a=runif(100,0,1),b=c(runif(50,0,1),runif(50,0,2)),c=c(rep(c(A,B),c(50,50

 1) Space appears when I plot multiple panels:
        xyplot(a~b|c,data=test.df)

 2) I can get rid of the space by explicitly defining scales (shown for
 x axis)...
        xyplot(a~b|c,data=test.df
              ,scale=list(x=list(limits=c(0,2),at=seq(0,2,0.5)))
              )

 3) ...but not when relation=free:
        xyplot(a~b|c,data=test.df
              
 ,scale=list(x=list(relation=free,limits=list(c(0,1),c(0,2)),at=seq(0,2,0.5)))
              )

 Peter Davenport


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

2010-10-28 Thread Changbin Du
Hi, Dear Community,

Several days ago, I received one email about the online svm course in R, I
try to find it. Can someone forward the information to me.

Thanks!


-- 
Sincerely,
Changbin
--

[[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] GBM and Extracting the Model

2010-10-28 Thread Jeff
Hi all,

I have found a couple posts on this topic but could not (yet) find an
answer. Is there a way to extract the model (trees and weights) from
the GBM package in order to program the prediction in a non R
environment (SQL database)? The constraint of not using R is based on
production requirements of the institution.

Any help or pointers would be appreciated - GBM is providing fantastic
results but need a way to put it into a production environment.

Thanks!

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


Re: [R] Returning highs and lows in R

2010-10-28 Thread Jason Kwok
Thanks for the help.

I'm looking to calculate rolling max and means for the last 3 observations
in my data including AND not including the current observation.  I'm not
sure how to offset the observations used.

For the 3 period max, I would like to return the max value over the last 3
observations not including today.  When I use the rollapply function to take
the max, it will look look back 1 observation, take the current observation
and look forward 1 observation.  I would like to return look back
observations 1-3 and return the max.

 merge(xx,rollapply(xx,3,max))
   GLD.Close GLD.Close.1
2010-04-01110.26  NA
2010-04-05110.89  111.03
2010-04-06111.03  112.49
2010-04-07112.49  112.65
2010-04-08112.65  113.64
2010-04-09113.64  113.64
2010-04-12113.01  113.64
2010-04-13112.69  113.03
2010-04-14113.03  113.65
2010-04-15113.65  113.65
2010-04-16111.24  113.65
2010-04-19111.15  111.46
2010-04-20111.46  112.31
2010-04-21112.31  112.31
2010-04-22111.84  113.19
2010-04-23113.19  113.19
2010-04-26112.75  114.63
2010-04-27114.63  114.63
2010-04-28114.31  114.63
2010-04-29114.28  115.36
2010-04-30115.36  NA


On Thu, Oct 28, 2010 at 12:45 PM, Bert Gunter gunter.ber...@gene.comwrote:

 Jason:

 Please read AND FOLLOW the posting guide on how to ask clear
 questions. Here, you need to more carefully define what you mean by
 the last 3 days. Do you mean:(a) the last 3 values in the series
 (including or excluding the present one?) or the last 3 calendar days
 -- e.g. for 10-05, only 10-05 and 10-04, since 10-01 is not within the
 last 3 calendar days.Also, do you have missing values, and, if so, how
 do you want to handle them.

 If you mean the former, for small amounts of data without any
 missings(say 100 million numeric values or less) and small n (like
 n=3), it's easy and should be pretty fast just to produce lagged
 columns and use pmax rowwise. If you mean the latter and have missing
 values, it may be considerably more difficult.

 However, offering anything more seems pointless until you have
 adequately specified what you want. Reproducible data and code for a
 start.

 Cheers,
 Bert

 On Thu, Oct 28, 2010 at 9:27 AM, Jason Kwok jayk...@gmail.com wrote:
  I'm having trouble returning a rolling n period highest value for a data
  set.  For each day I want to calculate the highest value over the last 3
  days.  I am using the following packages: zoo, xts, quantmod and TTR.
 
  Thanks, Jason
 
GLD.Close
  2010-10-01128.91
  2010-10-04128.46
  2010-10-05130.99
  2010-10-06131.81
  2010-10-07130.37
  2010-10-08131.66
  2010-10-11132.29
  2010-10-12131.96
  2010-10-13134.07
  2010-10-14134.75
  2010-10-15133.68
  2010-10-18134.28
  2010-10-19130.11
  2010-10-20131.32
  2010-10-21129.47
  2010-10-22129.73
  2010-10-25130.85
  2010-10-26130.88
  2010-10-27129.52
 
 
 [[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.
 



 --
 Bert Gunter
 Genentech Nonclinical Biostatistics


[[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] adding environment variables

2010-10-28 Thread Henrique Dallazuanna
Take a look in ?Sys.setenv



On Thu, Oct 28, 2010 at 12:21 PM, Robert M. Flight rfligh...@gmail.comwrote:

 Hi All,

 I am developing a package that requires information about the location
 of a set of files that will be used often in the calculations. In my
 current version, I define the location in the main file that calls all
 the subfunctions. This works fine when you are installing from source,
 but will not work so well if I want people to be able to install
 binary versions of the package. Therefore, I think the best way to
 encode the information would be through the use of an environment
 variable, that could then be read by Sys.getenv(VARIABLE) when the
 function is called.

 In the help, I found a few different ways to set environment
 variables, but the easiest way (from my reading anyways) seemed to be
 by creating the file Renviron.site in the R_HOME/etc directory and
 adding the variable there. I am interested in opinions from the list,
 or other suggestions on how to do this.

 For those who are interested, the package does a lot of parsing of
 KEGG KGML files, and to speed up calculations I offer advice that they
 should download a copy of the KGML directory for their organism to
 their local machine, and I want the package to know where those files
 are at runtime.

 Thanks in advance,

 -Robert

 Robert M. Flight, Ph.D.
 University of Louisville Bioinformatics Laboratory
 University of Louisville
 Louisville, KY

 PH 502-852-0467
 EM robert.fli...@louisville.edu
 EM rfligh...@gmail.com

 Williams and Holland's Law:
If enough data is collected, anything may be proven by
 statistical methods.

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




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

[[alternative HTML version deleted]]

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


Re: [R] runtime on ising model

2010-10-28 Thread David Winsemius


On Oct 28, 2010, at 12:20 PM, David Winsemius wrote:



On Oct 28, 2010, at 11:52 AM, Michael D wrote:

Mike, I'm not sure what you mean about removing foo but I think the  
method
is sound in diagnosing a program issue and the results speak for  
themselves.


I did invert my if statement at the suggestion of a CS professor  
(who also
suggested recoding in C, but I'm in an applied math program and  
haven't had

the time to take programming courses, which i know would be helpful)

Anyway, with the statement as:

if( !(k %in% c(10^4,10^5,10^6,10^7)) ){
#do nothing
} else {
q - q+1
Out[[q]] - M
}

run times were back to around 20 minutes.


Have you tried replacing all of those 10^x operations with their  
integer equivalents, c(1L, 10L, 100L)? Each time through  
the loop you are unnecessarily calling the ^ function 4 times. You  
could also omit the last one. 10^7,  during testing since M at the  
last iteration (k=10^7) would be the final value and you could just  
assign the state of M at the end. So we have eliminated 4*10^7  
unnecessary ^ calls and 10^7 unnecessary comparisons. (The CS  
professor is perhaps used to having the C compiler do all thinking  
of this sort for him.)


Bill Dunlap's suggestion to use == instead of %in% cut the time to  
1/3 of what it had been even after the pre-calculation of the integer  
values( which only improved the looping times by 30%). The combination  
of the two with:

 if (k ==1L|k==10L|k==100L ) { ... }

... resulted in an improvement by a factor or 12.006/2.523 or 475% for  
the interim checking and printing operation using Bill's test suite.




--
David


So as best I can tell something
happens in the if statement causing the computer to work ahead, as  
the
professor suggests. I'm no expert on R (and have no desire to try  
looking at

the R source code (it would only confuse me)) but if anyone can offer
guidance on how the if statement works (Does R try to work ahead?  
Under what

conditions does it try to work ahead so I can try to exploit this
behavior) I would greatly appreciate it.
If it would require too much knowledge of the computer system to  
understand
I doubt I would be able to make use of it, but maybe someone else  
could

benefit.

On Tue, Oct 26, 2010 at 3:24 PM, Mike Marchywka marchy...@hotmail.com 
wrote:





Date: Tue, 26 Oct 2010 12:53:14 -0400
From: mike...@gmail.com
To: j...@bitwrit.com.au
CC: r-help@r-project.org
Subject: Re: [R] runtime on ising model

I have an update on where the issue is coming from.

I commented out the code for pos[k+1] - M[i,j] and the if  
statement

for

time = 10^4, 10^5, 10^6, 10^7 and the storage and everything ran

fast(er).
Next I added back in the pos statements and still runtimes were  
good

(around 20 minutes).

So I'm left with something is causing problems in:


I haven't looked at this since some passing interest in magnetics
decades ago, something about 8-tracks and cassettes, but you have
to be careful with conclusions like  I removed foo and problem
went away therefore problem was foo. Performance issues are often
caused by memory, not CPU limitations. Removing anything with a big
memory footprint could speed things up. IO can be a real bottleneck.
If you are talking about things on minute timescales, look at task
manager and see if you are even CPU limited. Look for page faults
or IO etc. If you really need performance and have a task which
is relatively simple, don't ignore c++ as a way to generate data
points and then import these into R for analysis.

In short, just because you are focusing on math it doesn't mean
the computer is limited by that.




## Store state at time 10^4, 10^5, 10^6, 10^7
if( k %in% c(10^4,10^5,10^6,10^7) ){
q - q+1
Out[[q]] - M
}

Would there be any reason R is executing the statements inside  
the if

before getting to the logical check?
Maybe R is written to hope for the best outcome (TRUE) and will  
just

throw

out its work if the logic comes up FALSE?
I guess I can always break the for loop up into four parts and  
store the

state at the end of each, but thats an unsatisfying solution to me.


Jim, I like the suggestion of just pulling one big sample, but  
since I

can
get the runtimes under 30 minutes just by removing the storage  
piece I

doubt

I would see any noticeable changes by pulling large sample vectors.

Thanks,
Michael

On Tue, Oct 26, 2010 at 6:22 AM, Jim Lemon  wrote:


On 10/26/2010 04:50 PM, Michael D wrote:

So I'm in a stochastic simulations class and I having issues  
with the

amount
of time it takes to run the Ising model.

I usually don't like to attach the code I'm running, since it  
will

probably
make me look like a fool, but I figure its the best way I can  
find any

bits
I can speed up run time.

As for the goals of the exercise:
I need the state of the system at time=1, 10k, 100k, 1mill, and  
10mill

and the percentage of vertices with positive spin at all 

Re: [R] wait for graph to finish plotting

2010-10-28 Thread news

pdf(file = ~/Dropbox/phd/results/graphs/TEST%03d.pdf)
for (dataset in 
c(breastCancer,pima,heartDisease,crx,ionosphere,votes))
{
  p - eval(parse(text=paste(dataset,Probs,sep=)))
  m - melt(t(p))
  title - titles[[dataset]]
  
filename=paste(~/Dropbox/phd/results/graphs/,dataset,Probs_barcharts.eps,sep=)
  
barchart(value~X1|X2,data=m,origin=0,layout=c(1,10),scales=list(alternating=1,tck=c(0.6,0)),ylab=Difference
 from test 
probabilities,xlab=Interval,col=c(rep(black,8),red,white,blue),main=title,ylim=c(-1,1))
}
dev.off()


Tal Galili tal.gal...@gmail.com writes:

 Could you please paste the exact code you are using? (the one with the pdf and
 dev.off, outside the loop )

 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)
 --




 On Sat, Oct 23, 2010 at 4:53 PM, n...@aleblanc.cotse.net wrote:

 David Winsemius dwinsem...@comcast.net writes:

  On Oct 22, 2010, at 12:50 PM, n...@aleblanc.cotse.net wrote:
 
  Tal Galili tal.gal...@gmail.com writes:
 
  I suspect that using dev.copy2eps Is not going to help you here.
 
  Please try again using:
 
   pdf(...)  # Check: ?pdf
   for(i in something)
   {
      plot(things)
   }
   dev.off()
 
  But give pdf() the file path.
  Make sure you can make it work with simple plots.  then check it on
  your
  situation, and let us know if it works :)
  (I had it work with very heavy plots - so I trust it will work for
  you)
 
  (p.s: please keep cc'ing the r-help list so others will know the
  stage of your
  problem, in case others would like to add more help :) )
 
  Cheers,
  Tal
 
 
  The problem is that the filename changes with each iteration of the
  loop, so I need to
  save the graph inside the loop.
  I tried this:
 
  for(...)
  {
     ...
     pdf(...)
     barplot(...)
  }
 
  but I just got a load of empty graphs.
 
  Because you failed to follow Ted directions to use dev.off()
 
  pdf() just opens the file for writing, dev.off() executes the writing
  and closes properly.
 
  --
  David.
 I just tried with dev.off() but still the same problem.
 I tried with pdf() and dev.off() inside the loop, and with them outside
 (pdf before the loop,
 and dev.off after). Same results each time: an empty pdf file.
 I am using R version 2.11.1 if this makes any difference.
 --
 aleblanc
Hi Tal,


-- 
aleblanc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Returning highs and lows in R

2010-10-28 Thread Jason Kwok
I figured out how to offset my observations by 1 period by using the
rollapply(xx,3,max,align=right), which would calculate the mean for
(current observation, obs - 1 and obs -2 ).   How would I further offset by
1 more period?

Thanks,

Jason

On Thu, Oct 28, 2010 at 1:29 PM, Jason Kwok jayk...@gmail.com wrote:

 Thanks for the help.

 I'm looking to calculate rolling max and means for the last 3 observations
 in my data including AND not including the current observation.  I'm not
 sure how to offset the observations used.

 For the 3 period max, I would like to return the max value over the last 3
 observations not including today.  When I use the rollapply function to take
 the max, it will look look back 1 observation, take the current observation
 and look forward 1 observation.  I would like to return look back
 observations 1-3 and return the max.

  merge(xx,rollapply(xx,3,max))
GLD.Close GLD.Close.1
 2010-04-01110.26  NA
 2010-04-05110.89  111.03
 2010-04-06111.03  112.49
 2010-04-07112.49  112.65
 2010-04-08112.65  113.64
 2010-04-09113.64  113.64
 2010-04-12113.01  113.64
 2010-04-13112.69  113.03
 2010-04-14113.03  113.65
 2010-04-15113.65  113.65
 2010-04-16111.24  113.65
 2010-04-19111.15  111.46
 2010-04-20111.46  112.31
 2010-04-21112.31  112.31
 2010-04-22111.84  113.19
 2010-04-23113.19  113.19
 2010-04-26112.75  114.63
 2010-04-27114.63  114.63
 2010-04-28114.31  114.63
 2010-04-29114.28  115.36
 2010-04-30115.36  NA


 On Thu, Oct 28, 2010 at 12:45 PM, Bert Gunter gunter.ber...@gene.comwrote:

 Jason:

 Please read AND FOLLOW the posting guide on how to ask clear
 questions. Here, you need to more carefully define what you mean by
 the last 3 days. Do you mean:(a) the last 3 values in the series
 (including or excluding the present one?) or the last 3 calendar days
 -- e.g. for 10-05, only 10-05 and 10-04, since 10-01 is not within the
 last 3 calendar days.Also, do you have missing values, and, if so, how
 do you want to handle them.

 If you mean the former, for small amounts of data without any
 missings(say 100 million numeric values or less) and small n (like
 n=3), it's easy and should be pretty fast just to produce lagged
 columns and use pmax rowwise. If you mean the latter and have missing
 values, it may be considerably more difficult.

 However, offering anything more seems pointless until you have
 adequately specified what you want. Reproducible data and code for a
 start.

 Cheers,
 Bert

 On Thu, Oct 28, 2010 at 9:27 AM, Jason Kwok jayk...@gmail.com wrote:
  I'm having trouble returning a rolling n period highest value for a data
  set.  For each day I want to calculate the highest value over the last 3
  days.  I am using the following packages: zoo, xts, quantmod and TTR.
 
  Thanks, Jason
 
GLD.Close
  2010-10-01128.91
  2010-10-04128.46
  2010-10-05130.99
  2010-10-06131.81
  2010-10-07130.37
  2010-10-08131.66
  2010-10-11132.29
  2010-10-12131.96
  2010-10-13134.07
  2010-10-14134.75
  2010-10-15133.68
  2010-10-18134.28
  2010-10-19130.11
  2010-10-20131.32
  2010-10-21129.47
  2010-10-22129.73
  2010-10-25130.85
  2010-10-26130.88
  2010-10-27129.52
 
 
 [[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.
 



 --
 Bert Gunter
 Genentech Nonclinical Biostatistics




[[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] Please help me about Monte Carlo Permutation

2010-10-28 Thread Łukasz Ręcławowicz
I'm not sure is this correct, but maybe you are looking for something like
this:

test-function(){
permuted.Qtot-permn(data$Qtot)
n-length(permuted.Qtot)
correlation-rep(NA,n)
for(i in 1:n){
correlation[i]-cor(data$Itot,permuted.Qtot[[i]])}
p-sum(correlation=cor(data$Qtot,data$Itot))/n
print(paste(P-value:, round(p,5)),quote=F)
}
test()

-- 
Mi³ego dnia

[[alternative HTML version deleted]]

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


[R] How to enable Arial font for postcript/pdf figure on Windows?

2010-10-28 Thread Agnès Paquet
Hi,

I need to generate some figure using the Arial font as a requirement for
PLoS.
Following their guidelines, I have converted the windows font files
arial.tff files to .afm using tff2afm (exec file from MikTeX), but when I
try to generate a postcript file, the postcript device does not recognize
the .afm files.

The code I use to test the new font is the following:

postscript(file=try.ps, horizontal=F,
onefile=F,
width=4, height=4,
family=c(C:/MyDoc/arial.afm,
C:/MyDoc/arialbd.afm,
C:/MyDoc/ariali.afm,
C:/MyDoc/arialbi.afm),
pointsize=12)
hist(rnorm(100))
dev.off()
And I get the warnings:
In postscript(file = try.ps, horizontal = F, onefile = F,  ... :
  unknown AFM entity encountered
 Is there another way to convert .tff files into .afm on Windows, or any
other way to use Arial in pdf/postcript on Windows?

Thank you very much,

Agnes

[[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] wait for graph to finish plotting

2010-10-28 Thread David Winsemius


On Oct 28, 2010, at 1:27 PM, n...@aleblanc.cotse.net wrote:



pdf(file = ~/Dropbox/phd/results/graphs/TEST%03d.pdf)
for (dataset in  
c(breastCancer,pima,heartDisease,crx,ionosphere,votes))

{
 p - eval(parse(text=paste(dataset,Probs,sep=)))
 m - melt(t(p))
 title - titles[[dataset]]
 filename=paste(~/Dropbox/phd/results/ 
graphs/,dataset,Probs_barcharts.eps,sep=)
 barchart(value~X1| 
X2 
,data 
= 
m 
,origin 
= 
0 
,layout 
=c(1,10),scales=list(alternating=1,tck=c(0.6,0)),ylab=Difference  
from test probabilities,xlab=Interval,col=c(rep(black, 
8),red,white,blue),main=title,ylim=c(-1,1))

}
dev.off()


Now you have changed plotting functions from plot and barplot over to  
barchart (a Lattice function) and were not aware of FAQ 7.22:


http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

--
David.



Tal Galili tal.gal...@gmail.com writes:

Could you please paste the exact code you are using? (the one with  
the pdf and

dev.off, outside the loop )

Contact

On Sat, Oct 23, 2010 at 4:53 PM, n...@aleblanc.cotse.net wrote:

   David Winsemius dwinsem...@comcast.net writes:


On Oct 22, 2010, at 12:50 PM, n...@aleblanc.cotse.net wrote:


Tal Galili tal.gal...@gmail.com writes:


I suspect that using dev.copy2eps Is not going to help you here.

Please try again using:

 pdf(...)  # Check: ?pdf
 for(i in something)
 {
plot(things)
 }
 dev.off()

But give pdf() the file path.
Make sure you can make it work with simple plots.  then check it  
on

your
situation, and let us know if it works :)
(I had it work with very heavy plots - so I trust it will work for
you)

(p.s: please keep cc'ing the r-help list so others will know the
stage of your
problem, in case others would like to add more help :) )

Cheers,
Tal



The problem is that the filename changes with each iteration of the
loop, so I need to
save the graph inside the loop.
I tried this:

for(...)
{
   ...
   pdf(...)
   barplot(...)
}

but I just got a load of empty graphs.


Because you failed to follow Ted directions to use dev.off()

pdf() just opens the file for writing, dev.off() executes the  
writing

and closes properly.

--
David.

   I just tried with dev.off() but still the same problem.
   I tried with pdf() and dev.off() inside the loop, and with them  
outside

   (pdf before the loop,
   and dev.off after). Same results each time: an empty pdf file.
   I am using R version 2.11.1 if this makes any difference.
   --
   aleblanc

Hi Tal,


--
aleblanc


David Winsemius, MD
West Hartford, CT

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


Re: [R] Generate random percentages and placing vectors

2010-10-28 Thread Aaron Lee
Thanks for the help!

However, for the code in #2, it seems to just randomly split up the vectors.
I would still like to keep the integrity of each vector.

For example:

if v1 = (1,2,3)
   v2 = (4,5,6)

output = (0,0,0,1,2,3,0,0,0,0,4,5,6,0,0,0,0,0,0,0,0,0,0,0,0) - which has a
specified length of 25

With v1 and v2 inserted in at random locations.

On Wed, Oct 27, 2010 at 10:25 AM, Jonathan P Daily jda...@usgs.gov wrote:


 1)
 rands - runif(5)
 rands - rands/sum(rands)*100

 2)
 # assume vectors are v1, v2, etc.
 v_all - c(v1, v2, ...)
 v_len - length(v_all)

 output - rep(0,25)
 output[sample(1:25, v_len)] - v_all

 --
 Jonathan P. Daily
 Technician - USGS Leetown Science Center
 11649 Leetown Road
 Kearneysville WV, 25430
 (304) 724-4480
 Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it.
 - Jubal Early, Firefly


  From: Aaron Lee aaron.zl@gmail.com To: r-help@r-project.org Date: 
 10/27/2010
 11:06 AM Subject: [R] Generate random percentages and placing vectors Sent
 by: r-help-boun...@r-project.org
 --



 Hello everyone,

 I have two questions:

 1.) I would like to generate random percentages that add up to 100. For
 example, if I need 5 percentages, I would obtain something like: 20, 30,
 40,
 5, 5. Is there some way to do this in R?

 2.) I would like to insert vectors of specified length into a larger vector
 of specified length randomly, and fill the gaps with zeroes. For example,
 if
 I have 3 vectors of length 3, 2, and 2 with values and I would like to
 randomly place them into a vector of length 25 made of 0's.

 Thank you in advance!

 -Aaron

 [[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


Re: [R] Returning highs and lows in R

2010-10-28 Thread Jason Kwok
I was able to get what I wanted using the lag function to offset an addition
period.

lag(rollapply(xx,3,max),-2) or lag(rollapply(xx,3,max,align=right),-1)

Thanks.

Jason


On Thu, Oct 28, 2010 at 1:49 PM, Jason Kwok jayk...@gmail.com wrote:

 I figured out how to offset my observations by 1 period by using the
 rollapply(xx,3,max,align=right), which would calculate the mean for
 (current observation, obs - 1 and obs -2 ).   How would I further offset by
 1 more period?

 Thanks,

 Jason

 On Thu, Oct 28, 2010 at 1:29 PM, Jason Kwok jayk...@gmail.com wrote:

 Thanks for the help.

 I'm looking to calculate rolling max and means for the last 3 observations
 in my data including AND not including the current observation.  I'm not
 sure how to offset the observations used.

 For the 3 period max, I would like to return the max value over the last 3
 observations not including today.  When I use the rollapply function to take
 the max, it will look look back 1 observation, take the current observation
 and look forward 1 observation.  I would like to return look back
 observations 1-3 and return the max.

  merge(xx,rollapply(xx,3,max))
GLD.Close GLD.Close.1
 2010-04-01110.26  NA
 2010-04-05110.89  111.03
 2010-04-06111.03  112.49
 2010-04-07112.49  112.65
 2010-04-08112.65  113.64
 2010-04-09113.64  113.64
 2010-04-12113.01  113.64
 2010-04-13112.69  113.03
 2010-04-14113.03  113.65
 2010-04-15113.65  113.65
 2010-04-16111.24  113.65
 2010-04-19111.15  111.46
 2010-04-20111.46  112.31
 2010-04-21112.31  112.31
 2010-04-22111.84  113.19
 2010-04-23113.19  113.19
 2010-04-26112.75  114.63
 2010-04-27114.63  114.63
 2010-04-28114.31  114.63
 2010-04-29114.28  115.36
 2010-04-30115.36  NA


 On Thu, Oct 28, 2010 at 12:45 PM, Bert Gunter gunter.ber...@gene.comwrote:

 Jason:

 Please read AND FOLLOW the posting guide on how to ask clear
 questions. Here, you need to more carefully define what you mean by
 the last 3 days. Do you mean:(a) the last 3 values in the series
 (including or excluding the present one?) or the last 3 calendar days
 -- e.g. for 10-05, only 10-05 and 10-04, since 10-01 is not within the
 last 3 calendar days.Also, do you have missing values, and, if so, how
 do you want to handle them.

 If you mean the former, for small amounts of data without any
 missings(say 100 million numeric values or less) and small n (like
 n=3), it's easy and should be pretty fast just to produce lagged
 columns and use pmax rowwise. If you mean the latter and have missing
 values, it may be considerably more difficult.

 However, offering anything more seems pointless until you have
 adequately specified what you want. Reproducible data and code for a
 start.

 Cheers,
 Bert

 On Thu, Oct 28, 2010 at 9:27 AM, Jason Kwok jayk...@gmail.com wrote:
  I'm having trouble returning a rolling n period highest value for a
 data
  set.  For each day I want to calculate the highest value over the last
 3
  days.  I am using the following packages: zoo, xts, quantmod and TTR.
 
  Thanks, Jason
 
GLD.Close
  2010-10-01128.91
  2010-10-04128.46
  2010-10-05130.99
  2010-10-06131.81
  2010-10-07130.37
  2010-10-08131.66
  2010-10-11132.29
  2010-10-12131.96
  2010-10-13134.07
  2010-10-14134.75
  2010-10-15133.68
  2010-10-18134.28
  2010-10-19130.11
  2010-10-20131.32
  2010-10-21129.47
  2010-10-22129.73
  2010-10-25130.85
  2010-10-26130.88
  2010-10-27129.52
 
 
 [[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.
 



 --
 Bert Gunter
 Genentech Nonclinical Biostatistics





[[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] RWeka, java.lang.NullPointerException

2010-10-28 Thread Markus Loecher
Dear all,
I have trained a J48 classifier in RWeka but when I try to predict on new
data I get the following exceptions:

fit - J48(...)
yNew - predict(fit, x, type=probability);

Error in .jcall(RWekaInterfaces, [D, distributionForInstances,
.jcast(classifier,  :
  java.lang.NullPointerException

What could be the cause of this ?
I am using R version 2.10.0 on a Linux server.

Thanks,
Markus

[[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 with help()

2010-10-28 Thread claudia tebaldi
Hi all

Just this morning I upgraded to R 2.12.0  (for Mac OS X 10.6.4).
All went well until I needed to run a help() or help.search() in my session,
which I'm running within Emacs (ESS 5.3.7).
Say I need help with the command 'density'. When I type

help(density)
or
?density

the ESS help buffer opens, it is titled *help[R](density)* but it contains
only a couple of lines saying, e.g.,

Error in help(density, htmlhelp = FALSE) :
  unused argument(s) (htmlhelp = FALSE)

This is a problem only running R within emacs. The command help() works fine
if I run R at the command line in  a terminal window or if I use the
stand-alone R application.

Thank you in advance

Claudia

-- 
Claudia Tebaldi
Research Scientist, Climate Central
http://www.climatecentral.org

[[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] help with help()

2010-10-28 Thread Marc Schwartz
On Oct 28, 2010, at 1:20 PM, claudia tebaldi wrote:

 Hi all
 
 Just this morning I upgraded to R 2.12.0  (for Mac OS X 10.6.4).
 All went well until I needed to run a help() or help.search() in my session,
 which I'm running within Emacs (ESS 5.3.7).
 Say I need help with the command 'density'. When I type
 
 help(density)
 or
 ?density
 
 the ESS help buffer opens, it is titled *help[R](density)* but it contains
 only a couple of lines saying, e.g.,
 
 Error in help(density, htmlhelp = FALSE) :
  unused argument(s) (htmlhelp = FALSE)
 
 This is a problem only running R within emacs. The command help() works fine
 if I run R at the command line in  a terminal window or if I use the
 stand-alone R application.
 
 Thank you in advance
 
 Claudia


Put the following in your ~/.emacs file:

(setq inferior-ess-r-help-command help(\%s\, help_type=\html\)\n)


You might also want to update to ESS 5.11:

http://ess.r-project.org/index.php?Section=download

or consider using Vincent Goulet's pre-packaged Emacs 23/ESS install:

  http://vgoulet.act.ulaval.ca/en/ressources/emacs/mac


HTH,

Marc Schwartz

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


Re: [R] runtime on ising model

2010-10-28 Thread Mike Marchywka








 Date: Thu, 28 Oct 2010 09:58:40 -0700
 From: wdun...@tibco.com
 To: dwinsem...@comcast.net; mike...@gmail.com
 CC: r-help@r-project.org
 Subject: Re: [R] runtime on ising model

  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
  Sent: Thursday, October 28, 2010 9:20 AM
  To: Michael D
  Cc: r-help@r-project.org
  Subject: Re: [R] runtime on ising model
 
 
  On Oct 28, 2010, at 11:52 AM, Michael D wrote:
 
   Mike, I'm not sure what you mean about removing foo but I
  think the
   method
   is sound in diagnosing a program issue and the results speak for
   themselves.

Agreed on first part but not second- empirical debugging rarely 
produces compelling results in isolation. As a collection
of symptons fine but not conclusive- if you learn c++ you will
find out about all kinds of things like memory corruption that
never make sense :) Here, the big concern is issues with memory
as you never determined to be CPU limited although based on
others comments you likely are in any case.

  
   I did invert my if statement at the suggestion of a CS professor
   (who also
   suggested recoding in C, but I'm in an applied math program and
   haven't had
   the time to take programming courses, which i know would be helpful)
  
   Anyway, with the statement as:
  
   if( !(k %in% c(10^4,10^5,10^6,10^7)) ){
   #do nothing
   } else {
   q - q+1
   Out[[q]] - M
   }
  
   run times were back to around 20 minutes.

 Did that one change really make a difference?
 R does not evaluate anything in the if or else
 clauses of an if statement before evaluating
 the condition.

What is at issue here? That is, the OP claimed inverting polarity
sped things up, suggesting that the branch mattered. AFAIK he
never actually proved which branch was taken. This could
imply many things or nothing: one branch may be slow, or cause
a page fault, or the test may fail fast but succed slowly( testing
huge array for equality for example) .



  Have you tried replacing all of those 10^x operations with their
  integer equivalents, c(1L, 10L, 100L)? Each time through
  the loop you are unnecessarily calling the ^ function 4 times. You
  could also omit the last one. 10^7, during testing since M at the
  last iteration (k=10^7) would be the final value and you could just
  assign the state of M at the end. So we have eliminated 4*10^7
  unnecessary ^ calls and 10^7 unnecessary comparisons. (The CS
  professor is perhaps used to having the C compiler do all
  thinking of
  this sort for him.)

 %in% is a relatively expensive function. Use == if you
 can. E.g., compare the following 2 ways of stashing
 something at times 1e4, 1e5, and 1e6:

  system.time({z - integer()
 for(k in seq_len(1e6))
 if(k %in% set) z[length(z)+1]-k
 print(z)})
 [1] 1 10 100
 user system elapsed
 46.790 0.023 46.844

  system.time({z - integer()
 nextCheckPoint - 10^4
 for(k in seq_len(1e6))
 if( k == nextCheckPoint ) {
 nextCheckPoint - nextCheckPoint * 10
 z[length(z)+1]-k
 }
 print(z)})
 [1] 1 10 100
 user system elapsed
 4.529 0.013 4.545

 With such a large number of iterations it pays to
 remove unneeded function calls in arithmetic expressions.
 R does not optimize them out - it is up to you to
 do that. E.g.,

  system.time(for(i in seq_len(1e6)) sign(pi)*(-1))
 user system elapsed
 6.802 0.014 6.818
  system.time(for(i in seq_len(1e6)) -sign(pi))
 user system elapsed
 3.896 0.011 3.911

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 
  --
  David
 
   So as best I can tell something
   happens in the if statement causing the computer to work
  ahead, as the
   professor suggests. I'm no expert on R (and have no desire to try
   looking at
   the R source code (it would only confuse me)) but if anyone
  can offer
   guidance on how the if statement works (Does R try to work ahead?
   Under what
   conditions does it try to work ahead so I can try to exploit this
   behavior) I would greatly appreciate it.
   If it would require too much knowledge of the computer system to
   understand
   I doubt I would be able to make use of it, but maybe someone else
   could
   benefit.
  
   On Tue, Oct 26, 2010 at 3:24 PM, Mike Marchywka
   wrote:
  
   
   Date: Tue, 26 Oct 2010 12:53:14 -0400
   From: mike...@gmail.com
   To: j...@bitwrit.com.au
   CC: r-help@r-project.org
   Subject: Re: [R] runtime on ising model
  
   I have an update on where the issue is coming from.
  
   I commented out the code for pos[k+1] - M[i,j] and the if
   statement
   for
   time = 10^4, 10^5, 10^6, 10^7 and the storage and everything ran
   fast(er).
   Next I added back in the pos statements and still
  runtimes were
   good
   (around 20 minutes).
  
   So I'm left with something is causing problems in:
  
   I haven't looked at this since some passing interest in 

Re: [R] help with help()

2010-10-28 Thread Marc Schwartz

On Oct 28, 2010, at 1:32 PM, Marc Schwartz wrote:

 On Oct 28, 2010, at 1:20 PM, claudia tebaldi wrote:
 
 Hi all
 
 Just this morning I upgraded to R 2.12.0  (for Mac OS X 10.6.4).
 All went well until I needed to run a help() or help.search() in my session,
 which I'm running within Emacs (ESS 5.3.7).
 Say I need help with the command 'density'. When I type
 
 help(density)
 or
 ?density
 
 the ESS help buffer opens, it is titled *help[R](density)* but it contains
 only a couple of lines saying, e.g.,
 
 Error in help(density, htmlhelp = FALSE) :
 unused argument(s) (htmlhelp = FALSE)
 
 This is a problem only running R within emacs. The command help() works fine
 if I run R at the command line in  a terminal window or if I use the
 stand-alone R application.
 
 Thank you in advance
 
 Claudia
 
 
 Put the following in your ~/.emacs file:
 
 (setq inferior-ess-r-help-command help(\%s\, help_type=\html\)\n)
 
 
 You might also want to update to ESS 5.11:
 
 http://ess.r-project.org/index.php?Section=download
 
 or consider using Vincent Goulet's pre-packaged Emacs 23/ESS install:
 
  http://vgoulet.act.ulaval.ca/en/ressources/emacs/mac


One quick additional note. The above .emacs inclusion requires ESS 5.5 or 
greater. So you will definitely need to update. 5.3.7 is over two years old.

Marc

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


Re: [R] help with help()

2010-10-28 Thread Joshua Wiley
Hi,

Is it possible to upgrade your version of Emacs and ESS (ESS is up to 5.11)?

The official website for ESS is:
http://ess.r-project.org/

Vincent Goulet also maintains a nice distribution of the latest Emacs
bundled with AUCTeX and ESS for Mac at:
http://vgoulet.act.ulaval.ca/en/ressources/emacs/mac

It is very easy to install :)

I am not sure that there is an htmlhelp argument anymore.

Cheers,

Josh


On Thu, Oct 28, 2010 at 11:20 AM, claudia tebaldi
claudia.teba...@gmail.com wrote:
 Hi all

 Just this morning I upgraded to R 2.12.0  (for Mac OS X 10.6.4).
 All went well until I needed to run a help() or help.search() in my session,
 which I'm running within Emacs (ESS 5.3.7).
 Say I need help with the command 'density'. When I type

 help(density)
 or
 ?density

 the ESS help buffer opens, it is titled *help[R](density)* but it contains
 only a couple of lines saying, e.g.,

 Error in help(density, htmlhelp = FALSE) :
  unused argument(s) (htmlhelp = FALSE)

 This is a problem only running R within emacs. The command help() works fine
 if I run R at the command line in  a terminal window or if I use the
 stand-alone R application.

 Thank you in advance

 Claudia

 --
 Claudia Tebaldi
 Research Scientist, Climate Central
 http://www.climatecentral.org

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] help with help()

2010-10-28 Thread Erik Iverson



claudia tebaldi wrote:

Hi all

Just this morning I upgraded to R 2.12.0  (for Mac OS X 10.6.4).
All went well until I needed to run a help() or help.search() in my session,
which I'm running within Emacs (ESS 5.3.7).


That's very old version of ESS, I have no problems with 2.12.0 with ESS
5.11 on Emacs 23.2 at home.

Also, there is an ESS-help mailing list for ESS questions, usually
very responsive and all the developers read it.


Say I need help with the command 'density'. When I type

help(density)
or
?density

the ESS help buffer opens, it is titled *help[R](density)* but it contains
only a couple of lines saying, e.g.,

Error in help(density, htmlhelp = FALSE) :
  unused argument(s) (htmlhelp = FALSE)

This is a problem only running R within emacs. The command help() works fine
if I run R at the command line in  a terminal window or if I use the
stand-alone R application.

Thank you in advance

Claudia



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

2010-10-28 Thread Albyn Jones
I have worked with seismic data measured at 100hz, and had no trouble
locating events in long records (several times the size of your
dataset).  20 minutes is high frequency?  what kind of waves are
these?  what is the wavelength? some details would help.

albyn

On Thu, Oct 28, 2010 at 05:00:10AM -0700, dpender wrote:
 
 I am looking to use R in order to determine the number of extreme events for
 a high frequency (20 minutes) dataset of wave heights that spans 25 years
 (657,432) data points.
 
 I require the number, spacing and duration of the extreme events as an
 output.
 
 I have briefly used the clusters function in evd package.
 
 Can anyone suggest a more appropriate package to use for such a large
 dataset?
 
 Thanks,
 
 Doug
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Clustering-tp3017056p3017056.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.
 

-- 
Albyn Jones
Reed College
jo...@reed.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] scatterplot3d; scaling point symbols to depth of graph

2010-10-28 Thread Uwe Ligges
It's a bug (since I did not expect people to change the size of the 
symbols vectorized).

Will provide a fix tomorrow.

Uwe




On 28.10.2010 11:28, John Coulthard wrote:


Hi

I'm trying to scale the point symbols on a 3d plot so that the ones at the 
front are larger than the ones at the back.  I'm trying to give the image some 
perspective.

Given this code...

library(scatterplot3d)
data=array(c(0,5,9), c(3,3))
scatterplot3d(data, pch=19, cex.symbols=10-data[,2], 
color=c(red,blue,black));

data



  [,1] [,2] [,3]


[1,]000


[2,]555


[3,]999



which gives a vector for  cex.symbols as

10-data[,2]


[1] 10  5  1


  I would expect the largest point to be the red one at the origin but
the image I get has the black symbol at co-ords 9,9,9 as the largest and red at 
0,0,0 the smallest.

Then if I do...

data=array(c(0,9,5), c(3,3))
data

  [,1] [,2] [,3]
[1,]000
[2,]999
[3,]555

scatterplot3d(data, pch=19, cex.symbols=10-data[,2], 
color=c(red,blue,black));
10-data[,2]

[1] 10  1  5

I'd expect the position and size of the points to be the same but the colour of 
blue and black to be exchanged.  But the size of the points also changes such 
that the red point at 0,0,0 is the medium size and the black at 5,5,5 is the 
smallest.

So is it possible to get the points described by each row in data to be scaled 
by the values in data[,2]?

Many thanks

John




sessionInfo()

R version 2.11.1 (2010-05-31)
i386-redhat-linux-gnu

locale:
  [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C
  [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8
  [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=en_US.utf8   LC_NAME=C
  [9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] scatterplot3d_0.3-30

loaded via a namespace (and not attached):
[1] tools_2.11.1


[[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] Generate random percentages and placing vectors

2010-10-28 Thread Henrique Dallazuanna
Try this:

out - rep(0, 25)
out[embed(seq(out), 3)[sample(1:(length(out) - 2), 2),]] - rev(rbind(v1,
v2))

On Thu, Oct 28, 2010 at 3:59 PM, Aaron Lee aaron.zl@gmail.com wrote:

 Thanks for the help!

 However, for the code in #2, it seems to just randomly split up the
 vectors.
 I would still like to keep the integrity of each vector.

 For example:

 if v1 = (1,2,3)
   v2 = (4,5,6)

 output = (0,0,0,1,2,3,0,0,0,0,4,5,6,0,0,0,0,0,0,0,0,0,0,0,0) - which has a
 specified length of 25

 With v1 and v2 inserted in at random locations.

 On Wed, Oct 27, 2010 at 10:25 AM, Jonathan P Daily jda...@usgs.gov
 wrote:

 
  1)
  rands - runif(5)
  rands - rands/sum(rands)*100
 
  2)
  # assume vectors are v1, v2, etc.
  v_all - c(v1, v2, ...)
  v_len - length(v_all)
 
  output - rep(0,25)
  output[sample(1:25, v_len)] - v_all
 
  --
  Jonathan P. Daily
  Technician - USGS Leetown Science Center
  11649 Leetown Road
  Kearneysville WV, 25430
  (304) 724-4480
  Is the room still a room when its empty? Does the room,
  the thing itself have purpose? Or do we, what's the word... imbue it.
  - Jubal Early, Firefly
 
 
   From: Aaron Lee aaron.zl@gmail.com To: r-help@r-project.org Date:
 10/27/2010
  11:06 AM Subject: [R] Generate random percentages and placing vectors
 Sent
  by: r-help-boun...@r-project.org
  --
 
 
 
  Hello everyone,
 
  I have two questions:
 
  1.) I would like to generate random percentages that add up to 100. For
  example, if I need 5 percentages, I would obtain something like: 20, 30,
  40,
  5, 5. Is there some way to do this in R?
 
  2.) I would like to insert vectors of specified length into a larger
 vector
  of specified length randomly, and fill the gaps with zeroes. For example,
  if
  I have 3 vectors of length 3, 2, and 2 with values and I would like to
  randomly place them into a vector of length 25 made of 0's.
 
  Thank you in advance!
 
  -Aaron
 
  [[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
 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.




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

[[alternative HTML version deleted]]

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


[R] How do I install (download) a package with my own package?

2010-10-28 Thread Ian Schiller
I want to create my own package in which some of my functions depend on 
functions already existing in another package that is not part of the default 
library (i.e. when you install R for the first time, you need to download that 
package to access the functions.)

Is there a way to bundle this existing package with the package I will create 
so that one doesn't have to install my package and then the package in which 
some of my functions depend on?

Thanks!

Ian

[[alternative HTML version deleted]]

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


  1   2   >