[R] arrangement of crowded labels

2009-05-20 Thread Thomas Zumbrunn
Dear R users

I'm looking for algorithms that assist in spreading out crowded labels, e.g. 
labels of points in a scatter plot, in order to obtain a nicer visual 
appearance and better legibility. 

I'm probably just stuck because I didn't find the right key words for a 
successful search on the R websites or in the mailing list archives.

Any hints are appreciated.

Thomas Zumbrunn
University of Basel

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


Re: [R] arrangement of crowded labels

2009-05-20 Thread Richard . Cotton
 I'm looking for algorithms that assist in spreading out crowded labels, 
e.g. 
 labels of points in a scatter plot, in order to obtain a nicer visual 
 appearance and better legibility. 
 
 I'm probably just stuck because I didn't find the right key words for a 
 successful search on the R websites or in the mailing list archives.

Try thigmophobe.labels in the plotrix package.

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

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

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


Re: [R] nlrwr package. Error when fitting the optimal Box-Cox transformation with two variables

2009-05-20 Thread F.Tusell
El mar, 19-05-2009 a las 17:17 +0200, Ikerne del Valle escribió:
 
   Dear all:
 
   I'm trying to fit the optimal Box-Cox 
 transformation related to nls (see the code 
 below) for the demand of money data in Green (3th 
 Edition) but in the last step R gives the next 
 error message.
   Error en 
 `[.data.frame`(eval(object$data), , 
 as.character(formula(object)[[2]])[2]) :
undefined columns selected.
   ¿Any idea to solve the problem?
   Thanks in advance,
 
 
 library(nlrwr)
 r-c(4.50,4.19,5.16,5.87,5.95,4.88,4.50,6.44,7.83,6.25,5.50,5.46,7.46,10.28,11.77,13.42,11.02,8.50,8.80,7.69)
 M-c(480.00,524.30,566.30,589.50,628.20,712.80,805.20,861.00,908.40,1023.10,1163.60,1286.60,1388.90,1497.90,1631.40,1794.40,1954.90,2188.80,2371.70,2563.60)
 Y-c(2208.30,2271.40,2365.60,2423.30,2416.20,2484.80,2608.50,2744.10,2729.30,2695.00,2826.70,2958.60,3115.20,3192.40,3187.10,3248.80,3166.00,3277.70,3492.00,3573.50)
 money-data.frame(r,M,Y)
 attach(money)
 ols1-lm(log(M)~log(r)+log(Y))
 output1-summary(ols1)
 coef1-ols1$coefficients
 a1-coef1[[1]]
 b11-coef1[[2]]
 b21-coef1[[3]]
 money.m1-nls(log(M)~a+b*r^g+c*Y^g,data=money,start=list(a=a1,b=b11,g=1,c=b21))
 summary(money.m1)
 money.m2-boxcox(money.m1)
 
 
 
   Prof. Ikerne del Valle Erkiaga
   Department of Applied Economics V
   Faculty of Economic and Business Sciences
   University of the Basque Country
   Avda. Lehendakari Agirre, Nº 83
   48015 Bilbao (Bizkaia) Spain
 

 Ikerne,

 Inside boxcox.nls, the variable log(M) is searched in dataframe 
 money and not found. Indeed, it is a little redundant to take logs
 and then search a Box-Cox transformation --which gives the log
 when lambda is zero. 

 If you really want to do that, you might define a new variable
 logM and include that in your money dataframe, then rewrite
 the nls() call as:

 money.m1 - nls(logM ~ a + b ... etc.

 Best, ft.

-- 
Fernando TUSELLe-mail:
Departamento de Econometría y Estadística   fernando.tus...@ehu.es 
Facultad de CC.EE. y Empresariales Tel:   (+34)94.601.3733
Universidad del País Vasco Secr:  (+34)94.601.3740
Avenida Lendakari Aguirre, 83  Fax:   (+34)94.601.3754
E-48015 BILBAO  (Spain)  http://www.et.bs.ehu.es/~etptupaf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Running multiple versions of Rserve on a Linux system

2009-05-20 Thread Harsh
Hi useRs,

I would like to know how to run two versions of Rserve on a Linux system.

I am using the old JRE client of Rserve which requires me to use Rserve
version 0.4-3. I am also using the new REngine API to connect to Rserve
version 0.6.
I would like to run both these Rserve versions on a Linux system. Is it
necessary that I install two versions of R, and install these two Rserve
versions in each R installation?

I am aware that one can use multiple config files and provide different port
numbers, but that would run the same version of Rserve with different
settings.

- Install the two Rserve versions in the same R installation. Must I provide
an alternate library location for the other Rserve version to be installed
into?
- Install two R versions and install the two Rserve versions in each R
installation?


Any help in this regard will be much appreciated.

Thanks
Harsh Singhal

[[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] Package Inline under windows

2009-05-20 Thread Duncan Murdoch

_ wrote:

Hi all,
I installed the package inline (windows-version) but can not compile any 
code, I alway get an error message
ERROR(s) during compilation : source code errors or compiler 
configuration errors!


Unfornutanely there is no description where the package finds a 
c-compiler nor where so set the configuration.


Using the linux version, everything works.
  


There's nothing special about it:  just follow the instructions in 
Appendix E of the R Installation and Administration manual for setting 
up the tools.


Duncan Murdoch

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


[R] Functions returning functions

2009-05-20 Thread Paulo Grahl
Dear All:

I have a question regarding the behavior of functions.
Say I define a function that returns another function :
A - function(parameters) {
 # calculations w/ parameters returning 'y'
 tmpf - function(x) { # function of 'y' }
 return(tmpf)
}

The value of the parameters are stored in an environment local to the
function. Then I call
x- something
B-A(x)

When R executes this last statement,  does it perform all the
calculations inside function A again (i.e., all the calculations that
yield 'y')
 or the value of 'y' is already stored in the function's local environment ?

Many thanks.
Paulo Gustavo Grahl, CFA

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


Re: [R] *** POSSIBLE SPAM *** Functions returning functions

2009-05-20 Thread Romain Francois

Paulo Grahl wrote:

Dear All:

I have a question regarding the behavior of functions.
Say I define a function that returns another function :
A - function(parameters) {
 # calculations w/ parameters returning 'y'
 tmpf - function(x) { # function of 'y' }
 return(tmpf)
}

The value of the parameters are stored in an environment local to the
function. Then I call
x- something
B-A(x)

When R executes this last statement,  does it perform all the
calculations inside function A again 

no, see this:

 f - function( x = 3){
+function( ){}
+ }
 g - f()
 ls.str( environment(g) )
x :  num 3
 h - f(6)
 ls.str( environment(h) )
x :  num 6
 ls.str( environment(g) )
x :  num 3

See also colorRampPalette which uses this feature:

 colorRampPalette
function (colors, ...)
{
   ramp - colorRamp(colors, ...)
   function(n) {
   x - ramp(seq.int(0, 1, length.out = n))
   rgb(x[, 1], x[, 2], x[, 3], maxColorValue = 255)
   }
}
environment: namespace:grDevices
 pal - colorRampPalette( c(blue, white, red) )
 pal
function (n)
{
   x - ramp(seq.int(0, 1, length.out = n))
   rgb(x[, 1], x[, 2], x[, 3], maxColorValue = 255)
}
environment: 0x99aba4c
 ls.str( environment( pal ) )
colors :  chr [1:3] blue white red
ramp : function (x) 


(i.e., all the calculations that
yield 'y')
 or the value of 'y' is already stored in the function's local environment ?

Many thanks.
Paulo Gustavo Grahl, CFA
  


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

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


[R] SEM:Standard error of std.coef estimates?

2009-05-20 Thread BdeGroot

Hi,

I am currently working with the sem package in R, to create pathway
diagrams. Id like to use the standardized path coeffcients. To get these, I
use std.coef. However, using this yields only the standardized coefficients,
but does not give me the standard error. Does someone know how to get
std.coef to show the standard error of the standardized path coefficients as
well?


Thanks,
Bastiaan


PS: 
When I use std.coef, all I get is this:

std.coef(path.model.SSI4)
  Std. Estimate   
par1 par1  0.39499  com_veg --- tempm
par2 par2  0.35231  SNutBili --- tempm   
par3 par3 -0.68170  S_SSI4 --- tempm 
par4 par4 -0.39145  com_veg --- Wdeficit 
par5 par5 -0.60025  SNutBili --- Wdeficit
par6 par6 -0.20562  S_SSI4 --- Wdeficit  
par7 par7  0.14871  SNutBili --- com_veg 
par8 par8  0.14905  S_SSI4 --- com_veg   
par9 par9 -0.39164  S_SSI4 --- SNutBili  
-- 
View this message in context: 
http://www.nabble.com/SEM%3AStandard-error-of-std.coef-estimates--tp23633227p23633227.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] Too large a data set to be handled by R?

2009-05-20 Thread jim holtman
If your 1500 X 2 matrix is all numeric, it should take up about 240MB of
memory.  That should easily fit within the 2GB of your laptop and still
leave room for several copies that might arise during the processing.
Exactly what are you going to be doing with the data?  A lot will depend on
the functions/procedures that you will be calling, or the type of
transformations you might be doing.

On Tue, May 19, 2009 at 11:59 PM, tsunhin wong thjw...@gmail.com wrote:

 Dear R users,

 I have been using a dynamic data extraction from raw files strategy at
 the moment, but it takes a long long time.
 In order to save time, I am planning to generate a data set of size
 1500 x 2 with each data point a 9-digit decimal number, in order
 to save my time.
 I know R is limited to 2^31-1 and that my data set is not going to
 exceed this limit. But my laptop only has 2 Gb and is running 32-bit
 Windows / XP or Vista.

 I ran into R memory problem issue before. Please let me know your
 opinion according to your experience.
 Thanks a lot!

 - John

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




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] how to calculate means of matrix elements

2009-05-20 Thread Gabor Grothendieck
In that case use a modification of Jim's solution:

a - array(cbind(mat1, mat2, mat3), c(3, 3, 3))
apply(a, 1:2, mean, na.rm = TRUE)


On Tue, May 19, 2009 at 8:49 AM, dxc13 dx...@health.state.ny.us wrote:

 Easy enough.  What if some of the matrix elements contained missing values?
 Then how could you still calculate the means?  Example code below:
 mat1 - matrix(c(1,2,3,4,5,NA,7,8,9),3,3)
 mat2 - matrix(c(NA,6,1,9,0,5,8,2,7),3,3)
 mat3 - matrix(c(5,9,1,8,NA,3,7,2,4),3,3)


 Gabor Grothendieck wrote:

 Try this:

 (mat1 + mat2 + mat3) / 3

 On Mon, May 18, 2009 at 8:40 PM, dxc13 dx...@health.state.ny.us wrote:

 useR's,
 I have several matrices of size 4x4 that I want to calculate means of
 their
 respective positions with.  For example, consider I have 3 matrices given
 by
 the code:
 mat1 - matrix(sample(1:20,16,replace=T),4,4)
 mat2 - matrix(sample(-5:15,16,replace=T),4,4)
 mat3 - matrix(sample(5:25,16,replace=T),4,4)

 The result I want is one matrix of size 4x4 in which position [1,1] is
 the
 mean of position [1,1] of the given three matrices.  The same goes for
 all
 other positions of the matrix.  If these three matrices are given in
 separate text files, how can I write code that will get this result I
 need?

 Thanks in advance,
 dxc13
 --
 View this message in context:
 http://www.nabble.com/how-to-calculate-means-of-matrix-elements-tp23607694p23607694.html
 Sent from the R help mailing list archive at Nabble.com.

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


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



 --
 View this message in context: 
 http://www.nabble.com/how-to-calculate-means-of-matrix-elements-tp23607694p23615755.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] Functions returning functions

2009-05-20 Thread Wacek Kusnierczyk
Paulo Grahl wrote:
 Dear All:

 I have a question regarding the behavior of functions.
 Say I define a function that returns another function :
 A - function(parameters) {
  # calculations w/ parameters returning 'y'
  tmpf - function(x) { # function of 'y' }
  return(tmpf)
 }

 The value of the parameters are stored in an environment local to the
 function. 

consider this example:

foo = function(a, b)
   function(c)
  if (c) a else b

x = 1
y = 2
bar = foo(x, y)

bar(TRUE)
# 1
x = 0
bar(TRUE)
# 1, not 0

y = 0
bar(FALSE)
# 0, not 2

vQ

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


[R] Where to find a changelog for the survival package

2009-05-20 Thread Heinz Tuechler

Dear All,

since some days I try to use the versions 2.35-4 of the survival 
package instead of versions 2.31, I had installed until now. Several 
changes in print.survfit, plot.survfit and seemingly in the structure 
of ratetabels effect some of my syntax files.

Is there somewhere a documentation of these changes, besides the code itself?

Thanks in advance,
Heinz

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


Re: [R] Functions returning functions

2009-05-20 Thread Gabor Grothendieck
On Wed, May 20, 2009 at 7:48 AM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
 Paulo Grahl wrote:
 Dear All:

 I have a question regarding the behavior of functions.
 Say I define a function that returns another function :
 A - function(parameters) {
      # calculations w/ parameters returning 'y'
      tmpf - function(x) { # function of 'y' }
      return(tmpf)
 }

 The value of the parameters are stored in an environment local to the
 function.

 consider this example:

    foo = function(a, b)
       function(c)
          if (c) a else b

    x = 1
    y = 2
    bar = foo(x, y)

    bar(TRUE)
    # 1
    x = 0
    bar(TRUE)
    # 1, not 0

    y = 0
    bar(FALSE)
    # 0, not 2


The last one is due to lazy evaluation.  Try
repeating it with this variation:

   foo2 = function(a, b) {
  force(a); force(b)
  function(c) if (c) a else b
   }

which forces a and b to be evaluated right away.

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


Re: [R] Functions returning functions

2009-05-20 Thread Romain Francois

Romain Francois wrote:

Paulo Grahl wrote:

Dear All:

I have a question regarding the behavior of functions.
Say I define a function that returns another function :
A - function(parameters) {
 # calculations w/ parameters returning 'y'
 tmpf - function(x) { # function of 'y' }
 return(tmpf)
}

The value of the parameters are stored in an environment local to the
function. Then I call
x- something
B-A(x)

When R executes this last statement,  does it perform all the
calculations inside function A again 

no

... but there are ways around it

f - function( x = 3 ){
   # y will be get a value the first time
   # the function created below is called
   delayedAssign( y, {
   cat( \nevaluating `y` right now\n )
   x + 5
   } )
  
   # z will get a new value each time the function

   # created below is called
   makeActiveBinding( z, function( data ){
   if( missing(data) ){
   cat( \nevaluating `z` right now\n )
   rnorm(x)
   }
   }, environment() )
  function( ){
 list( y, z )
  }
}

 h - f()
 h()

evaluating `y` right now

evaluating `z` right now
[[1]]
[1] 8

[[2]]
[1]  1.0991189 -1.1033016 -0.5410733

 h()

evaluating `z` right now
[[1]]
[1] 8

[[2]]
[1]  0.7102276 -0.6371956 -0.7703179

 environment(h)[[z]]

evaluating `z` right now
[1] -0.6713595  2.2006114  0.9335674
 environment(h)[[z]]

evaluating `z` right now
[1]  0.1243523  0.6178176 -0.9043380


see this:

 f - function( x = 3){
+function( ){}
+ }
 g - f()
 ls.str( environment(g) )
x :  num 3
 h - f(6)
 ls.str( environment(h) )
x :  num 6
 ls.str( environment(g) )
x :  num 3

See also colorRampPalette which uses this feature:

 colorRampPalette
function (colors, ...)
{
   ramp - colorRamp(colors, ...)
   function(n) {
   x - ramp(seq.int(0, 1, length.out = n))
   rgb(x[, 1], x[, 2], x[, 3], maxColorValue = 255)
   }
}
environment: namespace:grDevices
 pal - colorRampPalette( c(blue, white, red) )
 pal
function (n)
{
   x - ramp(seq.int(0, 1, length.out = n))
   rgb(x[, 1], x[, 2], x[, 3], maxColorValue = 255)
}
environment: 0x99aba4c
 ls.str( environment( pal ) )
colors :  chr [1:3] blue white red
ramp : function (x)

(i.e., all the calculations that
yield 'y')
 or the value of 'y' is already stored in the function's local 
environment ?


Many thanks.
Paulo Gustavo Grahl, CFA
  





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

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


[R] turning off specific types of warnings

2009-05-20 Thread Eleni Rapsomaniki
Dear R users,

I have a long function that among other things uses the survest function from 
the Design package. This function generates the warning:

In survest.cph (...)
  S.E. and confidence intervals are approximate except at predictor means.
Use cph(...,x=T,y=T) (and don't use linear.predictors=) for better estimates.

I would like to turn this specific warning off, as it makes it difficult to 
detect other (potentially more crucial) warnings generated by other parts of my 
code.

Is there a way to do this?

Eleni Rapsomaniki

Research Associate
Strangeways Research Laboratory
Department of Public Health and Primary Care

University of Cambridge
 

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


Re: [R] turning off specific types of warnings

2009-05-20 Thread jim holtman
?suppressWarnings

On Wed, May 20, 2009 at 8:10 AM, Eleni Rapsomaniki
er...@medschl.cam.ac.ukwrote:

 Dear R users,

 I have a long function that among other things uses the survest function
 from the Design package. This function generates the warning:

 In survest.cph (...)
  S.E. and confidence intervals are approximate except at predictor means.
 Use cph(...,x=T,y=T) (and don't use linear.predictors=) for better
 estimates.

 I would like to turn this specific warning off, as it makes it difficult to
 detect other (potentially more crucial) warnings generated by other parts of
 my code.

 Is there a way to do this?

 Eleni Rapsomaniki

 Research Associate
 Strangeways Research Laboratory
 Department of Public Health and Primary Care

 University of Cambridge


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




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] turning off specific types of warnings

2009-05-20 Thread Romain Francois

jim holtman wrote:

?suppressWarnings
  
Note that this removes __all__ warnings, if you only want to remove 
specific warnings, you can adapt suppressWarnings like this:


 h - function(w) if( any(grepl(ouch, w))) 
invokeRestart(muffleWarning)

 withCallingHandlers( warning(ouch), warning = h )
 withCallingHandlers( warning(something else), warning = h )
Warning message:
In withCallingHandlers(warning(something else), warning = h) :
 something else

Maybe it would make sense to extend suppressWarnings in this direction

Romain


On Wed, May 20, 2009 at 8:10 AM, Eleni Rapsomaniki
er...@medschl.cam.ac.ukwrote:

  

Dear R users,

I have a long function that among other things uses the survest function
from the Design package. This function generates the warning:

In survest.cph (...)
 S.E. and confidence intervals are approximate except at predictor means.
Use cph(...,x=T,y=T) (and don't use linear.predictors=) for better
estimates.

I would like to turn this specific warning off, as it makes it difficult to
detect other (potentially more crucial) warnings generated by other parts of
my code.

Is there a way to do this?

Eleni Rapsomaniki

Research Associate
Strangeways Research Laboratory
Department of Public Health and Primary Care

University of Cambridge




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

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


Re: [R] Functions returning functions

2009-05-20 Thread Paulo Grahl
Thanks a lot !
regards,
Paulo Gustavo Grahl, CFA


On Wed, May 20, 2009 at 8:31 AM, Romain Francois
romain.franc...@dbmail.com wrote:
 Paulo Grahl wrote:

 Dear All:

 I have a question regarding the behavior of functions.
 Say I define a function that returns another function :
 A - function(parameters) {
     # calculations w/ parameters returning 'y'
     tmpf - function(x) { # function of 'y' }
     return(tmpf)
 }

 The value of the parameters are stored in an environment local to the
 function. Then I call
 x- something
 B-A(x)

 When R executes this last statement,  does it perform all the
 calculations inside function A again

 no, see this:

 f - function( x = 3){
 +    function( ){}
 + }
 g - f()
 ls.str( environment(g) )
 x :  num 3
 h - f(6)
 ls.str( environment(h) )
 x :  num 6
 ls.str( environment(g) )
 x :  num 3

 See also colorRampPalette which uses this feature:

 colorRampPalette
 function (colors, ...)
 {
   ramp - colorRamp(colors, ...)
   function(n) {
       x - ramp(seq.int(0, 1, length.out = n))
       rgb(x[, 1], x[, 2], x[, 3], maxColorValue = 255)
   }
 }
 environment: namespace:grDevices
 pal - colorRampPalette( c(blue, white, red) )
 pal
 function (n)
 {
   x - ramp(seq.int(0, 1, length.out = n))
   rgb(x[, 1], x[, 2], x[, 3], maxColorValue = 255)
 }
 environment: 0x99aba4c
 ls.str( environment( pal ) )
 colors :  chr [1:3] blue white red
 ramp : function (x)

 (i.e., all the calculations that
 yield 'y')
  or the value of 'y' is already stored in the function's local environment
 ?

 Many thanks.
 Paulo Gustavo Grahl, CFA


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




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


[R] how to merge replicate spots

2009-05-20 Thread Barbara Cegielska

Hi,
Does anybody know how to merge replicate spots in R Bioconductor? I use 
home-made spotted arrays and every probe is printed in triplicate. I 
normalize my data using limma package and I do not know how to get mean 
from these three replicates.


Regards,
Barbara Cegielska

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


Re: [R] Extracting correlation in a nlme model

2009-05-20 Thread Christine A.

Hello,

for calculation of intraclass correlation coefficient for a simple Random
Intercept model, the function ICC1.lme() in the package psychometric can
be applied.

Best regards, 
Christine Adrion






Kenneth Roy Cabrera Torres wrote:
 
 Hi R users:
 
 Is there a function to obtain the correlation within groups
 from this very simple lme model?
 
 modeloMx1
 Linear mixed-effects model fit by REML
   Data: barrag 
   Log-restricted-likelihood: -70.92739
   Fixed: fza_tension ~ 1 
 (Intercept) 
90.86667 
 
 Random effects:
  Formula: ~1 | molde
 (Intercept) Residual
 StdDev:2.610052 2.412176
 
 Number of Observations: 30
 Number of Groups: 3 
 
 I want to obtain \rho = \sigma_b^2 / (\sigma_b^2 + \sigma^2)
 
 I know that I obtain \sigma_b^2 and \sigma^2 with
 
 VarCorr(modeloMx1)
 
 molde = pdLogChol(1) 
 Variance StdDev  
 (Intercept) 6.812374 2.610052
 Residual5.818593 2.412176
 
 But, I want to know if I can obtain
 \rho = 6.8123/(6.8123 + 5.8185) = 0.53934 straightforward.
 
 Thank you for you help.
 
 Kenneth
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


-
Christine Adrion, Dipl.-Stat., MPH
 
Ludwig-Maximilians-Universitaet Muenchen
IBE – Institut für Medizinische Informations-
verarbeitung, Biometrie und Epidemiologie 
Marchioninistr. 15
81377 Muenchen
GERMANY
 
Tel.:  +49 (0)89 7095-4483
eMail: adr...@ibe.med.uni-muenchen.de  
Internet: http://ibe.web.med.uni-muenchen.de
-- 
View this message in context: 
http://www.nabble.com/Extracting-correlation-in-a-nlme-model-tp23628854p23632075.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] Least-square support vector machines regression!

2009-05-20 Thread Thomas Terhoeven-Urselmans
Dear Max,

thanks for your valuable comment. I assume that you used the function  
for regression - not classification.

I use Mac OS X plattform (version 10.5.6). The R version is 2.8.1 (I  
prefer to update to 2.9.1 not 2.9.0). The kernlab package version is  
0.9-8.

The x and y-input into LSSVM regression can be reproduced by:
x-- 
matrix 
(data 
= 
rnorm 
(n 
= 
12800 
,mean 
=0.0053,sd=0.0146),nrow=100,ncol=128,dimnames=list(c(1:100),c(1:128)));
y-rnorm(n=100,mean=0.7958,sd=0.1900);

The function is:
test 
 
_lssvm 
(test 
,test.ref,scale=F,type=regression,kernel=rbfdot,kpar=list(sigma=5));

The error message is:
Error in if (n != dim(y)[1]) stop(Labels y and data x dont match) :
   argument is of length zero.

This error message does not make sense to me. The R documentation for  
the lssvm function states that y can be a vector. The dimension of a  
vector is always NULL. Thus, the check function in the error message  
[if(n !=dim(y)[1]) stop] does not add up for me.

Regards,

Thomas

On 14 May 2009, at 15:33, Max Kuhn wrote:

 To make things easier (using only two optimization parameters and not
 loosing performance) I wanted to use LS SVM regression  
 (lssvm{kernlab}). But
 it looks to me that it is not yet implemented. At least I got error
 messages, which I could not find a solution for (Error in if (n ! 
 _dim(y)[1]
 stop (Labels y and data x dont match).

 I've used the lssvm function in kernlab without issue.

 You should follow the posting guide and provide a reproducible example
 so that there is a possibility of answering your question. Plus, what
 versions etc.

 Max



[[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] Plot data from table with column and row names

2009-05-20 Thread Matt Bishop

Dear All
Sorry for what appears a trivial matter - I'm new to R and am stumbling
ahead.

I have a table of numerical data (36 rows by 12 columns) such as below:

   GM1  GM2  GM3  GM4  GM5 ...etc GM12
Run1  1  2  1   2  3   ...
Run2  2  1  3   2  1   ...
...
Run36 2  1  1  1  1  

I would like to plot simple line graphs of some of the runs or all 36 to
compare together but I can't even get a plot to have the GM1-GM12 on the
x-axis and the numerical y -axis with the scores (1 to 3).
I think that using Plot(x) is not correct for this type of data.
Help would be appreciated - I'm sure I'm missing something...
Matt

-- 
View this message in context: 
http://www.nabble.com/Plot-data-from-table-with-column-and-row-names-tp23632750p23632750.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] Mixed Models

2009-05-20 Thread Alan O'Loughlin
Hello,
 
I've run a Proc Mixed function on a set of data in SAS.
 
The data was a result of an experiment that measured % viability over time and 
I wanted to compare a Large sample lets say 50L to a small sample say 5L. And 
compare the % viability between the 2 sizes to see if I get the same answer 
there are 8 samples of each size and the same 8 samples are tested every day 
over 10 days (day 0 - day 10).
 
Now, Given that the same bottles are repeatedly tested each day – then doing an 
ANOVA without taking account of the repeated measures nature of your experiment 
could lead to erroneous conclusions. The problem is that when I test a bottle 
11 times over so many days – each recorded value from that bottle cannot be 
considered statistically independent from the others. E.g. bottle A, day 0 – 
the percentage recorded is ‘high’ – then it is more likely to be quite high on 
day 2 than to be quite low – hence the two measures are not statistically 
independent.There are ANOVA models that can take account of repeated measures – 
I have used the SAS procedure Proc Mixed for this. And I have produced a 
significant P-Value for size and not for time so I've shown there is an effect 
of time but not for size. I have also produced confidence intervals for each 
day over time how can I output the data in SAS to be read into R then plot a 
graph of the confidence intervals??Also is there a way of doing this whole 
analysis in R?Kind Regards,Al

[[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] Least-square support vector machines regression!

2009-05-20 Thread Max Kuhn
Thomas,

 thanks for your valuable comment. I assume that you used the function for
 regression - not classification.

I have been using it for classification and that is the issue. Looking
at ?lssvm, it has regression is currently not supported in the
details for the type argument.

Max

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


Re: [R] Where to find a changelog for the survival package

2009-05-20 Thread Richard . Cotton
 since some days I try to use the versions 2.35-4 of the survival 
 package instead of versions 2.31, I had installed until now. Several 
 changes in print.survfit, plot.survfit and seemingly in the structure 
 of ratetabels effect some of my syntax files.
 Is there somewhere a documentation of these changes, besides the code 
itself?

It's in the repository on R-Forge.  The latest version is here:
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/survival/Changelog.09?rev=11234root=survivalview=markup

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

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

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


[R] efficiency when processing ordered data frames

2009-05-20 Thread Brigid Mooney
Hoping for a little insight into how to make sure I have R running as
efficiently as possible.

Suppose I have a data frame, A, with n rows and m columns, where col1
is a date time stamp.  Also suppose that when this data is imported
(from a csv or SQL), that the data is already sorted such that the
time stamp in col1 is in ascending (or descending) order.

If I then wanted to select only the rows of A where col1 = a certain
time, I am wondering if R has to read through the entirety of col1 to
select those rows (all n of them).  Is it possible for R to recognize
(or somehow be told) that these rows are already in order, thus
allowing the computation could be completed in ~log(n) row reads
instead?

Thanks!

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


[R] How to google for R stuff?

2009-05-20 Thread Kynn Jones
Hi!  I'm new to R programming, though I've been programming in other
languages for years.

One thing I find most frustrating about R is how difficult it is to use
Google (or any other search tool) to look for answers to my R-related
questions.  With languages with even slightly more distinctive names like
Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
language in the query is enough to ensure that the top hits are relevant.
 But this trick does not work for R, because the letter R appears by itself
in so many pages, that the chaff overwhelms the wheat, so to speak.

So I'm curious to learn what strategies R users have found to get around
this annoyance.

TIA!

KJ

[[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] Plot data from table with column and row names

2009-05-20 Thread Gabor Grothendieck
Here are a few possibilities:


Lines - GM1  GM2  GM3  GM4  GM5
Run1  1  2  1   2  3
Run2  2  1  3   2  1
Run3 2  1  1  1  1

DF - read.table(textConnection(Lines), header = TRUE)
long - as.data.frame.table(as.matrix(DF))
head(long)

with(long, balloonplot(Var1, Var2, Freq))

library(lattice)
dotplot(Freq ~ Var1, long, group = Var2, type = l)


On Wed, May 20, 2009 at 6:21 AM, Matt Bishop m.bis...@ed.ac.uk wrote:

 Dear All
 Sorry for what appears a trivial matter - I'm new to R and am stumbling
 ahead.

 I have a table of numerical data (36 rows by 12 columns) such as below:

       GM1  GM2  GM3  GM4  GM5 ...etc GM12
 Run1  1      2      1       2      3   ...
 Run2  2      1      3       2      1   ...
 ...
 Run36 2      1      1      1      1

 I would like to plot simple line graphs of some of the runs or all 36 to
 compare together but I can't even get a plot to have the GM1-GM12 on the
 x-axis and the numerical y -axis with the scores (1 to 3).
 I think that using Plot(x) is not correct for this type of data.
 Help would be appreciated - I'm sure I'm missing something...
 Matt

 --
 View this message in context: 
 http://www.nabble.com/Plot-data-from-table-with-column-and-row-names-tp23632750p23632750.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] Functions returning functions

2009-05-20 Thread Stavros Macrakis
On Wed, May 20, 2009 at 7:21 AM, Paulo Grahl pgr...@gmail.com wrote:

 A - function(parameters) {
 # calculations w/ parameters returning 'y'
 tmpf - function(x) { # function of 'y' }
 return(tmpf)
 }

 The value of the parameters are stored in an environment local to the
 function. Then I call
 x- something
 B-A(x)

 When R executes this last statement,  does it perform all the
 calculations inside function A again (i.e., all the calculations that
 yield 'y')
  or the value of 'y' is already stored in the function's local environment
 ?


 A - function(q) {
print(calculating y)
y - q+1
function(x) print(paste(value of x:,x,value of y:,y))
 }
 A(5)
[1] calculating y
function(x) print(paste(value of x:,x,value of y:,y))
environment: 0x07abe2a8
 A(5)(4)
[1] calculating y
[1] value of x: 4 value of y: 6
 A5 - A(5)
[1] calculating y
 A5(4)
[1] value of x: 4 value of y: 6


[[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] Too large a data set to be handled by R?

2009-05-20 Thread Stavros Macrakis
On Tue, May 19, 2009 at 11:59 PM, tsunhin wong thjw...@gmail.com wrote:

 In order to save time, I am planning to generate a data set of size
 1500 x 2 with each data point a 9-digit decimal number, in order
 to save my time.
 I know R is limited to 2^31-1 and that my data set is not going to
 exceed this limit. But my laptop only has 2 Gb and is running 32-bit
 Windows / XP or Vista.


32-bit R on Windows XP with 2GB RAM has no problem with a matrix this size
(not just integers, but also numerics):

 system.time(mm - matrix( numeric(1500 * 2), 1500, 2))
   user  system elapsed
   0.590.231.87
 system.time(nn - matrix( runif(1500 * 2), 1500, 2))
   user  system elapsed
   2.660.64   13.39
 system.time(oo - nn + 3)
   user  system elapsed
   0.240.170.41
 system.time(pp - oo - oo)
   user  system elapsed
   0.150.130.28

[[alternative HTML version deleted]]

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Jonathan Baron
See http://finzi.psych.upenn.edu/
for many options for searching for R stuff.

If you type R into Google, the R home page usually comes up first.  I
was amazed when this happened 9 years ago.

And now, if I type R lmer into Google (without the quotes), a whole
bunch of relevant stuff comes up, although it isn't so systematically
arranged as with the other search options.

Jon

On 05/20/09 09:02, Kynn Jones wrote:
 Hi!  I'm new to R programming, though I've been programming in other
 languages for years.
 
 One thing I find most frustrating about R is how difficult it is to use
 Google (or any other search tool) to look for answers to my R-related
 questions.  With languages with even slightly more distinctive names like
 Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
 language in the query is enough to ensure that the top hits are relevant.
  But this trick does not work for R, because the letter R appears by itself
 in so many pages, that the chaff overwhelms the wheat, so to speak.
 
 So I'm curious to learn what strategies R users have found to get around
 this annoyance.
 
 TIA!
 
 KJ
 
   [[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.

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Editor: Judgment and Decision Making (http://journal.sjdm.org)

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


[R] Error with regsubset in leaps package - vcov and all.best option (plus calculating VIFs for subsets)

2009-05-20 Thread lara harrup (IAH-P)


Hi all


I am hoping this is just a minor problem, I am trying to implement a best 
subsets regression procedure on some ecological datasets using the regsubsets 
function in the leaps package. The dataset contains 43 predictor variables plus 
the response (logcount) all in a dataframe called environment. I am 
implementing it as follows:

library(leaps)


subsets-regsubsets(logcount~.,data=environment,nvmax=10,nbest=2,really.big=FALSE,method=exhaustive)

###the subset regression runs fine when i run it as above and i can get all the 
usual summaries

###The problem comes when i try and get it to output the variance convariance 
matric by adding the option vcov=TRUE
##When I do that i get the following:

subsets-regsubsets(logcount~.,data=environment,nvmax=10,nbest=2,really.big=FALSE,method=exhaustive,vcov=TRUE)

Error in model.frame.default(data = environment, vcov = TRUE, formula = 
logcount~  : 
  variable lengths differ (found for '(vcov)')

 traceback()
6: model.frame.default(data = environment, vcov = TRUE, formula = logcount~ 
   .)
5: model.frame(data = environment, vcov = TRUE, formula = logcount~ .)
4: eval(expr, envir, enclos)
3: eval(mm, sys.frame(sys.parent()))
2: regsubsets.formula(logcount~ ., data = environment, nvmax = 10, really.big = 
TRUE, 
   method = exhaustive, nbest = 5, vcov = TRUE)
1: regsubsets(obs ~ ., data = environment, nvmax = 10, really.big = TRUE, 
   method = exhaustive, nbest = 5, vcov = TRUE)

I get the same error when i try and add the all.best=TRUE option (as ideally i 
would like it to report the fits of all the subsets).

All the predictor variables and the response are the same length (143) so not 
sure if I am misinterpreting the error or have misspecified the regsubsets?

I was wanting to get the variance - covariance matrix as I believe I need it to 
calculate the Variance Inflation Factors (VIFs) for each of the models reported 
by regsubsets. As I want to exclude any models that exhibit multicollinerarity 
from later analysis, I am hoping to select say the 'best' 10 models and 
bootstrap them to find out more about how they perform.

Or am I going about this all the wrong way? is there away to calulate vifs from 
regsubsets or pass it directly to something that calculates them e.g. VIF in 
the car package?

Any help will be most appreciated, many thanks in advance

Lara

lara.har...@bbsrc.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] How to google for R stuff?

2009-05-20 Thread Ian Fiske

www.rseek.org is the best solution to this that I have found.

Ian



kynn wrote:
 
 Hi!  I'm new to R programming, though I've been programming in other
 languages for years.
 
 One thing I find most frustrating about R is how difficult it is to use
 Google (or any other search tool) to look for answers to my R-related
 questions.  With languages with even slightly more distinctive names like
 Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
 language in the query is enough to ensure that the top hits are relevant.
  But this trick does not work for R, because the letter R appears by
 itself
 in so many pages, that the chaff overwhelms the wheat, so to speak.
 
 So I'm curious to learn what strategies R users have found to get around
 this annoyance.
 
 TIA!
 
 KJ
 
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-google-for-R-stuff--tp23635068p23635296.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] efficiency when processing ordered data frames

2009-05-20 Thread jim holtman
How much is it currently costing you in time to do the selection process?
Is it having a large impact on your program? Is it the part that is really
consuming the overall time?  What is your concern in this area? Here is the
timing that it take so select from 10M values those that are less than a
specific value.  This takes less than 0.2 seconds:

 x - runif(1e7)
 system.time(y - x  .5)
   user  system elapsed
   0.150.050.20
 x - sort(x)
 system.time(y - x  .5)
   user  system elapsed
   0.110.030.14



On Wed, May 20, 2009 at 8:54 AM, Brigid Mooney bkmoo...@gmail.com wrote:

 Hoping for a little insight into how to make sure I have R running as
 efficiently as possible.

 Suppose I have a data frame, A, with n rows and m columns, where col1
 is a date time stamp.  Also suppose that when this data is imported
 (from a csv or SQL), that the data is already sorted such that the
 time stamp in col1 is in ascending (or descending) order.

 If I then wanted to select only the rows of A where col1 = a certain
 time, I am wondering if R has to read through the entirety of col1 to
 select those rows (all n of them).  Is it possible for R to recognize
 (or somehow be told) that these rows are already in order, thus
 allowing the computation could be completed in ~log(n) row reads
 instead?

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




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Richard . Cotton
 One thing I find most frustrating about R is how difficult it is to use
 Google (or any other search tool) to look for answers to my R-related
 questions.  With languages with even slightly more distinctive names 
like
 Perl, Java, Python, Matlab, OCaml, etc., usually including the name of 
the
 language in the query is enough to ensure that the top hits are 
relevant.
  But this trick does not work for R, because the letter R appears by 
itself
 in so many pages, that the chaff overwhelms the wheat, so to speak.

There are loads of ways of finding information.

Use the function RSiteSearch, or
The R mail archive  
http://www.googlesyndicatedsearch.com/u/newcastlemaths
RSeek   http://www.rseek.org/
R Searchhttp://www.dangoldstein.com/search_r.html  

The R Graph Gallery http://addictedtor.free.fr/graphiques/
R Help Wiki http://wiki.r-project.org/rwiki/doku.php
R manuals   http://cran.r-project.org/manuals.html
FAQshttp://cran.r-project.org/faqs.html
Task Views  http://cran.r-project.org/web/views/
News
http://www.r-project.org/doc/Rnews/index.html
Books   
http://www.r-project.org/doc/bib/R-books.html
Cranberries http://dirk.eddelbuettel.com/cranberries/

R-Forge (http://r-forge.r-project.org/) and Bioconductor (
http://www.bioconductor.org/GettingStarted) also have their own search 
tools.

Regards,
Richie.

Mathematical Sciences Unit
HSL




ATTENTION:

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

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Luc Villandre


Kynn Jones wrote:

Hi!  I'm new to R programming, though I've been programming in other
languages for years.

One thing I find most frustrating about R is how difficult it is to use
Google (or any other search tool) to look for answers to my R-related
questions.  With languages with even slightly more distinctive names like
Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
language in the query is enough to ensure that the top hits are relevant.
 But this trick does not work for R, because the letter R appears by itself
in so many pages, that the chaff overwhelms the wheat, so to speak.

So I'm curious to learn what strategies R users have found to get around
this annoyance.

TIA!

KJ

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

Hi Kynn,

I've had this problem too in the beginning. Luckily, my personal 
experience has taught me that almost all relevant R-related information 
can be found either by searching directly through the archives of the 
different R-forums or by using the functions RSiteSearch() or 
help.search(). The reference manuals provided with each package 
(easily accessible on CRAN) are also invaluable sources of information.


Unfortunately, phrasing queries in a way that will yield relevant 
results is sometimes hard. Knowledge of the terminology mostly comes 
from experience, so patience is in order.


Of course, as a last recourse, there's always the mailing list.

Bottom line is, I suggest you try to avoid generic search engines and 
concentrate your efforts on the different R-forums (note that there are 
also package-specific forums).


I suspect the more experienced R-users might have better strategies to 
propose though...


Cheers,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

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


Re: [R] SEM:Standard error of std.coef estimates?

2009-05-20 Thread John Fox
Dear Bastiaan,

The standard errors of the standardized coefficients aren't simple because
the standard deviations used to standardize the coefficients are also
subject to sampling error. I can think of two ways to get standard errors
for the standardized coefficients: by the delta method and by bootstrapping.
Neither method is implemented in the sem package. Figuring out how to apply
the former would require some work; I'll put it on my to-do list, but may
not get to it. The second approach could easily be implemented via the boot
package.

I hope this helps,
 John


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of BdeGroot
 Sent: May-20-09 7:41 AM
 To: r-help@r-project.org
 Subject: [R] SEM:Standard error of std.coef estimates?
 
 
 Hi,
 
 I am currently working with the sem package in R, to create pathway
 diagrams. Id like to use the standardized path coeffcients. To get these,
I
 use std.coef. However, using this yields only the standardized
coefficients,
 but does not give me the standard error. Does someone know how to get
 std.coef to show the standard error of the standardized path coefficients
as
 well?
 
 
 Thanks,
 Bastiaan
 
 
 PS:
 When I use std.coef, all I get is this:
 
 std.coef(path.model.SSI4)
   Std. Estimate
 par1 par1  0.39499  com_veg --- tempm
 par2 par2  0.35231  SNutBili --- tempm
 par3 par3 -0.68170  S_SSI4 --- tempm
 par4 par4 -0.39145  com_veg --- Wdeficit
 par5 par5 -0.60025  SNutBili --- Wdeficit
 par6 par6 -0.20562  S_SSI4 --- Wdeficit
 par7 par7  0.14871  SNutBili --- com_veg
 par8 par8  0.14905  S_SSI4 --- com_veg
 par9 par9 -0.39164  S_SSI4 --- SNutBili
 --
 View this message in context:
http://www.nabble.com/SEM%3AStandard-error-of-
 std.coef-estimates--tp23633227p23633227.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Trouble installing package 'systemfit'

2009-05-20 Thread Rui Wang
I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to install 
'systemfit'. 
I downloaded file 'systemfit_1[1].0-8.zip' to install the package. 
I am using Windows 2000 service pack 4.
 
The error message is:
 
Error in gzfile(file, r) : cannot open the connection
In addition: Warning message:
In gzfile(file, r) :
  cannot open compressed file 'systemfit_1[1].0-8/DESCRIPTION', probable reason 
'No such file or directory'
 
Thanks!

[[alternative HTML version deleted]]

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


Re: [R] Getting lm() to work with a matrix

2009-05-20 Thread Luc Villandre

MikSmith wrote:

Hi

I'm fairly new to R and am trying to analyse some large spectral datasets
using stepwise regression (fairly standard in this area). I have a field
sampled dataset, of which a proportion has been held back for validation. I
gather than step() needs to be fed a regression model and lm() can produce a
multiple regression. I had thought something like:

spectra.lm - lm(response[,3]~spectra.spec[,2:20])

might work but lm() doesnt appear to like being fed a range of columns. I
suspect Ive missed something fairly fundamental here.

Any help much appreciated

best wishes

mike
  

Hi Mike,

Indeed, functions like /lm()/ require the object fed to the /data/ 
argument to be either a list, a data frame or an environment containing 
the variables in the model.  The /formula/ argument will then refer to 
column names or element names.


In your situation, I suggest you typecast your matrix into a data frame 
using /as.data.frame()/. You can attribute column names by using 
/colnames()/. If you have a very large number of columns and you don't 
feel like giving them names individually, using the /paste()/ function 
should save you a lot of time.


Also, character-type objects can be typecasted using /as.formula()/ to 
formula-like objects. So, using a combination of /paste()/ and 
/as.formula()/ might make your life a lot easier.


HTH,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

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

2009-05-20 Thread cryan
For Google searches, I find that throwing in the term cran on every search 
helps weed out irrelevant pages.

For example, instead of 

r residuals

I type

r cran residuals

--Chris Ryan

 Original message 
Date: Wed, 20 May 2009 09:43:14 -0400
From: Luc Villandre villa...@dms.umontreal.ca  
Subject: Re: [R] How to google for R stuff?  
To: Kynn Jones kyn...@gmail.com
Cc: r-help@r-project.org


Kynn Jones wrote:
 Hi!  I'm new to R programming, though I've been programming in other
 languages for years.

 One thing I find most frustrating about R is how difficult it is to use
 Google (or any other search tool) to look for answers to my R-related
 questions.  With languages with even slightly more distinctive names like
 Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
 language in the query is enough to ensure that the top hits are relevant.
  But this trick does not work for R, because the letter R appears by itself
 in so many pages, that the chaff overwhelms the wheat, so to speak.

 So I'm curious to learn what strategies R users have found to get around
 this annoyance.

 TIA!

 KJ

  [[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.
   
Hi Kynn,

I've had this problem too in the beginning. Luckily, my personal 
experience has taught me that almost all relevant R-related information 
can be found either by searching directly through the archives of the 
different R-forums or by using the functions RSiteSearch() or 
help.search(). The reference manuals provided with each package 
(easily accessible on CRAN) are also invaluable sources of information.

Unfortunately, phrasing queries in a way that will yield relevant 
results is sometimes hard. Knowledge of the terminology mostly comes 
from experience, so patience is in order.

Of course, as a last recourse, there's always the mailing list.

Bottom line is, I suggest you try to avoid generic search engines and 
concentrate your efforts on the different R-forums (note that there are 
also package-specific forums).

I suspect the more experienced R-users might have better strategies to 
propose though...

Cheers,
-- 
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

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

2009-05-20 Thread Ronggui Huang
Have you tried another mirror? It seems that downloaded file is incomplete.


2009/5/20 Rui Wang r...@hawaii.edu:
 I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to install 
 'systemfit'.
 I downloaded file 'systemfit_1[1].0-8.zip' to install the package.
 I am using Windows 2000 service pack 4.

 The error message is:

 Error in gzfile(file, r) : cannot open the connection
 In addition: Warning message:
 In gzfile(file, r) :
  cannot open compressed file 'systemfit_1[1].0-8/DESCRIPTION', probable 
 reason 'No such file or directory'

 Thanks!

        [[alternative HTML version deleted]]

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




-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

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


Re: [R] Trouble installing package 'systemfit'

2009-05-20 Thread Uwe Ligges



Rui Wang wrote:
I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to install 'systemfit'. 
I downloaded file 'systemfit_1[1].0-8.zip' to install the package. 
I am using Windows 2000 service pack 4.



The filename lost its canonical form, pelase try to rename it to:

systemfit_1.0-8.zip

Uwe Ligges





The error message is:
 
Error in gzfile(file, r) : cannot open the connection

In addition: Warning message:
In gzfile(file, r) :
  cannot open compressed file 'systemfit_1[1].0-8/DESCRIPTION', probable reason 
'No such file or directory'
 
Thanks!


[[alternative HTML version deleted]]

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


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


Re: [R] Error with regsubset in leaps package - vcov and all.best option (plus calculating VIFs for subsets)

2009-05-20 Thread Thomas Lumley

On Wed, 20 May 2009, lara harrup (IAH-P) wrote:




Hi all


I am hoping this is just a minor problem, I am trying to implement a best 
subsets regression procedure on some ecological datasets using the regsubsets 
function in the leaps package. The dataset contains 43 predictor variables plus 
the response (logcount) all in a dataframe called environment. I am 
implementing it as follows:

library(leaps)


subsets-regsubsets(logcount~.,data=environment,nvmax=10,nbest=2,really.big=FALSE,method=exhaustive)

###the subset regression runs fine when i run it as above and i can get all 
the usual summaries

###The problem comes when i try and get it to output the variance convariance 
matric by adding the option vcov=TRUE


Yes, that would be because there is no option vcov=TRUE for regsubsets. There 
is a vcov= option for the coef() method, which may be what is confusing you.

snip


I was wanting to get the variance - covariance matrix as I believe I need it to 
calculate the Variance Inflation Factors (VIFs) for each of the models reported by 
regsubsets. As I want to exclude any models that exhibit multicollinerarity from later 
analysis, I am hoping to select say the 'best' 10 models and bootstrap them to find out 
more about how they perform.


As in the example on the help page, once you have run regsubsets() you can use  
coef() and vcov() on the object it returns to get coefficient estimates and 
variance-covariance matrices for any of the best models.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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

2009-05-20 Thread Christine Griffiths

Dear All

I have a repeated measures design in which abundance was measured 
repeatedly over 10 months in three treatments (Tortoise A; Tortoise B and 
control) established in 6 blocks, i.e. crossed fixed effects. My original 
design incorporated two tortoises per treatment, however as fieldwork goes 
I ended up losing some animals. Rather than lose a couple of enclosures in 
the analysis and have to do a lmer, I thought I could include tortoise 
weight as an explanatory variable. For my treatments, tortoise weight in 
the control always = 0, while in general Tortoise A is twice as large as 
Tortoise B except when I lost animals. Is this the correct model?


aov(Tel.ab~Tort.W+Treatment*Month+Error(Month/Block))

Or should tortoise weight be nested in Treatment, i.e not included as a 
fixed factor but including the fact that tortoises species may have an 
effect? I am utterly confused now as to whether that should be the case as 
to some extent Tort.W and Treatment are correlated.

Any help would be much appreciated.
Many thanks
Christine


--
Christine Griffiths
School of Biological Sciences
University of Bristol
Woodland Road
Bristol BS8 1UG
Tel: 0117 9287593
Fax 0117 925 7374
christine.griffi...@bristol.ac.uk
http://www.bio.bris.ac.uk/research/mammal/tortoises.html

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


[R] function returning the name of an object

2009-05-20 Thread Antonio Gasparrini
Hello R users,
 
I'm trying to solve an apparently simple problem.
I include a matrix in a model formula, and I want then to extract the related 
coefficients.
Basically, I want a function func such that:
 
mymatrix - cbind(rnorm(10),rnorm(10))
y - b - rnorm(10)
model - lm(y ~ b + mymatrix)
func(mymatrix,model)
 
which returns only the 3rd and 4th coefficients.
 
I thought to search by:
 
grep(mymatrix,names(coef(model)))
 
but I don't know how to extract the name mymatrix from the object mymatrix.
Is there a specific function, something like func(mymatrix) returning the 
string mymatrix?
 
Thanks so much for your time.
 
Antonio Gasparrini
Public and Environmental Health Research Unit (PEHRU)
London School of Hygiene  Tropical Medicine
Keppel Street, London WC1E 7HT, UK
Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
Skype contact: a.gasparrini
http://www.lshtm.ac.uk/people/gasparrini.antonio ( 
http://www.lshtm.ac.uk/pehru/ )

[[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] Getting lm() to work with a matrix

2009-05-20 Thread Berwin A Turlach
G'day Luc,

On Wed, 20 May 2009 09:58:41 -0400
Luc Villandre villa...@dms.umontreal.ca wrote:

 MikSmith wrote:
  [...]

 Indeed, functions like /lm()/ require the object fed to the /data/ 
 argument to be either [...]

But the data argument is optional and does not need to be specified.

 In your situation, I suggest you typecast your matrix into a data
 frame using /as.data.frame()/.  [...]

My guess is that he is already working with a data frame and does not
work with matrices, otherwise he should not have encountered problems:

R response - matrix(rnorm(120), ncol=4)
R spectra.spec - matrix(rnorm(900), ncol=30)
R spectra.lm - lm(response[,3]~spectra.spec[,2:20])
R spectra.lm

Call:
lm(formula = response[, 3] ~ spectra.spec[, 2:20])

Coefficients:
   (Intercept)   spectra.spec[, 2:20]1  
  -0.48404 0.42503  
 spectra.spec[, 2:20]2   spectra.spec[, 2:20]3  
  -0.08955-0.27605  
 spectra.spec[, 2:20]4   spectra.spec[, 2:20]5  
  -0.16832-0.14107  
 spectra.spec[, 2:20]6   spectra.spec[, 2:20]7  
  -0.47009-0.23672  
 spectra.spec[, 2:20]8   spectra.spec[, 2:20]9  
   0.12920 0.23306  
spectra.spec[, 2:20]10  spectra.spec[, 2:20]11  
  -0.28586 0.03579  
spectra.spec[, 2:20]12  spectra.spec[, 2:20]13  
   0.10676-0.34407  
spectra.spec[, 2:20]14  spectra.spec[, 2:20]15  
   0.20253-0.17259  
spectra.spec[, 2:20]16  spectra.spec[, 2:20]17  
   0.19765 0.40705  
spectra.spec[, 2:20]18  spectra.spec[, 2:20]19  
  -0.12448-0.17149  

Cheers,

Berwin

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


Re: [R] Trouble installing package 'systemfit'

2009-05-20 Thread Rui Wang
Renaming the file worked! Thanks!

- Original Message -
From: Uwe Ligges lig...@statistik.tu-dortmund.de
Date: Wednesday, May 20, 2009 10:07 am
Subject: Re: [R] Trouble installing package 'systemfit'
To: Rui Wang r...@hawaii.edu
Cc: r-help@r-project.org

 
 
 Rui Wang wrote:
  I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to 
 install 'systemfit'. 
  I downloaded file 'systemfit_1[1].0-8.zip' to install the 
 package. 
  I am using Windows 2000 service pack 4.
 
 
 The filename lost its canonical form, pelase try to rename it to:
 
 systemfit_1.0-8.zip
 
 Uwe Ligges
 
 
 
 
  The error message is:
   
  Error in gzfile(file, r) : cannot open the connection
  In addition: Warning message:
  In gzfile(file, r) :
cannot open compressed file 'systemfit_1[1].0-
 8/DESCRIPTION', probable reason 'No such file or directory'
   
  Thanks!
  
   [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-
 project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

[[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] problem with APPLY

2009-05-20 Thread De France Henri
Hello,
 
The apply function seems to behave oddly with my code below
 
NB : H1 is a data frame. (data in the attached file.)
# the first lines are:
1 02/01/2008 0.00  0  0 0.00   0
2 03/01/2008 0.00  0  0 0.00   0
3 04/01/2008 0.00  0  0 0.00   0
4 07/01/2008 0.00  0  0 0.00   0
5 08/01/2008 0.00  0  0 0.00   0
6 09/01/2008 0.00  0  0 0.00   0
7 10/01/2008 0.00  0  0 0.00   0
8 11/01/2008 1.010391  0  0 1.102169   0
...
The aim of the code is to extract those lines for which there is a strictly 
positive value in the second column AND in one of the others:
 
reper=function(x){as.numeric(x[2]1  any(x[3:length(x)]1))}
 
TAB1= H1[which(apply(H1,1,reper)0),]
 
Strangely, this is OK for all the lines, except for the last one. In fact, in 
H1, the last 2 lines are:
258 29/12/2008 1.476535 1.187615  0 0.00   0
259 30/12/2008 0.00 1.147888  0 0.00   0
Obviously, line 258 should be the last line of TAB1, but it is not the case (it 
does not appear at all) and I really don't understand why. This is all the 
more strange since applying the function reper only to this line 258 gives a 
1 as expected...
Can someone help ?
 
Thanks,
 
Henri 


  do[, 1] V3 V5 V7 V13 V31
1 02/01/2008 0 0 0 0 0
2 03/01/2008 0 0 0 0 0
3 04/01/2008 0 0 0 0 0
4 07/01/2008 0 0 0 0 0
5 08/01/2008 0 0 0 0 0
6 09/01/2008 0 0 0 0 0
7 10/01/2008 0 0 0 0 0
8 11/01/2008 1.01039075593190 0 0 1.10216867469880 0
9 14/01/2008 0 0 0 0 0
10 15/01/2008 0 0 0 0 0
11 16/01/2008 0 0 0 0 0
12 17/01/2008 0 0 0 0 0
13 18/01/2008 0 0 0 0 0
14 21/01/2008 0 1.91598986420635 0 0 0
15 22/01/2008 0 0 0 1.67943418163028 0
16 23/01/2008 0 1.72752274788613 0 0 0
17 24/01/2008 0 0 0 0 0
18 25/01/2008 0 0 0 0 0
19 28/01/2008 0 1.58121398689715 0 0 0
20 29/01/2008 0 0 0 0 0
21 30/01/2008 0 0 0 0 0
22 31/01/2008 0 0 0 0 0
23 01/02/2008 0 0 0 0 0
24 04/02/2008 0 0 0 0 0
25 05/02/2008 0 0 0 0 0
26 06/02/2008 0 0 0 0 0
27 07/02/2008 0 0 0 0 0
28 08/02/2008 2.14000732355798 1.69766978689504 0 1.75685318945262 0
29 11/02/2008 0 0 0 0 0
30 12/02/2008 0 0 0 0 0
31 13/02/2008 0 0 0 0 0
32 14/02/2008 1.46825855993268 1.01452104942038 0 1.36151226158038 0
33 15/02/2008 0 0 0 0 0
34 18/02/2008 1.23828782287823 1.85457398206402 0 1.01737020551797 0
35 19/02/2008 0 0 0 0 0
36 20/02/2008 0 0 0 1.16595050312755 0
37 21/02/2008 0 0 0 0 0
38 22/02/2008 0 0 0 0 0
39 25/02/2008 0 0 0 0 0
40 26/02/2008 0 0 0 0 0
41 27/02/2008 0 0 0 1.14892847454562 0
42 28/02/2008 0 0 0 0 0
43 29/02/2008 0 0 0 1.08156034746327 0
44 03/03/2008 0 0 0 0 0
45 04/03/2008 0 0 0 0 0
46 05/03/2008 0 0 0 0 0
47 06/03/2008 0 0 0 0 0
48 07/03/2008 0 0 0 0 0
49 10/03/2008 0 0 0 0 0
50 11/03/2008 0 0 0 0 0
51 12/03/2008 0 0 0 0 0
52 13/03/2008 0 0 0 0 0
53 14/03/2008 0 0 0 0 0
54 17/03/2008 4.35512801471512 5.36991654793405 0 6.16519844357977 0
55 18/03/2008 2.79350502621745 2.11529748269272 0 3.52300391995049 0
56 19/03/2008 2.71891047108730 2.44490502825019 0 2.88516037009928 0
57 20/03/2008 0 0 0 0 0
58 21/03/2008 0 0 0 0 0
59 24/03/2008 5.54031680331131 5.79959578768216 0 6.7272138683414 0
60 25/03/2008 0 0 0 0 0
61 26/03/2008 0 0 0 0 0
62 27/03/2008 0 0 0 0 0
63 28/03/2008 0 0 0 0 0
64 31/03/2008 1.36298613237674 1.93688809995221 0 1.62820120724346 0
65 01/04/2008 0 0 0 0 0
66 02/04/2008 0 1.50365203568443 0 1.41661422278162 0
67 03/04/2008 0 0 0 0 0
68 04/04/2008 0 0 0 0 0
69 07/04/2008 0 0 0 0 0
70 08/04/2008 0 0 0 0 0
71 09/04/2008 0 0 0 0 0
72 10/04/2008 0 0 0 0 0
73 11/04/2008 0 0 0 0 0
74 14/04/2008 0 0 0 0 0
75 15/04/2008 0 1.12993898169451 0 0 0
76 16/04/2008 0 1.64919239565466 0 0 0
77 17/04/2008 1.85794201323402 2.32701547844896 0 2.13671788020485 0
78 18/04/2008 0 0 0 0 0
79 21/04/2008 0 0 0 0 0
80 22/04/2008 0 0 0 0 0
81 23/04/2008 0 0 0 0 0
82 24/04/2008 0 0 0 0 0
83 25/04/2008 0 0 0 0 0
84 28/04/2008 0 0 0 0 0
85 29/04/2008 1.41455686561253 1.23468581006293 0 1.41084889962815 0
86 30/04/2008 0 0 0 0 0
87 01/05/2008 0 1.5699823478825 0 0 0
88 02/05/2008 0 0 0 0 0
89 05/05/2008 0 0 0 0 0
90 06/05/2008 0 0 0 0 0
91 07/05/2008 0 0 0 0 0
92 08/05/2008 0 0 0 0 0
93 09/05/2008 0 0 0 0 0
94 12/05/2008 0 0 0 0 0
95 13/05/2008 0 0 0 0 0
96 14/05/2008 0 0 0 0 0
97 15/05/2008 0 0 0 0 0
98 16/05/2008 0 0 0 0 0
99 19/05/2008 0 0 0 0 0
100 20/05/2008 0 0 0 0 0
101 21/05/2008 0 0 0 0 0
102 22/05/2008 0 0 0 0 0
103 23/05/2008 0 0 0 0 0
104 26/05/2008 0 0 0 0 0
105 27/05/2008 0 0 0 0 0
106 28/05/2008 0 0 0 0 0
107 29/05/2008 0 0 0 0 0
108 30/05/2008 0 0 0 0 0
109 02/06/2008 0 0 0 0 0
110 03/06/2008 0 0 0 0 0
111 04/06/2008 0 0 0 0 0
112 05/06/2008 0 0 0 0 0
113 06/06/2008 0 0 0 0 0
114 09/06/2008 0 0 0 0 0
115 10/06/2008 0 0 0 0 0
116 11/06/2008 0 0 0 0 0
117 12/06/2008 0 0 0 0 0
118 13/06/2008 0 0 0 0 0
119 16/06/2008 0 0 0 0 0
120 17/06/2008 0 0 0 0 0
121 18/06/2008 0 0 0 0 0
122 19/06/2008 0 0 0 0 0
123 20/06/2008 0 0 0 0 0
124 23/06/2008 0 0 0 0 0
125 24/06/2008 0 0 0 0 0
126 25/06/2008 0 0 0 0 0
127 26/06/2008 0 0 0 0 0
128 27/06/2008 0 0 0 0 0

Re: [R] How to google for R stuff?

2009-05-20 Thread spencerg
 There is also the relatively new RSiteSearch package.  It's 
RSiteSearch.function searches only help pages of contributed packages 
but returns the result in a data.frame (of class RSiteSearch) sorted 
to put the most interesting package first with help pages sorted within 
packages.  If this package is installed, system.file('doc', 
'RSiteSearch.pdf', package='RSiteSearch') will give you the location of 
a 2-page description of the most important features of this package 
including examples that work.  Since that document was written, we've 
added | and  for combining the objects returned by different 
searches and packageSum2 to add information from installed packages 
not available from RSiteSearch itself. 



 For example, I'm giving an invited presentation on Fitting 
Nonlinear Differential Equations to Data in R as part of a Dynamics 
Workshop in Vancouver this June 4-6 
(http://stat.sfu.ca/~dac5/workshop09/Welcome.html).  To prepare for 
that, I first did the following: 



de - RSiteSearch.function(differential equation)
des - RSiteSearch.function(differential equations)
# With de and des, each finds things missed by the other. 
de. - de | des # combine into one
sumDE - packageSum2(de.) # add details on installed packages. 



 This helped me decide which packages I should look at first. 

 Hope this helps. 
 Spencer Graves


cr...@binghamton.edu wrote:

For Google searches, I find that throwing in the term cran on every search 
helps weed out irrelevant pages.

For example, instead of 


r residuals

I type

r cran residuals

--Chris Ryan

 Original message 
  

Date: Wed, 20 May 2009 09:43:14 -0400
From: Luc Villandre villa...@dms.umontreal.ca  
Subject: Re: [R] How to google for R stuff?  
To: Kynn Jones kyn...@gmail.com

Cc: r-help@r-project.org


Kynn Jones wrote:


Hi!  I'm new to R programming, though I've been programming in other
languages for years.

One thing I find most frustrating about R is how difficult it is to use
Google (or any other search tool) to look for answers to my R-related
questions.  With languages with even slightly more distinctive names like
Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
language in the query is enough to ensure that the top hits are relevant.
 But this trick does not work for R, because the letter R appears by itself
in so many pages, that the chaff overwhelms the wheat, so to speak.

So I'm curious to learn what strategies R users have found to get around
this annoyance.

TIA!

KJ

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

Hi Kynn,

I've had this problem too in the beginning. Luckily, my personal 
experience has taught me that almost all relevant R-related information 
can be found either by searching directly through the archives of the 
different R-forums or by using the functions RSiteSearch() or 
help.search(). The reference manuals provided with each package 
(easily accessible on CRAN) are also invaluable sources of information.


Unfortunately, phrasing queries in a way that will yield relevant 
results is sometimes hard. Knowledge of the terminology mostly comes 


from experience, so patience is in order.
  

Of course, as a last recourse, there's always the mailing list.

Bottom line is, I suggest you try to avoid generic search engines and 
concentrate your efforts on the different R-forums (note that there are 
also package-specific forums).


I suspect the more experienced R-users might have better strategies to 
propose though...


Cheers,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

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



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




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


Re: [R] SEM:Standard error of std.coef estimates?

2009-05-20 Thread BdeGroot

Dear John,

Thank you for your reply. I would like to try the bootstrapping method. I
have the boot package, however, I have not used it before. I do not know how
to compute the correct code to calculate the standarized errors. If possible
and easily achievable, could you please tell me what to do specifically or
provide some more specific guidelines?

Thanks,
Bastiaan


John Fox-6 wrote:
 
 Dear Bastiaan,
 
 The standard errors of the standardized coefficients aren't simple because
 the standard deviations used to standardize the coefficients are also
 subject to sampling error. I can think of two ways to get standard errors
 for the standardized coefficients: by the delta method and by
 bootstrapping.
 Neither method is implemented in the sem package. Figuring out how to
 apply
 the former would require some work; I'll put it on my to-do list, but may
 not get to it. The second approach could easily be implemented via the
 boot
 package.
 
 I hope this helps,
  John
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of BdeGroot
 Sent: May-20-09 7:41 AM
 To: r-help@r-project.org
 Subject: [R] SEM:Standard error of std.coef estimates?
 
 
 Hi,
 
 I am currently working with the sem package in R, to create pathway
 diagrams. Id like to use the standardized path coeffcients. To get these,
 I
 use std.coef. However, using this yields only the standardized
 coefficients,
 but does not give me the standard error. Does someone know how to get
 std.coef to show the standard error of the standardized path coefficients
 as
 well?
 
 
 Thanks,
 Bastiaan
 
 
 PS:
 When I use std.coef, all I get is this:
 
 std.coef(path.model.SSI4)
   Std. Estimate
 par1 par1  0.39499  com_veg --- tempm
 par2 par2  0.35231  SNutBili --- tempm
 par3 par3 -0.68170  S_SSI4 --- tempm
 par4 par4 -0.39145  com_veg --- Wdeficit
 par5 par5 -0.60025  SNutBili --- Wdeficit
 par6 par6 -0.20562  S_SSI4 --- Wdeficit
 par7 par7  0.14871  SNutBili --- com_veg
 par8 par8  0.14905  S_SSI4 --- com_veg
 par9 par9 -0.39164  S_SSI4 --- SNutBili
 --
 View this message in context:
 http://www.nabble.com/SEM%3AStandard-error-of-
 std.coef-estimates--tp23633227p23633227.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/SEM%3AStandard-error-of-std.coef-estimates--tp23633227p23636945.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] Class for time of day?

2009-05-20 Thread Stavros Macrakis
What is the recommended class for time of day (independent of calendar
date)?

And what is the recommended way to get the time of day from a POSIXct
object? (Not a string representation, but a computable representation.)

I have looked in the man page for DateTimeClasses, in the Time Series
Analysis Task View and in Spector's Data Manipulation book but haven't found
these. Clearly I can create my own Time class and hack around with the
internal representation of POSIXct, e.g.

days - unclass(d)/(24*3600)
days-floor(days)

and write print.Time, `-.Time`, etc. etc. but I expect there is already a
standard class or CRAN package.

   -s

[[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] meaning of order-vector in object of class hclust

2009-05-20 Thread Pieter van der Spek
I'm trying to export the dendrogram created in R such that I can rebuild it
inside an other program. However, I don't fully understand the relation
between the merge, height and order vectors.
This is what I do grasp. The merge-matrix shows how the original
observations were merged into a tree structure. The height-vector contains
the heights for each of the nodes in the tree. The order of the merge-matrix
and the height-vector is the same. This means that row *i* in the matrix
corresponds to row *i* in the vector.
Then there is the order-vector. The documentation describes it as follows:

order a vector giving the permutation of the original observations suitable
for plotting, in the sense that a cluster plot using this ordering and
matrix merge will not have crossings of the branches.

So far, I get it reorders the nodes to prevent overlapping branches, but I
don't understand how the values in this vector correspond to the values in
the other two structures. So what does row *i* in the order-vector say about
the other structures? Should I reorder the merge-matrix and height-vector,
according to the values in the order-vector, before constructing the tree?

Hopefully someone can explain to me how this works. Thanks in advance for
any help you can provide.

Kind regards,
Pieter

[[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] stationarity tests

2009-05-20 Thread mauede
How can I make sure the residual signal, after subtracting the trend extracted 
through some technique, is actually trend-free ?   
I would greatly appreciate any suggestion about some Stationarity tests.

I'd like to make sure I have got the difference between ACF and PACF right.
In the following I am citing some definitions. I would appreciate your thoughts.

ACF(k) estimates the correlation between y(t) and y(t-k)  like an ordinary 
correlation coefficient.
ACF is the simple ( i.e. unconditional ) correlation between a time series and 
it's lags thus
y(t)=a+b*y(t-k) gnerates the kth autocoreelation coefficient (b).

If we have form y(t)=a+b*y(t-1)+c*y(t-2) .. then (c)  is the PARTIAL 
AUTOCORRELATION COEFFFICIENT or in other words the
CONDITIONAL CORRELATION of lag 2 given lag1
PACF(k) estimates the correlation between y(t) and y(t-k) adjusted for the 
effects of y(t-1), ..., y(t-k+1).

Model identification is achieved by looking at the pattern of the ACF and PACF.
- If the ACF dies off exponentially, but the PACF has p spikes, AR(p) is 
indicated.
- If the ACF has  q  spikes and the PACF dies off exponentially, MA(q) is 
indicated.

The ACF and the PACF for the resulting stationary series is used to determine 
the best B/J model for the series according to the following rules:
 a.  If the ACF trails off and the PACF shows spikes, then an AR model with 
order p = number of significant PACF spikes is the best
  model.
 b.  If the PACF trails off and the ACF shows spikes, then an MA model with 
order q= number of significant ACF spikes is the best model.
 c.  If both the ACF and the PACF trail off then a ARMA model is used with p=1 
and q=1.

Thank you very much,
Maura

Thank you very much.
Best regards,
Maura Edelweiss



tutti i telefonini TIM!


[[alternative HTML version deleted]]

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Seeliger . Curt
Kynn writes:
 So I'm curious to learn what strategies R users have found to get around
 this annoyance.

I use Rseek for most of my R questions: http://www.rseek.org/

cur
-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638

[[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] arrangement of crowded labels

2009-05-20 Thread Greg Snow
Look at the spread.labs and the dynIdentify and TkIdentify functions in the 
TeachingDemos package. 

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Thomas Zumbrunn
 Sent: Wednesday, May 20, 2009 12:18 AM
 To: r-help@r-project.org
 Subject: [R] arrangement of crowded labels
 
 Dear R users
 
 I'm looking for algorithms that assist in spreading out crowded labels,
 e.g.
 labels of points in a scatter plot, in order to obtain a nicer visual
 appearance and better legibility.
 
 I'm probably just stuck because I didn't find the right key words for a
 successful search on the R websites or in the mailing list archives.
 
 Any hints are appreciated.
 
 Thomas Zumbrunn
 University of Basel
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] drc results differ for different versions

2009-05-20 Thread Marc Schwartz

On May 20, 2009, at 11:20 AM, Hans Vermeiren wrote:


Hello,

We use drc to fit dose-response curves, recently we discovered that
there are quite different standard error values returned for the same
dataset depending on the drc-version / R-version that was used (not
clear which factor is important)
On R 2.9.0 using drc_1.6-3 we get an IC50 of 1.27447 and a standard
error on the IC50 of 0.43540
Whereas on R 2.7.0 using drc_1.4-2  the IC50 is 1.2039e+00 and the
standard error is 3.7752e-03
Normally I would use the most recent version (both R and drc library)
but it seems to me that a standard error of 0.4 on a mean of 1.2 is  
too

big, so I trust the values we get with the older versions more
Has anyone suggestions on
- how to solve these discrepancies, if possible
- how to calculate which one of the 2 solutions is the correct one?

Thanks a lot,
Hans Vermeiren

Demo (on a windows machine, while the issue was actually discovered on
our ubuntu linux server):
1)
sessionInfo()
R version 2.7.0 (2008-04-22)
i386-pc-mingw32

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium. 
1252;LC_MONETARY=Du

tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.4-2  plotrix_2.4-2  nlme_3.1-89MASS_7.2-41
lattice_0.17-6
[6] alr3_1.1.7

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

d-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c(hs, bottom, top, ec50)), logDose =  
10,

control = drmc(useD = T))

summary(m)
results in:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

 Estimate  Std. Error t-value   p-value
hs:(Intercept) -9.8065e-01  2.5821e-03 -3.7979e+02 2.248e-33
bottom:(Intercept)  1.0955e+01  2.2546e-02  4.8591e+02 4.364e-35
top:(Intercept) 1.0502e+02  9.0935e-02  1.1549e+03 4.210e-41
ec50:(Intercept)1.2039e+00  3.7752e-03  3.1890e+02 3.681e-32

Residual standard error: 7.026655 (16 degrees of freedom)
= 
= 
==

===
2)
sessionInfo()
R version 2.9.0 (2009-04-17)
i386-pc-mingw32

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium. 
1252;LC_MONETARY=Du

tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.6-3   plotrix_2.5-5   nlme_3.1-90 MASS_7.2-46
magic_1.4-4 abind_1.1-0 lattice_0.17-22 alr3_1.1.7

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

d-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c(hs, bottom, top, ec50)), logDose =  
10,

control = drmc(useD = T))

summary(m)

gives:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

   Estimate Std. Error   t-value   p-value
hs:(Intercept)  -0.952660.25778  -3.695640.0020
bottom:(Intercept)  10.974372.24421   4.890090.0002
top:(Intercept)106.383739.98378  10.65565 1.127e-08
ec50:(Intercept) 1.274470.43540   2.927120.0099

Residual standard error:

7.020175 (16 degrees of freedom)


Hans,

You have three important factors changing here. The version of R, the  
version of drc and the versions of any relevant drc dependencies  
(alr3, lattice, magic, MASS, nlme, plotrix).


I would first try to install the newer version of drc on the older R  
system (all else staying the same) and see what you get. Don't run  
update.packages() here, lest you change other things. Just install the  
newer version of drc.


If you get the same results as the older version, then it might lead  
you to something in R or one of the package dependencies changing.


If you get a different result, then it would lead to something in drc  
changing.



You can also install the old version of drc on your more recent R  
system to see what you get, which might help to confirm behavior.


The old source version of drc would be 

Re: [R] How to google for R stuff?

2009-05-20 Thread spencerg
Dear Dieter: 

 Thanks for the correction.  I failed to test the code as written 
before I posted it. 


 Spencer Graves

Dieter Menne wrote:

spencerg spencer.graves at prodsyse.com writes:

  

de - RSiteSearch.function(differential equation)
des - RSiteSearch.function(differential equations)
# With de and des, each finds things missed by the other. 
de. - de | des # combine into one
sumDE - packageSum2(de.) # add details on installed packages. 



Should be 

PackageSum2(de.) 


Dieter

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




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


[R] evaluating partitions in CLUE

2009-05-20 Thread A M Lavezzi
Hello,
I'm starting to use CLUE to compare clusterings.

I have some cluster structures obtained outside R, which are simlply vectors
of lenght N (N: number of objects), which contain a number indicating the
cluster to which each object belongs. I report below a portion of one of
these:


   V1
1  12
2   1
3   2
4   6
5  15
6   9
7   5
8   8
9  12
10  9
11 10
12  2
13  7
14 12
15 10
-
which indicates that object 1 is in cluster 12, object 2 is in cluster 1
etc.

Is there a way to evaluate the dissimilarity of clusterings of this sort
without transforming them into ensembles or, alternatively, is there a way
to turn these vectors into ensembles

Thanks a lot!
Mario

-- 
Andrea Mario Lavezzi
Dipartimento Studi su Politica, Diritto e Società
Piazza Bologni 8
90134 Palermo, Italy
tel. ++39 091 6625650
fax  ++39 091 6112023
skype: lavezzimario
email: lave...@unipa.it
web: http://www.unipa.it/~lavezzi

[[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] drc results differ for different versions

2009-05-20 Thread Hans Vermeiren
Hello,

We use drc to fit dose-response curves, recently we discovered that
there are quite different standard error values returned for the same
dataset depending on the drc-version / R-version that was used (not
clear which factor is important)
On R 2.9.0 using drc_1.6-3 we get an IC50 of 1.27447 and a standard
error on the IC50 of 0.43540   
Whereas on R 2.7.0 using drc_1.4-2  the IC50 is 1.2039e+00 and the
standard error is 3.7752e-03  
Normally I would use the most recent version (both R and drc library)
but it seems to me that a standard error of 0.4 on a mean of 1.2 is too
big, so I trust the values we get with the older versions more
Has anyone suggestions on 
- how to solve these discrepancies, if possible
- how to calculate which one of the 2 solutions is the correct one?

Thanks a lot,
Hans Vermeiren

Demo (on a windows machine, while the issue was actually discovered on
our ubuntu linux server):
1)
sessionInfo()
R version 2.7.0 (2008-04-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium.1252;LC_MONETARY=Du
tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.4-2  plotrix_2.4-2  nlme_3.1-89MASS_7.2-41
lattice_0.17-6
[6] alr3_1.1.7

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

d-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c(hs, bottom, top, ec50)), logDose = 10,
control = drmc(useD = T))

summary(m)
results in:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

  Estimate  Std. Error t-value   p-value
hs:(Intercept) -9.8065e-01  2.5821e-03 -3.7979e+02 2.248e-33
bottom:(Intercept)  1.0955e+01  2.2546e-02  4.8591e+02 4.364e-35
top:(Intercept) 1.0502e+02  9.0935e-02  1.1549e+03 4.210e-41
ec50:(Intercept)1.2039e+00  3.7752e-03  3.1890e+02 3.681e-32

Residual standard error: 7.026655 (16 degrees of freedom)

===
2)
sessionInfo()
R version 2.9.0 (2009-04-17) 
i386-pc-mingw32 

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium.1252;LC_MONETARY=Du
tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.6-3   plotrix_2.5-5   nlme_3.1-90 MASS_7.2-46
magic_1.4-4 abind_1.1-0 lattice_0.17-22 alr3_1.1.7 

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

d-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c(hs, bottom, top, ec50)), logDose = 10,
control = drmc(useD = T))

summary(m)

gives:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

Estimate Std. Error   t-value   p-value
hs:(Intercept)  -0.952660.25778  -3.695640.0020
bottom:(Intercept)  10.974372.24421   4.890090.0002
top:(Intercept)106.383739.98378  10.65565 1.127e-08
ec50:(Intercept) 1.274470.43540   2.927120.0099

Residual standard error:

 7.020175 (16 degrees of freedom)





--
This e-mail and its attachment(s) (if any) may contain confidential and/or 
proprietary information and is intended for its addressee(s) only. Any 
unauthorized use of the information contained herein (including, but not 
limited to, alteration, reproduction, communication, distribution or any other 
form of dissemination) is strictly prohibited. If you are not the intended 
addressee, please notify the orginator promptly and delete this e-mail and its 
attachment(s) (if any) subsequently. 

Galapagos nor any of its affiliates shall be liable for direct, special, 
indirect or consequential damages arising from alteration of the contents of 
this message (by a third party) or as a result of a virus being passed on.

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

Re: [R] RGoogleDocs: can now see documents but cannot get content.

2009-05-20 Thread Duncan Temple Lang


Hi Farrel

 This particular problem is a trivial issue of an argument out
of place due to a change in the function definition during the
development.  There is a new version of the package (0.2-2)
and it also uses a slightly different approach (and function)
to pull the values into the form of an R data frame.

Please try that and hopefully it will work.

The code in the run.pdf (or run.html) file on the Web page
and in the package works and is the best and shortest
example of sheetAsMatrix().

Let me know if there are still problems.


  D.

Farrel Buchinsky wrote:

The author of the package, Duncan Temple Lang posted an update. I have
installed it and now can list my spreadsheets but alas I cannot read the
data within any of them.
Has anybody been able to get it to work.
I would love to see a real live example of sheetAsMatrix
I am not sure how to specify sheet and  con = sh...@connection. I have tried
many ways but just get:
Error in !includeEmpty : invalid argument type

Windows Vista (with UAC disabled)
R 2.9.0

Farrel Buchinsky

[[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] SEM:Standard error of std.coef estimates?

2009-05-20 Thread John Fox
Dear Bastiaan,

I've written an appendix on bootstrapping regression models, available at
http://socserv.mcmaster.ca/jfox/Books/Companion/appendix-bootstrapping.pdf
, which describes generally how to proceed. In outline, you'll write a
function that takes your data matrix (not covariance matrix) as an argument,
along with a vector argument for indexing the data matrix. Your function
will calculate covariances from the indexed data matrix, fit your model to
this covariance matrix, get the standardized coefficients from the model,
and return the standardized coefficients as a vector. 

An alternative would be to adapt the boot.sem() function in the sem package
to return standardized coefficients. That might prove simpler for you.

Regards,
 John


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of BdeGroot
 Sent: May-20-09 10:54 AM
 To: r-help@r-project.org
 Subject: Re: [R] SEM:Standard error of std.coef estimates?
 
 
 Dear John,
 
 Thank you for your reply. I would like to try the bootstrapping method. I
 have the boot package, however, I have not used it before. I do not know
how
 to compute the correct code to calculate the standarized errors. If
possible
 and easily achievable, could you please tell me what to do specifically or
 provide some more specific guidelines?
 
 Thanks,
 Bastiaan
 
 
 John Fox-6 wrote:
 
  Dear Bastiaan,
 
  The standard errors of the standardized coefficients aren't simple
because
  the standard deviations used to standardize the coefficients are also
  subject to sampling error. I can think of two ways to get standard
errors
  for the standardized coefficients: by the delta method and by
  bootstrapping.
  Neither method is implemented in the sem package. Figuring out how to
  apply
  the former would require some work; I'll put it on my to-do list, but
may
  not get to it. The second approach could easily be implemented via the
  boot
  package.
 
  I hope this helps,
   John
 
 
  -Original Message-
  From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]
  On
  Behalf Of BdeGroot
  Sent: May-20-09 7:41 AM
  To: r-help@r-project.org
  Subject: [R] SEM:Standard error of std.coef estimates?
 
 
  Hi,
 
  I am currently working with the sem package in R, to create pathway
  diagrams. Id like to use the standardized path coeffcients. To get
these,
  I
  use std.coef. However, using this yields only the standardized
  coefficients,
  but does not give me the standard error. Does someone know how to get
  std.coef to show the standard error of the standardized path
coefficients
  as
  well?
 
 
  Thanks,
  Bastiaan
 
 
  PS:
  When I use std.coef, all I get is this:
 
  std.coef(path.model.SSI4)
Std. Estimate
  par1 par1  0.39499  com_veg --- tempm
  par2 par2  0.35231  SNutBili --- tempm
  par3 par3 -0.68170  S_SSI4 --- tempm
  par4 par4 -0.39145  com_veg --- Wdeficit
  par5 par5 -0.60025  SNutBili --- Wdeficit
  par6 par6 -0.20562  S_SSI4 --- Wdeficit
  par7 par7  0.14871  SNutBili --- com_veg
  par8 par8  0.14905  S_SSI4 --- com_veg
  par9 par9 -0.39164  S_SSI4 --- SNutBili
  --
  View this message in context:
  http://www.nabble.com/SEM%3AStandard-error-of-
  std.coef-estimates--tp23633227p23633227.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
 View this message in context:
http://www.nabble.com/SEM%3AStandard-error-of-
 std.coef-estimates--tp23633227p23636945.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] How to load data from Statistics Canada

2009-05-20 Thread guox
We would like to load data from Statistics Canada
(http://www.statcan.gc.ca/) using R,
for example, Employment and unemployment rates.
It seems to me that the tables are displayed in HTML.
I was wondering if you know how to load these tables. Thanks,

-james

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


[R] Comparing spatial distributions - permutation test implementation

2009-05-20 Thread JiHO

Hello everyone,

I am looking at the joint spatial distribution of 2 kinds of organisms  
(estimated on a grid of points) and want to test for significant  
association or dissociation.


My first question is: do you know a nice technique to do that,  
considering that I have a limited number of points (36) but that they  
are repeated (4 times)? I did GLMs to test for correlations between  
the two (hence forgetting about the spatial aspect of it) and was  
previously pointed to the SADIE software. Would there be anything  
explicitly spatial and available in R please?


Then, Syrjala's test[1] seems appropriate and tests for differences in  
distribution. It computes a Cramér-von Mises-type statistic and tests  
its significance with a permutation test.
I implemented the test in R and posted the code on these mailing  
lists[2]. Some people checked it and confirmed that the statistic  
gives correct results but my estimation of the p-value does not match  
the one predicted with the orignal software from Syrjala. I don't know  
what I am doing wrong. The permutation test is described by Syrjala as:


(...) Under the null hypothesis,
at a given sampling location (x_k, y_k), either density ob-
servation y_i(x_k, y_k), i = 1, 2, is equally likely for each
population. Thus, for a given data set, the distribution
of the test statistic can be constructed by calculating
the value of the test statistic for all 2^k pairwise per-
mutations of the data set. (...) The level of signif-
icance of a specific realization of the test statistic T is
determined from its position in the ordered set of test
statistic values from all 2^k permutations. (...)

My understanding is that, for each permutation I should choose a  
random number of points (between 1 and k), swap the values for species  
1 and species 2 at those points, and recompute the test on the new  
data. But this does not work :/ . Here is my code and associated data  
from Syrjala (for which I have reference values). Any advice would be  
very welcome (in particular if there is a way to leverage boot() for  
this).
NB: computing the 1000 permutations can be a bit lengthy, but  
fortunately, by using plyr, you get a nice progress bar to look at!


syrjala.stat - function(x, y=NULL, var1=NULL, var2=NULL)
#
#   Compute Syrjala statistic
#   x, ycoordinates
#   var1, var2  value of 2 parameters both measured at (x,y) points
#	NB: x can also be a data.frame/matrix containing x,y,var1,var2 as  
columns

#
{
# Input checks
if (!is.null(ncol(x))) {
if (ncol(x) == 4) {
names(x) = c(x,y,var1,var2)
dat = x
} else {
stop(Wrong number of columns in argument x)
}
} else {
dat = data.frame(x, y, var1, var2)
}

# Normalize abundances
dat$var1 = dat$var1/sum(dat$var1)
dat$var2 = dat$var2/sum(dat$var2)

# For each point (each line of dat)
# compute the squared difference in gammas from each origin
meanSqDiff = apply(dat, 1, function(d, coord, variab) {
north = (coord$x=d[1])
east = (coord$y=d[2])
south = (coord$x=d[1])
west = (coord$y=d[2])
return( mean( c(
(diff(sapply(variab[(north  east),], sum)))^2,
(diff(sapply(variab[(south  east),], sum)))^2,
(diff(sapply(variab[(south  west),], sum)))^2,
(diff(sapply(variab[(north  west),], sum)))^2
) )
)
}, dat[,c(x,y)], dat[,c(var1,var2)])

# Compute the statistic (i.e. sum of mean squared differences)
return(sum(meanSqDiff))
}


# Get data online : http://dl.getdropbox.com/u/1047321/syrjala_data_cod.csv
system(curl http://dl.getdropbox.com/u/1047321/syrjala_data_cod.csv   
syrjala_data_cod.csv)


dataCod = read.csv(file = syrjala_data_cod.csv, header = TRUE)

# Normalize abundances
dataCod$var1 = dataCod$var1/sum(dataCod$var1)
dataCod$var2 = dataCod$var2/sum(dataCod$var2)

# Number of permutations
nperm = 1000

# Create nperm-1 replicates of the data (one is the original  
observation)

d = rep(list(dataCod), nperm-1)

# Compute number of observations before to avoid doing that for every  
replicate

n = nrow(dataCod)

require(plyr)
# Permute some observations and compute the syrjala stat for each  
permutation

psis = ldply(d, .fun=function(x, n){
# choose indices of observations to swap
idx = sample(1:n, runif(1, min=1, max=n))
# swap observations
x[idx, 3:4] = x[idx, 4:3]
# compute syrjala stat
return(syrjala.stat(x))
}, n, .progress=text)
}

# Compute the syrjala stat for the observations
psi = syrjala.stat(dataCod)

# 

Re: [R] problem with APPLY

2009-05-20 Thread Peter Dalgaard

De France Henri wrote:

Hello,
 
The apply function seems to behave oddly with my code below
 
NB : H1 is a data frame. (data in the attached file.)

# the first lines are:
1 02/01/2008 0.00  0  0 0.00   0
2 03/01/2008 0.00  0  0 0.00   0
3 04/01/2008 0.00  0  0 0.00   0
4 07/01/2008 0.00  0  0 0.00   0
5 08/01/2008 0.00  0  0 0.00   0
6 09/01/2008 0.00  0  0 0.00   0
7 10/01/2008 0.00  0  0 0.00   0
8 11/01/2008 1.010391  0  0 1.102169   0
...
The aim of the code is to extract those lines for which there is a strictly 
positive value in the second column AND in one of the others:
 
reper=function(x){as.numeric(x[2]1  any(x[3:length(x)]1))}
 
TAB1= H1[which(apply(H1,1,reper)0),]
 
Strangely, this is OK for all the lines, except for the last one. In fact, in H1, the last 2 lines are:

258 29/12/2008 1.476535 1.187615  0 0.00   0
259 30/12/2008 0.00 1.147888  0 0.00   0
Obviously, line 258 should be the last line of TAB1, but it is not the case (it does not appear at 
all) and I really don't understand why. This is all the more strange since applying the function 
reper only to this line 258 gives a 1 as expected...
Can someone help ?
 


Works for me...

   do...1.   V3   V5 V7  V13 V31
213 24/10/2008 2.038218 2.820196  0 0.00   0
214 27/10/2008 3.356057 2.588509  0 2.101651   0
219 03/11/2008 2.122751 1.648410  0 2.180908   0
233 21/11/2008 1.439861 1.883605  0 1.359372   0
234 24/11/2008 1.216548 1.480797  0 1.049390   0
258 29/12/2008 1.476535 1.187615  0 0.00   0

You are crossing the creek to fetch water, though:

reper - function(x) x[2]1  any(x[3:length(x)]1)
TAB1 -  H1[apply(H1,1,reper),]

or even

TAB1 -  H1[ H1[2]  1   apply(H1[3:6]  1, 1, any),]


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

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


[R] Supressing the enumeration of output in console

2009-05-20 Thread ZeMajik
Hi!
Pretty low content question but I've had major trouble finding an answer for
it so I hope it's alright.
I'm obviously new to R, and have been trying to get rid of the numerated
output I get in the console.

What I mean more specifically is that

X-4;X

comes out as

[1] 4

and I'd like to get rid of the listing [1].

This isn't usually a problem when working with the console but when writing
scripts that print out lines of text it gives a rather unattractive output
in the console.

Thanks in advance!
Mike

[[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] Class for time of day?

2009-05-20 Thread Gabor Grothendieck
There is a times class in the chron package.  Times are measured
in fractions of a day so 1/24 is one hour.

 library(chron)
 dt - Sys.time()
 tt - times(format(dt, %H:%M:%S))
 tt
[1] 12:27:46
 tt + 1/24
[1] 13:27:46

There is an article on dates and times in R News 4/1.

On Wed, May 20, 2009 at 10:57 AM, Stavros Macrakis
macra...@alum.mit.edu wrote:
 What is the recommended class for time of day (independent of calendar
 date)?

 And what is the recommended way to get the time of day from a POSIXct
 object? (Not a string representation, but a computable representation.)

 I have looked in the man page for DateTimeClasses, in the Time Series
 Analysis Task View and in Spector's Data Manipulation book but haven't found
 these. Clearly I can create my own Time class and hack around with the
 internal representation of POSIXct, e.g.

    days - unclass(d)/(24*3600)
    days-floor(days)

 and write print.Time, `-.Time`, etc. etc. but I expect there is already a
 standard class or CRAN package.

           -s

        [[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] sem with categorical data

2009-05-20 Thread John Fox
Dear Frank,

Did you take a look at the data you generated? The contingency tables
are extremely sparse. Try, e.g., with(dat, table(q1, q2)). (I assume,
BTW, that you're using the cut2() function in the Hmisc package.)

Beyond that, I'm not sure what the point is of your example. You're
generating three independent lognormal random variables while the model
assumed by polychoric correlation is of multinormal random variables;
of course, these *could* be independent, but generally would not.

I hope this helps,
 John

On Wed, 20 May 2009 12:55:49 -0400
 Frank Lawrence f...@psu.edu wrote:
 I am trying to run a confirmatory factor analysis using the SEM
 package.  My
 data are ordinal.  I have read
 http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf.
 When I apply the hetcor function, I receive the following error:
 Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr
 = corr,
 : 
   at least one element of 'lower' is larger than 'upper'
 
 Example:
 set.seed(781)
 q1 - cut2(x = rlnorm(n = 1e2, m = 2), cuts = seq(1,6))
 q2 - cut2(x = rlnorm(n = 1e2, m = 0), cuts = seq(1,6))
 q3 - cut2(x = rlnorm(n = 1e2, m = 1), cuts = seq(1,6))
 dat - data.frame(q1,q2,q3)
 hetcor(data = dat, ML = T, pd = T, use = 'p')
 
 Any help in understanding and correcting the error would be
 appreciated.
 
 unlist(R.Version())
   platform   arch 
  i386-pc-mingw32 i386 
 os system 
  mingw32i386, mingw32 
 status  major 
 2 
  minor   year 
  9.0 2009 
  monthday 
   04   17 
svn rev   language 
48333R 
 version.string 
 R version 2.9.0 (2009-04-17)
 
 Respectfully,
 
 Frank Lawrence
 
 
 
 


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

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


Re: [R] Supressing the enumeration of output in console

2009-05-20 Thread Greg Snow
Use the 'cat' function to put text on the console without any extra decoration 
(you are then responsible for all formatting including line feeds).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of ZeMajik
 Sent: Wednesday, May 20, 2009 1:04 PM
 To: r-help@r-project.org
 Subject: [R] Supressing the enumeration of output in console
 
 Hi!
 Pretty low content question but I've had major trouble finding an
 answer for
 it so I hope it's alright.
 I'm obviously new to R, and have been trying to get rid of the
 numerated
 output I get in the console.
 
 What I mean more specifically is that
 
 X-4;X
 
 comes out as
 
 [1] 4
 
 and I'd like to get rid of the listing [1].
 
 This isn't usually a problem when working with the console but when
 writing
 scripts that print out lines of text it gives a rather unattractive
 output
 in the console.
 
 Thanks in advance!
 Mike
 
   [[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] How to google for R stuff?

2009-05-20 Thread Joshua Stults
I was having the same frustration so I made a Google custom search
engine for Open Math Tools:
http://www.google.com/coop/cse?cx=015659631714008342946:wolsniqtrxc

It gives preferences to results from r-project.org, octave.org,
maxima.sourceforge.net, and the mailing list archives from those
projects.  It also has some other smaller pages that contain tutorials
for those tools.

It includes results from the broader web as well, so if there is a
highly ranked article from wikipedia or mathworld that will show up
too.

Here's a short write-up with example searches:
http://j-stults.blogspot.com/2009/05/open-math-tools-custom-search-engine.html

If any folks on the list out there have any suggestions or would like
to be a 'contributor' on it post a reply with a site to add to the
preference list , or click the 'volunteer to contribute' link on the
search engine homepage.

Good luck with your R searching.

On Wed, May 20, 2009 at 9:02 AM, Kynn Jones kyn...@gmail.com wrote:
 Hi!  I'm new to R programming, though I've been programming in other
 languages for years.

 One thing I find most frustrating about R is how difficult it is to use
 Google (or any other search tool) to look for answers to my R-related
 questions.  With languages with even slightly more distinctive names like
 Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
 language in the query is enough to ensure that the top hits are relevant.
  But this trick does not work for R, because the letter R appears by itself
 in so many pages, that the chaff overwhelms the wheat, so to speak.

 So I'm curious to learn what strategies R users have found to get around
 this annoyance.

 TIA!

 KJ

        [[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 Stults
Website: http://j-stults.blogspot.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] Class for time of day?

2009-05-20 Thread jim holtman
If you want the hours from a POSIXct, here is one way of doing it; you can
create a function for doing it:

 x - Sys.time()
 x
[1] 2009-05-20 12:17:13 EDT
 y - difftime(x, trunc(x, units='days'), units='hours')
 y
Time difference of 12.28697 hours
 as.numeric(y)
[1] 12.28697

It depends on what type of computations you want to do with it.  You can
leave it as POSIXct and carry out a lot of them.  Can you specify what you
want?


On Wed, May 20, 2009 at 10:57 AM, Stavros Macrakis macra...@alum.mit.eduwrote:

 What is the recommended class for time of day (independent of calendar
 date)?

 And what is the recommended way to get the time of day from a POSIXct
 object? (Not a string representation, but a computable representation.)

 I have looked in the man page for DateTimeClasses, in the Time Series
 Analysis Task View and in Spector's Data Manipulation book but haven't
 found
 these. Clearly I can create my own Time class and hack around with the
 internal representation of POSIXct, e.g.

days - unclass(d)/(24*3600)
days-floor(days)

 and write print.Time, `-.Time`, etc. etc. but I expect there is already a
 standard class or CRAN package.

   -s

[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Dieter Menne
spencerg spencer.graves at prodsyse.com writes:

 de - RSiteSearch.function(differential equation)
 des - RSiteSearch.function(differential equations)
 # With de and des, each finds things missed by the other. 
 de. - de | des # combine into one
 sumDE - packageSum2(de.) # add details on installed packages. 

Should be 

PackageSum2(de.) 

Dieter

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


Re: [R] How to load data from Statistics Canada

2009-05-20 Thread Luc Villandre

g...@ucalgary.ca wrote:

We would like to load data from Statistics Canada
(http://www.statcan.gc.ca/) using R,
for example, Employment and unemployment rates.
It seems to me that the tables are displayed in HTML.
I was wondering if you know how to load these tables. Thanks,

-james

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

Hi James,

I believe a similar issue was covered recently in the following thread:

http://www.nabble.com/import-HTML-tables-td23504282.html#a23517322

If this is not what you need, please go into more details as to what the 
issue at hand may be.


HTH,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

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

2009-05-20 Thread Steve_Friedman


I note that someone asked for help a few weeks ago regarding the ability to
drop empty panels on an xyplot.

I did not see a reply to that inquiry so I am asking for assistance with
the same problem

To prepare the data for the plotting routine, I did the following to
restrict the content of the data object to specific colonies of interest.

  Colony_HSI.df - Colony_HSI[Colony_HSI$Colony == NE Grossman A |
Colony_HSI$Colony == Loop Road | Colony_HSI$Colony == Otter Creek |
   Colony_HSI$Colony == Upper Taylor Slough |
Colony_HSI$Colony == Tamiami West ,]


xyplot(Colony_HSI$MEAN + Colony_HSI$TotalNests ~ Colony_HSI$Year |
Colony_HSI$Colony,  lty=c(1,2), pch=c(1,9),
  par.settings = graph.sets, type = o,  xlab= Year,
ylim=c(0,1),
   ylab=Mean HSI,  drop.unused.levels =
lattice.getOption(drop.unused.levels))


However this produces a plot with 22 panels, but only 5 have data in them.
Am I using the subsetting routines incorrectly? Why are there place
holders in the data object even after I selected for just 5 of them? How
can I build the plot including  just the 5 colony names?

Steve

Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

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


Re: [R] problem with APPLY

2009-05-20 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Dalgaard
 Sent: Wednesday, May 20, 2009 8:16 AM
 To: De France Henri
 Cc: r-help@r-project.org
 Subject: Re: [R] problem with APPLY
 
 De France Henri wrote:
  Hello,
   
  The apply function seems to behave oddly with my code below
   
  NB : H1 is a data frame. (data in the attached file.)
  # the first lines are:
  1 02/01/2008 0.00  0  0 0.00   0
  2 03/01/2008 0.00  0  0 0.00   0
  3 04/01/2008 0.00  0  0 0.00   0
  4 07/01/2008 0.00  0  0 0.00   0
  5 08/01/2008 0.00  0  0 0.00   0
  6 09/01/2008 0.00  0  0 0.00   0
  7 10/01/2008 0.00  0  0 0.00   0
  8 11/01/2008 1.010391  0  0 1.102169   0
  ...
  The aim of the code is to extract those lines for which 
 there is a strictly positive value in the second column AND 
 in one of the others:
   
  reper=function(x){as.numeric(x[2]1  any(x[3:length(x)]1))}
   
  TAB1= H1[which(apply(H1,1,reper)0),]
   
  Strangely, this is OK for all the lines, except for the 
 last one. In fact, in H1, the last 2 lines are:
  258 29/12/2008 1.476535 1.187615  0 0.00   0
  259 30/12/2008 0.00 1.147888  0 0.00   0
  Obviously, line 258 should be the last line of TAB1, but it 
 is not the case (it does not appear at all) and I really 
 don't understand why. This is all the more strange since 
 applying the function reper only to this line 258 gives a 
 1 as expected...
  Can someone help ?
   
 
 Works for me...
 
 do...1.   V3   V5 V7  V13 V31
 213 24/10/2008 2.038218 2.820196  0 0.00   0
 214 27/10/2008 3.356057 2.588509  0 2.101651   0
 219 03/11/2008 2.122751 1.648410  0 2.180908   0
 233 21/11/2008 1.439861 1.883605  0 1.359372   0
 234 24/11/2008 1.216548 1.480797  0 1.049390   0
 258 29/12/2008 1.476535 1.187615  0 0.00   0
 
 You are crossing the creek to fetch water, though:
 
 reper - function(x) x[2]1  any(x[3:length(x)]1)
 TAB1 -  H1[apply(H1,1,reper),]
 
 or even
 
 TAB1 -  H1[ H1[2]  1   apply(H1[3:6]  1, 1, any),]
 
 
 -- 
 O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
   (*) \(*) -- University of Copenhagen   Denmark  Ph:  
 (+45) 35327918
 ~~ - (p.dalga...@biostat.ku.dk)  FAX: 
 (+45) 35327907

I couldn't reproduce the bad result either.  However, it was
more or less by chance that the results were as good as
they were.  The call
apply(myDataFrame, 1, FUN)
does essentially the equivalent of
myMatrix - as.matrix(myDataFrame)
for(i in seq_len(nrow(myMatrix)))
  rowResult[i] - FUN(myMatrix[i,,drop=TRUE])
If myDataFrame contains any factor, character, POSIXt, or
any other non-numeric columns then myMatrix will be a matrix
of character strings.  Each column of myDataFrame is passed
though format() to make those strings, so the precise formatting
of the strings depends on all the other elements of the column
(E.g., one big or small number might cause the whole column to
be formatted in scientific notation).

Your reper() function happened to work because
2.3  0
is interpreted as (I think)
2.3  0
which is TRUE (at least in ASCII).  However, if your cutoff were 0.02
then you might be surprised
 2.30.02
[1] FALSE
because as.character(0.02) is 2e-06.

I think that using apply(MARGIN=1,...) to data.frames is generally
a bad idea and it only really works if all the columns are the same
simple type.  Avoiding it altgether makes for tedious coding like
 H1[ H1[2]  1   (H1[,3]1 | H1[,4]1 | H1[,5]1 | H1[,6]1) ,]
You can also use pmax (parallel max), as in,
 H1[H1[2]1  do.call(pmax, unname(as.list(H1[,3:6])))1, ]
Peter's 2nd solution calls apply(MARGIN=1,...) only on the numeric
part of the data.frame so it works as expected.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.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] Where to find a changelog for the survival package

2009-05-20 Thread Heinz Tuechler
Thank you Richie. I had seen this before, but my impression is that 
it's not up to date. I gave a wrong version number in my previous 
post. I changed from 2.34-1 to 2.35-4. For example, the plot.survfit 
function lost it's legend parameters, but I don't see this in the changelog.


Thanks again,
Heinz

At 14:53 20.05.2009, richard.cot...@hsl.gov.uk wrote:

 since some days I try to use the versions 2.35-4 of the survival
 package instead of versions 2.31, I had installed until now. Several
 changes in print.survfit, plot.survfit and seemingly in the structure
 of ratetabels effect some of my syntax files.
 Is there somewhere a documentation of these changes, besides the code
itself?

It's in the repository on R-Forge.  The latest version is here:
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/survival/Changelog.09?rev=11234root=survivalview=markup

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential information intended
for the addressee(s) only. If this message was sent to you in error,
you must not disseminate, copy or take any action in reliance on it and
we request that you notify the sender immediately by return email.

Opinions expressed in this message and any attachments are not
necessarily those held by the Health and Safety Laboratory or any person
connected with the organisation, save those by whom the opinions were
expressed.

Please note that any messages sent or received by the Health and Safety
Laboratory email system may be monitored and stored in an information
retrieval system.



Scanned by MailMarshal - Marshal's comprehensive email content security
solution. Download a free evaluation of MailMarshal at www.marshal.com



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


Re: [R] How to load data from Statistics Canada

2009-05-20 Thread guox
Yes, XML can help load HTML tables.
As we knew, tables in Bureau of Labor Statistics (http://www.bls.gov/)
can be displayed in HTML and can also be loaded directly using their urls,
for example, ftp://ftp.bls.gov/pub/time.series/wp/
I was wondering if tables in Statist Canada have such locations so that we
load them directly. Thanks,

-james
 g...@ucalgary.ca wrote:
 We would like to load data from Statistics Canada
 (http://www.statcan.gc.ca/) using R,
 for example, Employment and unemployment rates.
 It seems to me that the tables are displayed in HTML.
 I was wondering if you know how to load these tables. Thanks,

 -james

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

 Hi James,

 I believe a similar issue was covered recently in the following thread:

 http://www.nabble.com/import-HTML-tables-td23504282.html#a23517322

 If this is not what you need, please go into more details as to what the
 issue at hand may be.

 HTH,
 --
 *Luc Villandré*
 /Biostatistician
 McGill University Health Center -
 Montreal Children's Hospital Research Institute/




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

2009-05-20 Thread Peter Dalgaard

g...@ucalgary.ca wrote:

We would like to load data from Statistics Canada
(http://www.statcan.gc.ca/) using R,
for example, Employment and unemployment rates.
It seems to me that the tables are displayed in HTML.
I was wondering if you know how to load these tables. Thanks,


I suspect the answer is with some difficulty. You can do stuff like 
this, based on using the clipboard. Go to


http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm

mark the contents of the table, then

 dd - t(read.delim(clipboard, colClasses=character))
 dd1 - dd[-1,] # 1st row are labels
 dd2 - as.numeric(gsub(,,,dd1)) # strip thousands separators
Warning message:
NAs introduced by coercion
 dim(dd2) - dim(dd1)
 dd2
 [,1]  [,2]  [,3]   [,4][,5] [,6]  [,7] [,8] [,9]   [,10] 
[,11]

[1,]   NA 226.8 123.1 2948.0 11630.0 178768.0 122.5   NA 37.6 27822.0  1.760
[2,]   NA 224.6 117.7 2945.0 10709.0 181862.0 121.7   NA 37.1 28822.0  1.750
[3,]   NA 222.0 109.5 2932.0  9694.0 185068.0 121.1   NA 36.9 27801.0  1.730
[4,]   NA 218.8 101.2 2924.0  8968.0 187636.0 120.6   NA 36.7 26560.0  1.690
[5,]   NA 215.6  97.2 2920.0  8759.0 189702.0 120.1   NA 36.4 23762.0  1.640
[6,]   NA 213.3  96.0 2918.0  8770.0 191343.0 119.7   NA 36.2 22029.0  1.600
[7,]   NA  -1.1  -1.2   -0.1 0.1  0.9  -0.3   NA -0.5-7.3 -0.045
 [,12]  [,13]  [,14] [,15]
[1,]NA 2959.0 9637.0 221.8
[2,]NA 2963.0 9635.0 218.4
[3,]NA 2966.0 9587.0 217.1
[4,]NA 2939.0 9368.0 211.2
[5,]NA 2915.0 9325.0 209.4
[6,]NA 2879.0 9199.0 210.5
[7,]NA   -1.2   -1.4   0.5


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

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


[R] Linear constraints for constrasts

2009-05-20 Thread Serguei Kaniovski

Dear List!

How can I define contrasts (design matrix) that can all be included, 
i.e. which do not require a control category be dropped. My application 
(see below) does not suggest a sensible control category. I am thinking 
of constraining the (treatment) contrasts to sum up to zero and dropping 
the constant term in the regression. Is this a good idea? If yes, how to 
achieve this in R?


I am estimating a GLM for bilateral country data. Each observation in on 
a pair of countries, e.g. GER_USA, GER_JAP, USA_JAP. I constructed the 
following contrasts: d_GER, d_USA, d_JAP, which take the value of 1 when 
the country is in the pair and 0 otherwise, i.e.

“Bilat”, “d_GER”, “d_USA”, “d_JAP”
GER_USA, 1, 1, 0
GER_JAP, 1, 0, 1
USA_JAP, 0, 1, 1
These contrasts highlight the effect of having a given country in the pair.

Thank you for your help!
Serguei Kaniovski

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


[R] minmun p-value for wilcox.test and correlation

2009-05-20 Thread charles78

I have a stupid question on how to get the real p-values for wilcox.test and
correlation.  the minmun can be reached is 2.2E-16 using the R version
2.6.2.  I do not think it is the R version causing this but other issues.

Any help is highly appreciated.

Charles
-- 
View this message in context: 
http://www.nabble.com/minmun-p-value-for-wilcox.test-and-correlation-tp23637568p23637568.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] Predicting complicated GAMMs on response scale

2009-05-20 Thread William Paterson

Creation of Animal category in p.d solved all problems. Plots fine now. The
smallest hurdles are often the hardest to get over.


Gavin Simpson wrote:
 
 On Mon, 2009-05-18 at 11:48 -0700, William Paterson wrote:
 Hi,
 
 I am using GAMMs to show a relationship of temperature differential over
 time with a model that looks like this:-
 
 gamm(Diff~s(DaysPT)+AirToC,method=REML) 
 
 where DaysPT is time in days since injury and Diff is repeat measures of
 temperature differentials with regards to injury sites compared to
 non-injured sites in individuals over the course of 0-24 days. I use the
 following code to plot this model on the response scale with 95% CIs
 which
 works fine:-
 
 g.m-gamm(Diff~s(DaysPT)+AirToC,method=REML)
 p.d-data.frame(DaysPT=seq(min(DaysPT),max(DaysPT)))
 p.d$AirToC-(6.7)
 b-predict.gam(g.m$gam,p.d,se=TRUE)
 range-c(min(b$fit-2*b$se.fit),max(b$fit+2*b$se.fit))
 plot(p.d$DaysPT,b$fit,ylim=c(-4,12),xlab=Days post-tagging,ylab=dTmax
 (ºC),type=l,lab=c(24,4,12),las=1,cex.lab=1.5, cex.axis=1,lwd=2)
 lines(p.d$DaysPT,b$fit+b$se.fit*1.96,lty=2,lwd=1.5)
 lines(p.d$DaysPT,b$fit-b$se.fit*1.96,lty=2,lwd=1.5)
 points(DaysPT,Diff)
 
 
 However, when I add a correlation structure and/or a variance structure
 so
 that the model may look like:- 
 
 
 gamm(Diff~s(DaysPT3)+AirToC,correlation=corCAR1(form=~DaysPT|
 Animal),weights=varPower(form=~DaysPT),method=REML)
 
 
 I get this message at the point of inputting the line
 b-predict.gam(g.m$gam,p.d,se=TRUE)
 
 Note that p.d doesn't contain Animal. Not sure this is the problem, but
 I would have thought you'd need to supply new values of Animal for the
 data you wish to predict for in order to get the CAR(1) errors correct.
 Is it possible that the model is finding another Animal variable in the
 global environment?
 
 I have predicted from several thousand GAMMs containing correlation
 structures similar to the way you do above so this does work in general.
 If the above change to p.d doesn't work, you'll probably need to speak
 to Simon Wood to take this further.
 
 Is mgcv up-to-date? I am using 1.5-5 that was released in the last week
 or so.
 
 For example, this dummy example runs without error for me and is similar
 to your model
 
 y1 - arima.sim(list(order = c(1,0,0), ar = 0.5), n = 200, sd = 1)
 y2 - arima.sim(list(order = c(1,0,0), ar = 0.8), n = 200, sd = 3)
 x1 - rnorm(200)
 x2 - rnorm(200)
 ind - rep(1:2, each = 200)
 d - data.frame(Y = c(y1,y2), X = c(x1,x2), ind = ind, time = rep(1:200,
 times = 2))
 require(mgcv)
 mod - gamm(Y ~ s(X), data = d, corr = corCAR1(form = ~ time | ind),
 weights = varPower(form = ~ time))
 p.d - data.frame(X = rep(seq(min(d$X), max(d$X), len = 20), 2),
   ind = rep(1:2, each = 20),
   time = rep(1:20, times = 2))
 pred - predict(mod$gam, newdata = p.d, se = TRUE)
 
 Does this work for you? If not, the above would be a reproducible
 example (as asked for in the posting guide) and might help Simon track
 down the problem if you are running an up-to-date mgcv.
 
 HTH
 
 G
 
 
 
 Error in model.frame(formula, rownames, variables, varnames, extras,
 extranames,  : 
 variable lengths differ (found for 'DaysPT')
 In addition: Warning messages:
 1: not all required variables have been supplied in  newdata!
  in: predict.gam(g.m$gam, p.d, se = TRUE) 
 2: 'newdata' had 25 rows but variable(s) found have 248 rows 
 
 
 Is it possible to predict a more complicated model like this on the
 response
 scale? How can I incorporate a correlation structure and variance
 structure
 in a dataframe when using the predict function for GAMMs?
 
 Any help would be greatly appreciated.
 
 William Paterson
 
 
 
 
 -- 
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
  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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Predicting-complicated-GAMMs-on-response-scale-tp23603248p23639184.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] sem with categorical data

2009-05-20 Thread Frank Lawrence
I am trying to run a confirmatory factor analysis using the SEM package.  My
data are ordinal.  I have read
http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf.
When I apply the hetcor function, I receive the following error:
Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr = corr,
: 
  at least one element of 'lower' is larger than 'upper'

Example:
set.seed(781)
q1 - cut2(x = rlnorm(n = 1e2, m = 2), cuts = seq(1,6))
q2 - cut2(x = rlnorm(n = 1e2, m = 0), cuts = seq(1,6))
q3 - cut2(x = rlnorm(n = 1e2, m = 1), cuts = seq(1,6))
dat - data.frame(q1,q2,q3)
hetcor(data = dat, ML = T, pd = T, use = 'p')

Any help in understanding and correcting the error would be appreciated.

unlist(R.Version())
  platform   arch 
 i386-pc-mingw32 i386 
os system 
 mingw32i386, mingw32 
status  major 
2 
 minor   year 
 9.0 2009 
 monthday 
  04   17 
   svn rev   language 
   48333R 
version.string 
R version 2.9.0 (2009-04-17)

Respectfully,

Frank Lawrence

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] error message re: max(i), but code and output seen O.K.

2009-05-20 Thread Kirsten Miles
I have a researcher who is consistently get the warning message:

In max(i) : no non-missing arguments to max; returning -Inf

Best as I can tell the code is working properly and the output is as
expected. I would like some help in understanding why he is getting this
error message and what its implications are.  I have his code.

Sincerely,
Kirsten Miles
Support Specialist
Research Computing Lab
Charles L. Brown Science and Engineering Library

kd...@virginia.edu

[[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] Example for parsing XML file?

2009-05-20 Thread Brigid Mooney
Hi,

I am trying to parse XML files and read them into R as a data frame,
but have been unable to find examples which I could apply
successfully.

I'm afraid I don't know much about XML, which makes this all the more
difficult.  If someone could point me in the right direction to a
resource (preferably with an example or two), it would be greatly
appreciated.

Here is a snippet from one of the XML files that I am looking to read,
and I am aiming to be able to get it into a data frame with columns N,
T, A, B, C as in the 2nd level of the heirarchy.

  ?xml version=1.0 encoding=utf-8 ?
- C S=UnitA D=1/3/2007 C=24745 F=24648
  T N=1 T=9:30:13 AM A=30.05 B=29.85 C=30.05 /
  T N=2 T=9:31:05 AM A=29.89 B=29.78 C=30.05 /
  T N=3 T=9:31:05 AM A=29.9 B=29.86 C=29.87 /
  T N=4 T=9:31:05 AM A=29.86 B=29.86 C=29.87 /
  T N=5 T=9:31:05 AM A=29.89 B=29.86 C=29.87 /
  T N=6 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
  T N=7 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
  T N=8 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
/C

Thanks for any help or direction anyone can provide.

As a point of reference, I am using R 2.8.1 and have loaded the XML package.

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


[R] Non-linear regression with latent variable

2009-05-20 Thread Samiul Hasan

Hi 
Can anyone please suggest me a package where I can estimate a non-linear
regression model? One of the independent variables is latent or unobserved.
I have an indicator variable for this unobserved variable; however the
relationship is known to be non-linear also. In terms of equations my
problem is

y=f(latent, fixed) 
q=g(latent) where q is the indicator variable

For me both f and g are non-linear.

Thanks
Samiul Hasan


   
-- 
View this message in context: 
http://www.nabble.com/Non-linear-regression-with-latent-variable-tp23641833p23641833.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] minmun p-value for wilcox.test and correlation

2009-05-20 Thread Peter Flom
charles78 hu...@hotmail.com wrote 

I have a stupid question on how to get the real p-values for wilcox.test and
correlation.  the minmun can be reached is 2.2E-16 using the R version
2.6.2.  I do not think it is the R version causing this but other issues.

Any help is highly appreciated.


Can I ask why you want this?

I'm curious.

Peter

Peter L. Flom, PhD
Statistical Consultant
www DOT peterflomconsulting DOT 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] round function seems to produce maximum 2 decimals

2009-05-20 Thread Glenn E Stauffer
I am trying to use round()to force R to display a specific number of
decimals, but it seems to display =2 decimals no matter what I specify in
the digits argument. As an alternative I tried signif(), but it also
produces unexpected results. See example code and results below. Format()
works, but then the result no longer is numeric. Am I missing something
simple?
I am using R 2.9.0 on Windows XP. 
Thanks,
Glenn

#code
h=12345.16711
h

round(h,digits=1)
round(h,digits=2)
round(h,digits=3)
round(h,digits=4)
round(h,digits=5)

signif(h,digits=9)

format(h,nsmall=4)

#results
 h=12345.16711
 h
[1] 12345.17
 round(h,digits=1)
[1] 12345.2
 round(h,digits=2)
[1] 12345.17
 round(h,digits=3)
[1] 12345.17
 round(h,digits=4)
[1] 12345.17
 round(h,digits=5)
[1] 12345.17
 signif(h,digits=9)
[1] 12345.17
 
 format(h,nsmall=4)
[1] 12345.1671

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

2009-05-20 Thread Wacek Kusnierczyk
Peter Dalgaard wrote:
 g...@ucalgary.ca wrote:
 We would like to load data from Statistics Canada
 (http://www.statcan.gc.ca/) using R,
 for example, Employment and unemployment rates.
 It seems to me that the tables are displayed in HTML.
 I was wondering if you know how to load these tables. Thanks,

 I suspect the answer is with some difficulty. You can do stuff like
 this, based on using the clipboard. Go to

or maybe
   
library(XML)
document =
htmlParse('http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm')
rows = xpathSApply(document, '//table/tbody/tr')

and then use further xpaths to extract the content of interest.

vQ


 http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm

 mark the contents of the table, then

  dd - t(read.delim(clipboard, colClasses=character))
  dd1 - dd[-1,] # 1st row are labels
  dd2 - as.numeric(gsub(,,,dd1)) # strip thousands separators
 Warning message:
 NAs introduced by coercion
  dim(dd2) - dim(dd1)
  dd2
  [,1]  [,2]  [,3]   [,4][,5] [,6]  [,7] [,8] [,9]   [,10]
 [,11]
 [1,]   NA 226.8 123.1 2948.0 11630.0 178768.0 122.5   NA 37.6 27822.0 
 1.760
 [2,]   NA 224.6 117.7 2945.0 10709.0 181862.0 121.7   NA 37.1 28822.0 
 1.750
 [3,]   NA 222.0 109.5 2932.0  9694.0 185068.0 121.1   NA 36.9 27801.0 
 1.730
 [4,]   NA 218.8 101.2 2924.0  8968.0 187636.0 120.6   NA 36.7 26560.0 
 1.690
 [5,]   NA 215.6  97.2 2920.0  8759.0 189702.0 120.1   NA 36.4 23762.0 
 1.640
 [6,]   NA 213.3  96.0 2918.0  8770.0 191343.0 119.7   NA 36.2 22029.0 
 1.600
 [7,]   NA  -1.1  -1.2   -0.1 0.1  0.9  -0.3   NA -0.5-7.3
 -0.045
  [,12]  [,13]  [,14] [,15]
 [1,]NA 2959.0 9637.0 221.8
 [2,]NA 2963.0 9635.0 218.4
 [3,]NA 2966.0 9587.0 217.1
 [4,]NA 2939.0 9368.0 211.2
 [5,]NA 2915.0 9325.0 209.4
 [6,]NA 2879.0 9199.0 210.5
 [7,]NA   -1.2   -1.4   0.5

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


Re: [R] error message re: max(i), but code and output seen O.K.

2009-05-20 Thread Sundar Dorai-Raj
This error is thrown if the argument to max is either NULL or length zero:

[~] Rscript -e max(NULL)
[1] -Inf
Warning message:
In max(NULL) : no non-missing arguments to max; returning -Inf
[~] Rscript -e max(numeric(0))
[1] -Inf
Warning message:
In max(numeric(0)) : no non-missing arguments to max; returning -Inf

HTH,

--sundar

On Wed, May 20, 2009 at 11:23 AM, Kirsten Miles sirole@gmail.com wrote:
 I have a researcher who is consistently get the warning message:

 In max(i) : no non-missing arguments to max; returning -Inf

 Best as I can tell the code is working properly and the output is as
 expected. I would like some help in understanding why he is getting this
 error message and what its implications are.  I have his code.

 Sincerely,
 Kirsten Miles
 Support Specialist
 Research Computing Lab
 Charles L. Brown Science and Engineering Library

 kd...@virginia.edu

        [[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] minmun p-value for wilcox.test and correlation

2009-05-20 Thread Peter Dalgaard

charles78 wrote:

I have a stupid question on how to get the real p-values for wilcox.test and
correlation.  the minmun can be reached is 2.2E-16 using the R version
2.6.2.  I do not think it is the R version causing this but other issues.

Any help is highly appreciated.

Charles


It's mainly a printing issue (and to some extent historical, because 
small p-values in the upper tail were generated by subtraction and could 
underflow if  2.2e-16):


 wilcox.test(1:100,101:200)

Wilcoxon rank sum test with continuity correction

data:  1:100 and 101:200
W = 0, p-value  2.2e-16
alternative hypothesis: true location shift is not equal to 0

 wilcox.test(1:100,101:200)$p.value
[1] 2.562144e-34

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

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


Re: [R] error message re: max(i), but code and output seen O.K.

2009-05-20 Thread Rolf Turner


On 21/05/2009, at 6:23 AM, Kirsten Miles wrote:


I have a researcher who is consistently get the warning message:

In max(i) : no non-missing arguments to max; returning -Inf

Best as I can tell the code is working properly and the output is as
expected. I would like some help in understanding why he is getting  
this

error message and what its implications are.  I have his code.


(a) This is not an error message, it is a warning message.

(b) The message says that, in a particular context, all of the
arguments to max() are missing.  Hence you are taking the maximum
of the empty set.  By definition this maximum is -infinity.  (This
makes good sense when you think about it carefully.)

(c) What the implications are is hard to say without knowing what the
code is actually doing.  You say that the output is as expected; this
*probably* means that the definition of the maximum of the empty set
is meshing as it should with the remainder of the calculations.

However if I were doing it, I'd track down the instance where all
of the arguments to max are missing and make sure that the code
really is doing the right thing.  You have to decide what *is*
the right thing.  What *should* happen if all of the arguments are NA?

One way to start tracking down the instance would be to set

options(warn=2)

to change the warning to a real error, and then use traceback() to
see where the error occurred.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2009-05-20 Thread Kynn Jones
Thank you all very much for the so many useful ideas and resources.
KJ

[[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 get remote ESS graphics to work?

2009-05-20 Thread Matthew Keller
Hi all,

My graduate student is logging onto my macpro and running R through
ESS aquamacs (with Mx ssh and then  Mx ess-remote). Everything is
working fine until we get to graphing.

 We are trying to give him the ability to look at graphics
interactively. The ESS manual is not too helpful: If you run X11 (See
Section 13.3.2 [X11], page 68, X-windows) on both the local and remote
machines then you should be able to display the graphs locally by
setting the ‘DISPLAY’ environment variable appropriately.

It's unclear what DISPLAY is appropriate. I have X11 forwarding set up
on my machine (the remote machine). When we try to create a graphic in
his ESS remote process, (e.g., hist(rnorm(50))), we get the following
error:
Error in X11(...
unable to start device X11cairo
In addition: Warning message:
In x11(): unable to open connection to X11 display

Does anyone out there use interactive graphics on their ESS remote
sessions? If so, could you provide any help? We're really stuck and
just need a step-by-step from anyone who knows.

Thank you,

Matt




-- 
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.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] Example for parsing XML file?

2009-05-20 Thread Duncan Temple Lang

Hi Brigid.

Here are a few commands that should do what you want:

bri = xmlParse(myDataFile.xml)

tmp =  t(xmlSApply(xmlRoot(bri), xmlAttrs))[, -1]
dd = as.data.frame(tmp, stringsAsFactors = FALSE,
row.names = 1:nrow(tmp))

And then you can convert the columns to whatever types you want
using regular R commands.

The basic idea is that for each of the child nodes of C,
i.e. the T's, we want the character vector of attributes
which we can get with xmlAttrs().

Then we stack them together into a matrix, drop the N
and then convert the result to a data frame, avoiding
duplicate row names which are all T.

(BTW, make certain the '-' on the second line is not in the XML content.
 I assume that came from bringing the text into mail.)

HTH
  D.


Brigid Mooney wrote:

Hi,

I am trying to parse XML files and read them into R as a data frame,
but have been unable to find examples which I could apply
successfully.

I'm afraid I don't know much about XML, which makes this all the more
difficult.  If someone could point me in the right direction to a
resource (preferably with an example or two), it would be greatly
appreciated.

Here is a snippet from one of the XML files that I am looking to read,
and I am aiming to be able to get it into a data frame with columns N,
T, A, B, C as in the 2nd level of the heirarchy.

  ?xml version=1.0 encoding=utf-8 ?
- C S=UnitA D=1/3/2007 C=24745 F=24648
  T N=1 T=9:30:13 AM A=30.05 B=29.85 C=30.05 /
  T N=2 T=9:31:05 AM A=29.89 B=29.78 C=30.05 /
  T N=3 T=9:31:05 AM A=29.9 B=29.86 C=29.87 /
  T N=4 T=9:31:05 AM A=29.86 B=29.86 C=29.87 /
  T N=5 T=9:31:05 AM A=29.89 B=29.86 C=29.87 /
  T N=6 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
  T N=7 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
  T N=8 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
/C

Thanks for any help or direction anyone can provide.

As a point of reference, I am using R 2.8.1 and have loaded the XML package.

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

2009-05-20 Thread Wacek Kusnierczyk
Brigid Mooney wrote:
 Hi,

 I am trying to parse XML files and read them into R as a data frame,
 but have been unable to find examples which I could apply
 successfully.

 I'm afraid I don't know much about XML, which makes this all the more
 difficult.  If someone could point me in the right direction to a
 resource (preferably with an example or two), it would be greatly
 appreciated.

 Here is a snippet from one of the XML files that I am looking to read,
 and I am aiming to be able to get it into a data frame with columns N,
 T, A, B, C as in the 2nd level of the heirarchy.
   

There might be a simpler approach, but this seems to do:

library(XML)

input = xmlParse(
'?xml version=1.0 encoding=utf-8 ?
  C S=UnitA D=1/3/2007 C=24745 F=24648
  T N=1 T=9:30:13 AM A=30.05 B=29.85 C=30.05 /
  T N=2 T=9:31:05 AM A=29.89 B=29.78 C=30.05 /
  T N=3 T=9:31:05 AM A=29.9 B=29.86 C=29.87 /
  T N=4 T=9:31:05 AM A=29.86 B=29.86 C=29.87 /
  T N=5 T=9:31:05 AM A=29.89 B=29.86 C=29.87 /
  T N=6 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
  T N=7 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
  T N=8 T=9:31:06 AM A=29.89 B=29.85 C=29.86 /
/C')

(output = data.frame(t(xpathSApply(input, '//T', xpathSApply, '@*'
#  N  T A B C
# 1 1 9:30:13 AM 30.05 29.85 30.05
# 2 2 9:31:05 AM 29.89 29.78 30.05
# 3 3 9:31:05 AM  29.9 29.86 29.87
# 4 4 9:31:05 AM 29.86 29.86 29.87
# 5 5 9:31:05 AM 29.89 29.86 29.87
# 6 6 9:31:06 AM 29.89 29.85 29.86
# 7 7 9:31:06 AM 29.89 29.85 29.86
# 8 8 9:31:06 AM 29.89 29.85 29.86

output$N
# [1] 1 2 3 4 5 6 7 8
# Levels: 1 2 3 4 5 6 7 8

you may need to reformat the columns.

vQ

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Emmanuel Charpentier
Le mercredi 20 mai 2009 à 09:02 -0400, Kynn Jones a écrit :
 Hi!  I'm new to R programming, though I've been programming in other
 languages for years.
 
 One thing I find most frustrating about R is how difficult it is to use
 Google (or any other search tool) to look for answers to my R-related
 questions.  With languages with even slightly more distinctive names like
 Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
 language in the query is enough to ensure that the top hits are relevant.
  But this trick does not work for R, because the letter R appears by itself
 in so many pages, that the chaff overwhelms the wheat, so to speak.
 
 So I'm curious to learn what strategies R users have found to get around
 this annoyance.

ISTR having this question or very close ones at least thrice in the last
two months.

Time for a FAQ entry ? (It does not seem to exist : I checked...)

Emmanuel Charpentier

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


[R] combining xYplot with map

2009-05-20 Thread eric.archer
I'm using xYplot to create a bubble plot of values that I'd like to 
visualize on top of a filled-in map of the coast, but I'm too much of a 
lattice (which I understand xYplot is built on) and mapping newbie to 
figure out how to begin to make this happen.  Below is some sample code 
that doesn't work but illustrates my goal.  Any pointers anyone has 
would be much appreciated.  I'm using R v2.9.0 on Windows with Hmisc 
v3.6-0 and maps v2.1-0.


Cheers,
eric

library(Hmisc)
library(maps)

sample.data - data.frame(lat = c(12.1667, 14.6333, -6.874, 2.6167, 
14.6833,

11.2, 3.2667, 11.4167, -13.8623, 13.1667), lon = c(-126.25, -103.4667,
-88.4572, -93.65, -97.7, -88.65, -111.0167, -119.7333, -100.0748,
-108.0333), exp.index = c(23.6266244576543, 2.06824648038330,
0, 1.46378849121688, 24.1824663424805, 0, 0.364600074527829,
4.468039274638, 0.543833744085446, 18.2301918845932))

xlim - c(-150, -80)
ylim - c(-5, 30)
print(xYplot(lat ~ lon, data = sample.data, size = sample.data$exp.index,
xlim = xlim, ylim = ylim
))
map(world, fill = TRUE, col = gray, xlim = xlim, ylim = ylim, add = 
TRUE)


--

Eric Archer, Ph.D.
Southwest Fisheries Science Center
National Marine Fisheries Service
 North Torrey Pines Court
La Jolla, CA 92037-1022
858-546-7121 (work)
858-546-7003 (FAX)

ETP Cetacean Assessment Program: http://swfsc.noaa.gov/prd-etp.aspx
Population ID Program: http://swfsc.noaa.gov/prd-popid.aspx 



Innocence about Science is the worst crime today.
  - Sir Charles Percy Snow

Lighthouses are more helpful than churches.
  - Benjamin Franklin

  ...but I'll take a GPS over either one.
  - John C. Craig George

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


Re: [R] round function seems to produce maximum 2 decimals

2009-05-20 Thread Ted Harding
On 20-May-09 20:10:15, Glenn E Stauffer wrote:
 I am trying to use round()to force R to display a specific number
 of decimals, but it seems to display =2 decimals no matter what I
 specify in the digits argument. As an alternative I tried signif(),
 but it also produces unexpected results. See example code and results
 below.
 Format() works, but then the result no longer is numeric. Am I missing
 something simple?
 I am using R 2.9.0 on Windows XP. 
 Thanks,
 Glenn
 
#code
 h=12345.16711
 h
 
 round(h,digits=1)
 round(h,digits=2)
 round(h,digits=3)
 round(h,digits=4)
 round(h,digits=5)
 
 signif(h,digits=9)
 
 format(h,nsmall=4)
 
#results
 h=12345.16711
 h
 [1] 12345.17
 round(h,digits=1)
 [1] 12345.2
 round(h,digits=2)
 [1] 12345.17
 round(h,digits=3)
 [1] 12345.17
 round(h,digits=4)
 [1] 12345.17
 round(h,digits=5)
 [1] 12345.17
 signif(h,digits=9)
 [1] 12345.17
 
 format(h,nsmall=4)
 [1] 12345.1671

What you're missing is that when you do (e.g.)

  h - 12345.16711
  round(h,digits=4)
# [1] 12345.17

what is displayed ([1] 12345.17) is not the result of round(),
but what the result of round() is to be displayed as given the
options digits=7 (default) for the number of *significant figures*
in the display of stored values.

To see the result as it is stored, you should use print() with
the appropriate number of disgits specified:

  print( round(h,digits=5),10)
# [1] 12345.16711
  print( round(h,digits=4),10)
# [1] 12345.1671
  print( round(h,digits=3),10)
# [1] 12345.167
  print( round(h,digits=2),10)
# [1] 12345.17

Internally, round(h) is correctly stored:

  h4 - round(h,4)
  h - h4
# [1] 1e-05
  h3 - round(h,3)
  h - h3
# [1] 0.00011
  h2 - round(h,2)
  h - h2
# [1] -0.00289

To illustrate the influence of the display option digits=7:

  h-45.16711
  h
# [1] 45.16711
  round(h,digits=4)
# [1] 45.1671
   round(h,digits=3)
# [1] 45.167
  round(h,digits=2)
# [1] 45.17

  h-345.16711
  h
# [1] 345.1671
   round(h,digits=4)
# [1] 345.1671
   round(h,digits=3)
# [1] 345.167
   round(h,digits=2)
# [1] 345.17

  h-2345.16711
  h
# [1] 2345.167
  round(h,digits=4)
# [1] 2345.167
   round(h,digits=3)
# [1] 2345.167
  round(h,digits=2)
# [1] 2345.17

Hoping this helps,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 20-May-09   Time: 22:54:41
-- XFMail --

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


Re: [R] round function seems to produce maximum 2 decimals

2009-05-20 Thread Ben Bolker



Glenn E Stauffer wrote:
 
 I am trying to use round()to force R to display a specific number of
 decimals, but it seems to display =2 decimals no matter what I specify in
 the digits argument. As an alternative I tried signif(), but it also
 produces unexpected results. See example code and results below. Format()
 works, but then the result no longer is numeric. Am I missing something
 simple?
 I am using R 2.9.0 on Windows XP. 
 Thanks,
 Glenn
 
 #code
 h=12345.16711
 h
 
 round(h,digits=1)
 round(h,digits=2)
 round(h,digits=3)
 round(h,digits=4)
 round(h,digits=5)
 
 signif(h,digits=9)
 
 format(h,nsmall=4)
 
 #results
 h=12345.16711
 h
 [1] 12345.17
 round(h,digits=1)
 [1] 12345.2
 round(h,digits=2)
 [1] 12345.17
 round(h,digits=3)
 [1] 12345.17
 round(h,digits=4)
 [1] 12345.17
 round(h,digits=5)
 [1] 12345.17
 signif(h,digits=9)
 [1] 12345.17
 
 format(h,nsmall=4)
 [1] 12345.1671
 
 

options(digits) is set to 7 by default.

 h - 12345.16711
 round(h,digits=5)
[1] 12345.17
 print(h,digits=12)
[1] 12345.16711
 options(digits=12)
 round(h,digits=5)
[1] 12345.16711
 round(h,digits=4)
[1] 12345.1671
 round(h,digits=3)
[1] 12345.167
 round(h,digits=2)
[1] 12345.17

-- 
View this message in context: 
http://www.nabble.com/round-function-seems-to-produce-maximum-2-decimals-tp23643311p23643853.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] error message re: max(i), but code and output seen O.K.

2009-05-20 Thread David Scott

On Wed, 20 May 2009, Kirsten Miles wrote:


I have a researcher who is consistently get the warning message:

In max(i) : no non-missing arguments to max; returning -Inf



You get this message when trying to take the maximum of a vector with no 
elements. I am guessing he is looping through and in some cases getting an 
empty vector.



x - numeric(0)
max(x)

[1] -Inf
Warning message:
In max(x) : no non-missing arguments to max; returning -Inf


David Scott





Best as I can tell the code is working properly and the output is as
expected. I would like some help in understanding why he is getting this
error message and what its implications are.  I have his code.

Sincerely,
Kirsten Miles
Support Specialist
Research Computing Lab
Charles L. Brown Science and Engineering Library

kd...@virginia.edu

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



_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

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


Re: [R] combining xYplot with map

2009-05-20 Thread eric.archer
I'll retract my request for help.  I managed to solve the problem by 
calling map followed by a call to points after rescaling the cex.  Its 
the kind of solution that deserves a head-slap.


library(Hmisc)
library(maps)

sample.data - data.frame(lat = c(12.1667, 14.6333, -6.874, 2.6167, 14.6833,
11.2, 3.2667, 11.4167, -13.8623, 13.1667), lon = c(-126.25, -103.4667,
-88.4572, -93.65, -97.7, -88.65, -111.0167, -119.7333, -100.0748,
-108.0333), exp.index = c(23.6266244576543, 2.06824648038330,
0, 1.46378849121688, 24.1824663424805, 0, 0.364600074527829,
4.468039274638, 0.543833744085446, 18.2301918845932))

xlim - c(-150, -80)
ylim - c(-5, 30)
cex.range - c(1, 5)
exp.range - range(sample.data$exp.index)
exp.cex - diff(cex.range) * sample.data$exp.index / exp.range[2] + 
cex.range[1]

map(world, fill = TRUE, col = gray, xlim = xlim, ylim = ylim)
points(sample.data$lon, sample.data$lat, pch = 21, cex = exp.cex)



eric.archer wrote:
I'm using xYplot to create a bubble plot of values that I'd like to 
visualize on top of a filled-in map of the coast, but I'm too much of 
a lattice (which I understand xYplot is built on) and mapping newbie 
to figure out how to begin to make this happen.  Below is some sample 
code that doesn't work but illustrates my goal.  Any pointers anyone 
has would be much appreciated.  I'm using R v2.9.0 on Windows with 
Hmisc v3.6-0 and maps v2.1-0.


Cheers,
eric

library(Hmisc)
library(maps)

sample.data - data.frame(lat = c(12.1667, 14.6333, -6.874, 2.6167, 
14.6833,

11.2, 3.2667, 11.4167, -13.8623, 13.1667), lon = c(-126.25, -103.4667,
-88.4572, -93.65, -97.7, -88.65, -111.0167, -119.7333, -100.0748,
-108.0333), exp.index = c(23.6266244576543, 2.06824648038330,
0, 1.46378849121688, 24.1824663424805, 0, 0.364600074527829,
4.468039274638, 0.543833744085446, 18.2301918845932))

xlim - c(-150, -80)
ylim - c(-5, 30)
print(xYplot(lat ~ lon, data = sample.data, size = sample.data$exp.index,
xlim = xlim, ylim = ylim
))
map(world, fill = TRUE, col = gray, xlim = xlim, ylim = ylim, add 
= TRUE)




--

Eric Archer, Ph.D.
Southwest Fisheries Science Center
National Marine Fisheries Service
 North Torrey Pines Court
La Jolla, CA 92037-1022
858-546-7121 (work)
858-546-7003 (FAX)

ETP Cetacean Assessment Program: http://swfsc.noaa.gov/prd-etp.aspx
Population ID Program: http://swfsc.noaa.gov/prd-popid.aspx 



Innocence about Science is the worst crime today.
  - Sir Charles Percy Snow

Lighthouses are more helpful than churches.
  - Benjamin Franklin

  ...but I'll take a GPS over either one.
  - John C. Craig George

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