[R] Time series

2014-04-02 Thread Marlin Keith Cox
A simplified ask is:  when I use the time series plot function, R treats
each time on 9/19/13 as an individual day, when clearly it isn't.

Thank you ahead of time.  Keith

ts(chum)
with(chum,plot.ts(Time,PA))

Chum-

  Time PA  9/18/13 18:29 16  9/19/13 13:29 14  9/19/13 16:29 13.2  9/19/13
17:29 13.1  9/19/13 18:29 13  9/20/13 18:29 12  9/21/13 18:29 10  9/22/13
18:29 9  9/23/13 18:29 7  9/24/13 18:29 5  9/25/13 18:29 3  9/26/13
18:29 2  9/27/13
18:29 1


M. Keith Cox, Ph.D.
Principal
MKConsulting
17105 Glacier Hwy
Juneau, AK 99801
U.S. 907.957.4606

[[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] Time series

2014-04-02 Thread Achim Zeileis

On Tue, 1 Apr 2014, Marlin Keith Cox wrote:


A simplified ask is:  when I use the time series plot function, R treats
each time on 9/19/13 as an individual day, when clearly it isn't.


The ts class can handle only regular time series. See the zoo or xts 
packages for dealing with time series that have an irregular time index. 
Here, you could use POSIXct or chron time stamps.



Thank you ahead of time.  Keith

ts(chum)
with(chum,plot.ts(Time,PA))

Chum-

 Time PA  9/18/13 18:29 16  9/19/13 13:29 14  9/19/13 16:29 13.2  9/19/13
17:29 13.1  9/19/13 18:29 13  9/20/13 18:29 12  9/21/13 18:29 10  9/22/13
18:29 9  9/23/13 18:29 7  9/24/13 18:29 5  9/25/13 18:29 3  9/26/13
18:29 2  9/27/13
18:29 1


M. Keith Cox, Ph.D.
Principal
MKConsulting
17105 Glacier Hwy
Juneau, AK 99801
U.S. 907.957.4606

[[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] Time series

2014-04-02 Thread Pascal Oettli
Hello Keith,

Your example is clearly not reproducible and wrong (Chum and chum).
Please use dput() to attach sample dataset.
At first glance, you work with hourly data. Package such as xts
might be more useful.

Regards,
Pascal

On Wed, Apr 2, 2014 at 3:16 PM, Marlin Keith Cox marlink...@gmail.com wrote:
 A simplified ask is:  when I use the time series plot function, R treats
 each time on 9/19/13 as an individual day, when clearly it isn't.

 Thank you ahead of time.  Keith

 ts(chum)
 with(chum,plot.ts(Time,PA))

 Chum-

   Time PA  9/18/13 18:29 16  9/19/13 13:29 14  9/19/13 16:29 13.2  9/19/13
 17:29 13.1  9/19/13 18:29 13  9/20/13 18:29 12  9/21/13 18:29 10  9/22/13
 18:29 9  9/23/13 18:29 7  9/24/13 18:29 5  9/25/13 18:29 3  9/26/13
 18:29 2  9/27/13
 18:29 1


 M. Keith Cox, Ph.D.
 Principal
 MKConsulting
 17105 Glacier Hwy
 Juneau, AK 99801
 U.S. 907.957.4606

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



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] pre-allocation not always a timesaver

2014-04-02 Thread Henrik Bengtsson
I don't think you got a response to this one;

x - array(dim=(c(j, n)))
for (i in 1:n) {
x[,i] - rnorm(j)
}

Note that array() allocates a logical array by default, which means
that in your first iteration (i==1) it has to be coerced to a double
array before assigning the value of rnorm(). That takes time. It also
takes time to garbage collect the stray logical array afterward.
Using,

x - array(NA_real_, dim=(c(j, n)))
for (i in 1:n) {
x[,i] - rnorm(j)
}

avoids this.

For updating list elements, you can avoid repetitive overhead from $-
and $ by replacing:

   a$myx - array(dim=c(j, n))
for (i in 1:n) {
   a$myx[,i] - rnorm(j)
}
a$myx

with

   myx - array(NA_real, dim=c(j, n))
for (i in 1:n) {
   myx[,i] - rnorm(j)
}
a$myx - myx
myx

Similarly for S4 slots and @- and @.

/Henrik

On Thu, Feb 27, 2014 at 7:53 PM, Ross Boylan r...@biostat.ucsf.edu wrote:
 The R Inferno advises that if you are building up results in pieces it's
 best to pre-allocate the result object and fill it in.  In some testing,
 I see a benefit with this strategy for regular variables.  However, when
 the results are held by a class, the opposite seems to be the case.

 Comments?  Explanations?

 Possibly for classes any update causes the entire object to be
 replaced--perhaps to trigger the validation machinery?--and so
 preallocation simply means on average a bigger object is being
 manipulated.

 Here is some test code, with CPU seconds given in the comments.  I tried
 everything twice in case there was some first-time overhead such as
 growing total memory in the image.  When the 2 times differed noticeably
 I reported both values.

 # class definitions
 refbase - setRefClass(refBase, fields = list(dispatch=ANY, myx=ANY),
methods = list( initialize = function(x0=NULL, ...) {
usingMethods(foo)
dispatch - foo
myx - x0
}
 # some irrelevant methods edited out
))

 myclass - setClass(simple, representation=list(myx=ANY))

 ### Method 1: regular variables
 pre - function(n, j=1000) {
 x - array(dim=(c(j, n)))
 for (i in 1:n) {
 x[,i] - rnorm(j)
 }
 x
 }
 system.time(pre(1000)) #0.3s

 nopre - function(n, j=1000) {
 x - numeric(0)
 for (i in 1:n)
 x - c(x, rnorm(j))
 x
 }

 system.time(nopre(1000))  # 2.0s, 2.7s

 # Method 2: with ref class
 pre2 - function(n, j=1000) {
 a - refbase(x0=numeric(0))
 a$myx - array(dim=c(j, n))
 for (i in 1:n) {
 a$myx[,i] - rnorm(j)
 }
 a$myx
 }
 system.time(pre2(1000)) # 4.0 s

 nopre2 - function(n, j=1000) {
 a - refbase(x0=numeric(0))
 for (i in 1:n)
 a$myx - c(a$myx, rnorm(j))
 a$myx
 }
 system.time(nopre2(1000)) # 2.9s, 4.3

 # Method 3: with regular class
 pre3 - function(n, j=1000) {
 a - myclass()
 a@myx - array(dim=c(j, n))
 for (i in 1:n) {
 a@myx[,i] - rnorm(j)
 }
 a@myx
 }
 system.time(pre3(1000)) # 7.3 s

 nopre3 - function(n, j=1000) {
 a - myclass(myx=numeric(0))
 for (i in 1:n)
 a@myx - c(a@myx, rnorm(j))
 a@myx
 }
 system.time(nopre3(1000))  # 4.2s

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Difficulty coding time-forced functions in deSolve

2014-04-02 Thread Thomas Petzoldt

On 4/2/2014 5:51 AM, Aimee Kopolow wrote:


Any pointers as to how I can code a function that relies on solutions
from previous time steps?


Such a system would be called a delay differential equation (DDE). It 
can be solved with the dede function, see ?dede for details.


However if you want to model something like this:

 Explicitly:
 I want to introduce vaccination 7 days after the proportion of I2/N2
 reaches 0.01.


Than this is called root finding, that can be combined with events, 
see example EVENTS triggered by a root function in ?events.


More can be found in the papers listed at:

http://desolve.r-forge.r-project.org

... or you may consider to ask the R-sig-dynamic models mailing list:

https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models

Hope it helps

Thomas Petzoldt

Dr. Thomas Petzoldt
Technische Universitaet Dresden
Faculty of Environmental Sciences
Institute of Hydrobiology
01062 Dresden, Germany

http://tu-dresden.de/Members/thomas.petzoldt

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


Re: [R] A vector of normal distributed values with a sum-to-zero constraint

2014-04-02 Thread Frede Aakmann Tøgersen
Hi Marc

I think that we could help you better if we knew in which context you need 
sample from a sum constrained normal distribution. However this is more a 
question on probability theory than on how to do it in R.

The proposal so far has been linear transformation of multivariate normal 
distribution (Marc, Rui), mixture of normal and reflected normal distribution 
(Boris, try that with e.g. mu = 2), normal distribution mixed with single point 
with positive mass (Jlucke), degenerated normal distribution (Greg).

What you in fact want to do is to draw samples from a conditional distribution. 
The condition is the sum constraint so if we have x = (x1, x2, ..., xn) then 
sum_{i=1}^n xi = 0 or x1 + x2 + ... x{n-1} = xn so you want to draw samples 
from P(x given that x is normal distributed and sum(x)=0). The sum constraint 
gives in fact what is called distributions on the simplex. Google for normal 
distribution simplex and you will get almost 2 mill hits. The second shows how 
to sample using Gibbs sampling 
(http://dobigeon.perso.enseeiht.fr/papers/Dobigeon_TechReport_2007b.pdf).

However you can probably just use other distributions given sum constraint 
since you say that you only need the sample as initial values for a MCMC 
algorithm. Many methods are available from compositional statistics (google 
for that, Aitchison 1986 is the pioneer). 

At least two packages are available for R:compositions with the latest 
version from 2013 and can be found in the archives and robComposition still 
maintained.

Hope that helps, it is help for yourself to find a solution.


Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance  Modeling

Technology  Service Solutions
T +45 9730 5135
M +45 2547 6050
fr...@vestas.com
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Marc Marí Dell'Olmo
 Sent: 1. april 2014 16:57
 To: Boris Steipe
 Cc: r-help@r-project.org
 Subject: Re: [R] A vector of normal distributed values with a sum-to-zero
 constraint
 
 Boris is right. I need this vector to include as initial values of a
 MCMC process (with openbugs) and If I use this last approach sum(x)
 could be a large (or extreme) value and can cause problems.
 
 The other approach x - c(x, -x) has the problem that only vectors
 with even values are obtained.
 
 Thank you!
 
 
 2014-04-01 16:25 GMT+02:00 Boris Steipe boris.ste...@utoronto.ca:
  But the result is not Normal. Consider:
 
  set.seed(112358)
  N - 100
  x - rnorm(N-1)
  sum(x)
 
  [1] 1.759446   !!!
 
  i.e. you have an outlier at 1.7 sigma, and for larger N...
 
  set.seed(112358)
  N - 1
  x - rnorm(N-1)
  sum(x)
  [1] -91.19731
 
  B.
 
 
  On 2014-04-01, at 10:14 AM, jlu...@ria.buffalo.edu wrote:
 
  The sum-to-zero constraint imposes a loss of one degree of freedom.  Of
 N samples, only (N-1) can be random.   Thus the solution is
   N - 100
   x - rnorm(N-1)
   x - c(x, -sum(x))
   sum(x)
  [1] -7.199102e-17
 
  
 
 
 
 
 
 
 
 
  Boris Steipe boris.ste...@utoronto.ca
  Sent by: r-help-boun...@r-project.org
  04/01/2014 09:29 AM
 
  To
  Marc Marí Dell'Olmo marceivi...@gmail.com,
  cc
  r-help@r-project.org r-help@r-project.org
  Subject
  Re: [R] A vector of normal distributed values with a sum-to-zero
 constraint
 
 
 
 
 
  Make a copy with opposite sign. This is Normal, symmetric, but no longer
 random.
 
   set.seed(112358)
   x - rnorm(5000, 0, 0.5)
   x - c(x, -x)
   sum(x)
   hist(x)
 
  B.
 
  On 2014-04-01, at 8:56 AM, Marc Marí Dell'Olmo wrote:
 
   Dear all,
  
   Anyone knows how to generate a vector of Normal distributed values
   (for example N(0,0.5)), but with a sum-to-zero constraint??
  
   The sum would be exactly zero, without decimals.
  
   I made some attempts:
  
   l - 100
   aux - rnorm(l,0,0.5)
   s - sum(aux)/l
   aux2 - aux-s
   sum(aux2)
   [1] -0.0006131392
  
   aux[1]- -sum(aux[2:l])
   sum(aux)
   [1] -0.03530422
  
  
   but the sum is not exactly zero and not all parameters are N(0,0.5)
   distributed...
  
   Perhaps is obvious but I can't find the way to do it..
  
   Thank you very much!
  
   Marc
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, 

Re: [R] A vector of normal distributed values with a sum-to-zero constraint

2014-04-02 Thread peter dalgaard

On 01 Apr 2014, at 17:22 , Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,
 
 One way is to use ?scale.
 

...except that the sd will be less than 0.5 (not obvious at n=1e6, though). 
However, if you want

- normal distribution
- symmetry
- constant marginal variance of sigma^2
- fixed sum = 0 

I don't see any way more straightforward than generating n normal variates and 
subtracting the mean. The only snag is that the variance of a residual is 
sigma^2(1-1/n), so generate the original data with a variance of 
sigma^2/(1-1/n) = n/(n-1) sigma^2

I.e.

x - rnorm(n,0,0.5*sqrt(n/(n-1)))
x - x - mean(x) 

All of this applies within the boundaries of numerical precision. You're not 
going to beat the FPU:

 n - 1e6
 x - rnorm(n,0,0.5*sqrt(n/(n-1)))
 x - x - mean(x) 
 sum(x)
[1] -1.625718e-11
 mean(x)
[1] -1.452682e-17

The problem of getting a sum or mean of _exactly_ 0 is just not well-defined, 
since sums and averages depend on the summation order:

 sum(x)
[1] -1.625718e-11
 sum(sample(x))
[1] -1.624851e-11
 sum(sort(x))
[1] -1.508771e-11
 sum(rev(sort(x)))
[1] -1.599831e-11


 


 set.seed(4867)
 l - 100
 aux - rnorm(l, 0, 0.5)
 aux - scale(aux, scale = FALSE)
 sum(aux)
 
 hist(aux, prob = TRUE)
 curve(dnorm(x, 0, 0.5), from = -2, to = 2, add = TRUE)
 
 Hope this helps,
 
 Rui Barradas
 
 Em 01-04-2014 16:01, jlu...@ria.buffalo.edu escreveu:
 Then what's wrong with centering your initial values around the mean?
 
 
 
 Marc Marí Dell'Olmo marceivi...@gmail.com
 04/01/2014 10:56 AM
 
 To
 Boris Steipe boris.ste...@utoronto.ca,
 cc
 jlu...@ria.buffalo.edu, r-help@r-project.org r-help@r-project.org
 Subject
 Re: [R] A vector of normal distributed values with a sum-to-zero
 constraint
 
 
 
 
 
 
 Boris is right. I need this vector to include as initial values of a
 MCMC process (with openbugs) and If I use this last approach sum(x)
 could be a large (or extreme) value and can cause problems.
 
 The other approach x - c(x, -x) has the problem that only vectors
 with even values are obtained.
 
 Thank you!
 
 
 2014-04-01 16:25 GMT+02:00 Boris Steipe boris.ste...@utoronto.ca:
 But the result is not Normal. Consider:
 
 set.seed(112358)
 N - 100
 x - rnorm(N-1)
 sum(x)
 
 [1] 1.759446   !!!
 
 i.e. you have an outlier at 1.7 sigma, and for larger N...
 
 set.seed(112358)
 N - 1
 x - rnorm(N-1)
 sum(x)
 [1] -91.19731
 
 B.
 
 
 On 2014-04-01, at 10:14 AM, jlu...@ria.buffalo.edu wrote:
 
 The sum-to-zero constraint imposes a loss of one degree of freedom.  Of
  N samples, only (N-1) can be random.   Thus the solution is
 N - 100
 x - rnorm(N-1)
 x - c(x, -sum(x))
 sum(x)
 [1] -7.199102e-17
 
 
 
 
 
 
 
 
 
 
 Boris Steipe boris.ste...@utoronto.ca
 Sent by: r-help-boun...@r-project.org
 04/01/2014 09:29 AM
 
 To
 Marc Marí Dell'Olmo marceivi...@gmail.com,
 cc
 r-help@r-project.org r-help@r-project.org
 Subject
 Re: [R] A vector of normal distributed values with a sum-to-zero
 constraint
 
 
 
 
 
 Make a copy with opposite sign. This is Normal, symmetric, but no
 longer random.
 
  set.seed(112358)
  x - rnorm(5000, 0, 0.5)
  x - c(x, -x)
  sum(x)
  hist(x)
 
 B.
 
 On 2014-04-01, at 8:56 AM, Marc Marí Dell'Olmo wrote:
 
 Dear all,
 
 Anyone knows how to generate a vector of Normal distributed values
 (for example N(0,0.5)), but with a sum-to-zero constraint??
 
 The sum would be exactly zero, without decimals.
 
 I made some attempts:
 
 l - 100
 aux - rnorm(l,0,0.5)
 s - sum(aux)/l
 aux2 - aux-s
 sum(aux2)
 [1] -0.0006131392
 
 aux[1]- -sum(aux[2:l])
 sum(aux)
 [1] -0.03530422
 
 
 but the sum is not exactly zero and not all parameters are N(0,0.5)
 distributed...
 
 Perhaps is obvious but I can't find the way to do it..
 
 Thank you very much!
 
 Marc
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.
 
 
  [[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 

[R] Strange sprintf Behavior

2014-04-02 Thread Michael Smith
All,

I'm getting this:

 sprintf(%.17f, 0.8)
[1] 0.80004

Where does the `4` at the end come from? Shouldn't it be zero at the
end? Maybe I'm missing something.

 sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-redhat-linux-gnu (64-bit)

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

[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8
LC_IDENTIFICATION=C

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


Thanks,

M

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

2014-04-02 Thread Zsurzsa Laszlo
Good morning everyone,


I'm having the following error when I try to load the *mzR* libary. Does
someone have a clue where to search for a solution. I tried to re-install *mzR
*and *Rcpp* also, but with no effect.

-
 library(mzR)
Lade nötiges Paket: Rcpp
Error : .onLoad in loadNamespace() für 'mzR' fehlgeschlagen, Details:
  Aufruf: value[[3L]](cond)
  Fehler: failed to load module Ramp from package mzR
kann Vektor der Größe 13.2 GB nicht allozieren
Zusätzlich: Warnmeldungen:
1: In fun(libname, pkgname) :
   mzR has been built against a different Rcpp version
 than is installed on your system. This might lead to errors
 when loading mzR. If you encounter such issues, please send
 a report, including the output of sessionInfo() to the Bioc
 mailing list -- http://www.bioconductor.org/help/mailing-list.
2: In Module(m, pkg, mustStart = TRUE) :
  Reached total allocation of 8183Mb: see help(memory.size)
3: In Module(m, pkg, mustStart = TRUE) :
  Reached total allocation of 8183Mb: see help(memory.size)
4: In Module(m, pkg, mustStart = TRUE) :
  Reached total allocation of 8183Mb: see help(memory.size)
5: In Module(m, pkg, mustStart = TRUE) :
  Reached total allocation of 8183Mb: see help(memory.size)
Fehler: Laden von Paket oder Namensraum für 'mzR' fehlgeschlagen
 sessionInfo()
R version 3.0.3 (2014-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

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

other attached packages:
[1] Rcpp_0.11.1

loaded via a namespace (and not attached):
[1] Biobase_2.20.1 BiocGenerics_0.6.0 parallel_3.0.3
-


Best Regards, László-András Zsurzsa
Master of Informatics Student,
Technical University Munich, Germany

[[alternative HTML version deleted]]

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


Re: [R] Strange sprintf Behavior

2014-04-02 Thread Marc Schwartz

On Apr 2, 2014, at 6:32 AM, Michael Smith my.r.h...@gmail.com wrote:

 All,
 
 I'm getting this:
 
 sprintf(%.17f, 0.8)
 [1] 0.80004
 
 Where does the `4` at the end come from? Shouldn't it be zero at the
 end? Maybe I'm missing something.


Hi,

First, please start a new thread when posting, do not just reply to an existing 
thread and change the subject line. Your post gets lost in the archive and is 
improperly linked to other posts.

Second, see the Most Frequently Asked Question:

  
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

Regards,

Marc Schwartz

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


[R] gradientForest input data structure

2014-04-02 Thread Sean Porter
Dear All,

Following on from my last post (randomForest warning: The response has five
or fewer unique values. Are you sure you want to do regression?) which
presented two problems whilst trying to conduct a gradientForest regression,
the warning I got was not an issue as Andy kindly pointed out, but I still
have the second problem relating to the data structure of my input data and
I would really appreciate your help on this. I think this is simply a data
structure issue and nothing specific to gradientForest.

I am a relative beginner to R (also not a mathematician) and have tried to
figure out how the data is structured to get the analysis to work but to no
avail. I can run the analysis with the data provided within the
gradientForest package according to the instructions but when I try it with
my own data it doesn’t work and it does not consider all the response
variables (please see output in the previous post below). So my
understanding is that gradientForest regression requires a set of response
variables and a set of predictor variables which then need to be combined.
The structure of the predictor variables according to the example data
accompanying the gradientForest package is:

load(GZ.phys.site.Rdata)
 str(Phys_site)
'data.frame':   197 obs. of  28 variables:
 $ BATHY  : num  -16.7 -26.6 -32.8 -32.5 -29.7 ...
 $ SLOPE  : num  0.505 0.784 0.12 0.332 0.467 ...
 $ ASPECT : num  234 116 192 172 230 ...
 $ BSTRESS: num  0.218 0.248 0.322 0.374 0.425 ...
 $ CRBNT  : num  98.5 98 98.9 98.3 97.9 ...
 $ GRAVEL : num  39.3 39.2 30 42.4 38.8 ...
 $ SAND   : num  59.7 59.8 63.9 54.9 62.7 ...
 $ MUD: num  3.16e-07 2.76e-02 5.17 9.22e-01 2.38 ...
 $ NO3_AV : num  0.24 0.3 0.24 0.26 0.3 0.24 0.25 0.24 0.23 0.25 ...
 $ NO3_SR : num  0.33 0.39 0.29 0.16 0.2 0.33 0.31 0.35 0.39 0.19 ...
 $ PO4_AV : num  0.15 0.15 0.15 0.15 0.16 0.16 0.16 0.16 0.15 0.15 ...
 $ PO4_SR : num  0.08 0.08 0.07 0.05 0.08 0.07 0.07 0.08 0.08 0.06 ...
 $ O2_AV  : num  4.42 4.44 4.39 4.35 4.33 4.38 4.34 4.37 4.4 4.34 ...
 $ O2_SR  : num  0.4 0.49 0.28 0.26 0.24 0.32 0.27 0.36 0.43 0.24 ...
 $ S_AV   : num  34.9 34.9 35 34.9 34.9 ...
 $ S_SR   : num  1.47 1.29 1.64 1.57 1.58 1.8 1.94 1.81 1.7 1.83 ...
 $ T_AV   : num  28.2 28 28.3 28.6 28.5 ...
 $ T_SR   : num  2.19 2.79 1.8 1.99 2.12 2.03 2.12 2.18 2.15 2.23 ...
 $ Si_AV  : num  2.33 2.67 2.25 1.26 1.21 2.39 2.34 2.46 2.6 1.6 ...
 $ Si_SR  : num  4.3 4.96 3.59 2.59 2.64 3.92 3.56 4.32 4.88 2.97 ...
 $ CHLA_AV: num  0.499 0.499 0.455 0.594 0.594 ...
 $ CHLA_SR: num  0.55 0.55 0.669 1.258 1.258 ...
 $ K490_AV: num  0.0726 0.0726 0.0672 0.075 0.075 ...
 $ K490_SR: num  0.0489 0.0489 0.0594 0.0732 0.0732 ...
 $ SST_AV : num  27 27 26.9 26.9 26.9 ...
 $ SST_SR : num  4.85 4.85 4.81 4.81 4.81 ...
 $ BIR_AV : num  0.1735 0.0688 0.2397 0.4476 0.5169 ...
 $ BIR_SR : num  0.1563 0.0885 0.2249 0.2667 0.256 ...

Which seems to correspond to the structure of my predictor variables, so I
don’t think this is the problem:

str(enviro)
'data.frame':   14 obs. of  8 variables:
 $ Temperature : num  24.8 24.4 24.3 23 24.6 24.6 24.8 24.9 24.3
24.5 ...
 $ Turbidity   : num  0.047 0.046 0.052 0.058 0.049 0.047 0.047
0.049 0.049 0.051 ...
 $ Chlorophyll : num  0.24 0.23 0.29 0.26 0.25 0.23 0.23 0.28 0.3
0.29 ...
 $ Waveheight  : num  2.14 2.13 2.12 2.12 2.12 2.12 2.11 2.12 2.11
2.12 ...
 $ nLw551  : num  0.231 0.228 0.228 0.236 0.226 ...
 $ nLw667  : num  1e-04 8e-04 1e-03 1e-03 1e-03 1e-04 1e-04
1e-03 1e-03 1e-04 ...
 $ Sediment.nlw551.667.: num  0.231 0.229 0.229 0.237 0.227 ...
 $ Depth   : num  4.8 4.1 5 4 6.2 7.7 10.1 4.3 5.1 7.9 ...

 BUT my set of response variables seems to be in the wrong structure and
this is I think the problem and where I need help. This is the structure of
the example data provided with gradientForest:

 load(GZ.sps.mat.Rdata)
 str(Sp_mat)
 num [1:197, 1:110] 1.04 -2.11 -3.43 -2.36 -1.15 ...
 - attr(*, dimnames)=List of 2
  ..$ : chr [1:197] 1 2 3 4 ...
  ..$ : chr [1:110] A1010102 A1010113 A1010206 A1010209 ...

And this is the structure that my response variables are currently in
(essentially a matrix created from Excel with rows indicating sites (14 of
them) and coloumns indicating species (100 hundred of them) abbundances
occuring at these sites (Header = TRUE):

 # data structure of biological data
 str(biological)
'data.frame':   14 obs. of  100 variables:
 $ a : num  0 0 0 0 0 0 0 0 0 0 ...
 $ b : num  0 0 0 0 257 ...
 $ c : int  0 0 0 0 0 0 441 0 0 0 ...
 $ d : num  179 0 1430 0 0 ...
 $ e : num  100 0 601 0 123 ...
 $ f : num  0 0 3 0 1.5 0 0 0 0 4.5 ...
 $ g : num  0 0 0 0 0 0 0 0 0 0 ...
 $ h : int  0 0 0 0 0 0 0 0 1 0 ...
 $ i : num  0 0 0 0 0 0 0 0 0 3.85 ...
 $ j : num  0 0 0 27.6 3.6 ...
 $ k : num  0 0 0 0 0 0 0 0 0 1.8 ...
 $ l : num  0 0 0 0 0 0 0 0 0 0 ...
 $ m : num  0 0 0 0 0 0 0 0 0 0 ...
 $ n : num  0 0 0 0 0 0 0 1.1 0 0 ...
 $ o : num  0 0 0 0 0 0.2 0 0 0 0 ...
 $ p : num  0 0.15 0 

[R] Survey

2014-04-02 Thread Leandro Marino
Dear R-Users,

I was using survey for the past years and now I am experiencing some
problems with scripts that was working in the past.

We are working with big data bases so I can't put all variables that I will
use in the svydesign.


Script working:
 data(api)

 dclus1-svydesign(id=apiclus1$dnum, weights=apiclus1$pw, fpc=apiclus1$fpc)
 svyby(apiclus1$api99,apiclus1$stype, dclus1, svymean)
  by   V1   se
E  E 607.7917 22.81660
H  H 595.7143 41.76400
M  M 608.6000 32.56064
 svyby(apiclus1$api99,~apiclus1$stype, dclus1, svymean)
  apiclus1$stype   V1   se
E  E 607.7917 22.81660
H  H 595.7143 41.76400
M  M 608.6000 32.56064

 dclus1-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
 svyby(~api99, ~stype, dclus1, svymean)
  stypeapi99 se.api99
E E 607.7917 22.81660
H H 595.7143 41.76400
M M 608.6000 32.56064

 sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
 LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C   LC_TIME=Portuguese_Brazil.1252

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

other attached packages:
[1] gdata_2.8.2 survey_3.26 foreign_0.8-42  SOAR_0.99-8
svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2
[8] Hmisc_3.8-3 survival_2.36-2

loaded via a namespace (and not attached):
[1] cluster_1.14.1  grid_2.12.1 gtools_2.6.2lattice_0.19-33
svMisc_0.9-63   tools_2.12.1



script not working:

 data(api)

 dclus1-svydesign(id=apiclus1$dnum, weights=apiclus1$pw, fpc=apiclus1$fpc)
 svyby(apiclus1$api99,apiclus1$stype, dclus1, svymean)
Erro em svyby.default(apiclus1$api99, apiclus1$stype, dclus1, svymean) :
  objeto 'byfactor' não encontrado
 svyby(apiclus1$api99,~apiclus1$stype, dclus1, svymean)
Erro em svyby.default(apiclus1$api99, ~apiclus1$stype, dclus1, svymean) :
  objeto 'byfactor' não encontrado

 dclus1-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
 svyby(~api99, ~stype, dclus1, svymean)
  stypeapi99   se
E E 607.7917 22.81660
H H 595.7143 41.76400
M M 608.6000 32.56064
 sessionInfo()
R version 3.0.3 (2014-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
 LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
LC_TIME=Portuguese_Brazil.1252

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

other attached packages:
[1] survey_3.29-5

loaded via a namespace (and not attached):
[1] tools_3.0.3


[[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] Strange sprintf Behavior

2014-04-02 Thread Jeff Newmiller
It is poor netiquette to reply to a thread with a different subject. Please 
start a new thread for a new subject.

As for your question, see FAQ 7.31. This is standard floating point numerical 
limitations at work.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On April 2, 2014 4:32:26 AM PDT, Michael Smith my.r.h...@gmail.com wrote:
All,

I'm getting this:

 sprintf(%.17f, 0.8)
[1] 0.80004

Where does the `4` at the end come from? Shouldn't it be zero at the
end? Maybe I'm missing something.

 sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-redhat-linux-gnu (64-bit)

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

[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8
LC_IDENTIFICATION=C

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


Thanks,

M

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot: add points selectively to curves

2014-04-02 Thread Michael Friendly
I'm working on an example of plotting predicted probabilities from a 
proportional odds model.
The steps below generate a data frame, plotdat, that I want to plot with 
ggplot.


library(MASS)
data(Arthritis, package=vcd)
arth.polr - polr(Improved ~ Sex + Treatment + Age, data=Arthritis, 
Hess=TRUE)


# get predicted probs for categories of Improve
arth.fitp - cbind(Arthritis,
  predict(arth.polr, type=probs))
head(arth.fitp)

# reshape probs to long
library(reshape2)
plotdat - melt(arth.fitp,
id.vars = c(Sex, Treatment, Age, Improved),
measure.vars=c(None, Some, Marked),
variable.name = Level,
value.name = Probability)
## view first few rows
head(plotdat)

 head(plotdat)
   Sex Treatment Age Improved Level Probability
1 Male   Treated  27 Some  None   0.7326185
2 Male   Treated  29 None  None   0.7174048
3 Male   Treated  30 None  None   0.7096042
4 Male   Treated  32   Marked  None   0.6936286
5 Male   Treated  46   Marked  None   0.5702499
6 Male   Treated  58   Marked  None   0.4563432

In the plot step, I am plotting Probability vs. Age, stratified by 
Level, and faceted by

Sex and Treatment.  My question concerns the use of geom_point().
The call below plots 3 points for each case, one on each Level curve.


ggplot(plotdat, aes(x = Age, y = Probability, color = Level)) +
geom_line(size=2.5) + theme_bw() + xlim(10,80) +
geom_point(color=black, size=1.5) +
facet_grid(Sex ~ Treatment,
   labeller = function(x, y) sprintf(%s = %s, x, y)
   )

Instead,
I want to plot only one point for each case, for the value of Level that 
corresponds

to the value of Improved in this data set.  Somehow, this involves something
like an aes() argument to geom_point(), with Level indexed by Improved, 
or some such.

How can I do this?

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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

2014-04-02 Thread Elizabeth Caron-Gamache
Hi, 

I search on your website for a definition of the CORDIF test, but it wasn’t 
successful. I’m analyzing an article that use that test and it’s not really 
documented on the net. The article refers to your website, so I pretend that 
you will be able to give me a brief explanation of this test. Here is the cote 
that talk about this test in my article : 

‘' To compare these regressions and to see which—either body height or LLL—is 
best related to performance (Pearson correlation coefficients comparison), a 
CORDIF test (R software [www.r-project.org], multilevel package, ver- sion 
2.12.1) was performed.

Does it use parametric or non-parametric values ?
Is it a test to compare 2 groups only or it can be used for a comparison of 
more than two groups ?
Why is it so hard to find information on that test on the net ?

Thanks for your time
Have a nice day 

Elizabeth Caron
Physical therapist student, Laval University, Qc, Canada
 

[[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] Insert DateTime from R into MongoDB

2014-04-02 Thread PHOULIHAN
First time poster, for forgive if I'm not following the etiquette:

How does one properly insert a DateTime, from R, into mongoDB and have it
recognized as a DateTime in mongoDB in lieu of being recognized as a string?

I've tried a zillion things, and NOTHING works.  I'm using:
library('RMongo')
require(rmongodb)
require(RJSONIO)

With a variety of commands I found online, and it always passes from R into
mognoDB as a string no matter what I do. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Insert-DateTime-from-R-into-MongoDB-tp4688030.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 with MANOVA

2014-04-02 Thread Natalie Houghton McNair
I'm trying to run a MANOVA on shoreline habitat data.  The data was
collected in an odd way.  For each reach of shoreline, data was collected
for each habitat variable (shade, veg and IWM).  Each variable was
described as having a certain percentage of a particular category of the
variable.  For example, (not from my data) Shade (the habitat variable) at
Reach 1 was comprised of 50% No Shade (one of the categories), 25%
6%-25% shade, and 25% Greater than 75% shade.  Therefore each of the
three variables are described by amounts of each of the categories and the
percentages always equal 100 when added together.
So my question is, how do I run a MANOVA on this to determine if the
reaches are statistically different in R?
Thanks in advance for any advice!
  Reach  No Shade 1-5% Shade 6-25% Shade 26-75%Shade 75% Shade 25% Veg 26-50%
Veg 51-75%Veg 75% Veg No IWM 1-10% IMW 11-50%IWM 50% IWM  MS01 0.5609
0.2631 0.0103 0.1658 0 0 0.0294 0 0.9706 0.6693 0.2281 0.1026 0  MS02 0.2916
0.5672 0.0623 0.0789 0 0.0222 0 0 0.9778 0.1312 0.4787 0.1011 0.289  MS03
0.477 0.0411 0.0609 0.184 0.2371 0.0411 0 0 0.9589 0.477 0 0.225 0.298  MS04
0.7158 0.2037 0 0.0805 0 0.2569 0 0 0.7431 0.4589 0.2037 0.3374 0  MS05
0.4938 0.5062 0 0 0 0 0 0 1 0.558 0.442 0 0

[[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] R2WinBUGS expected collection operator c error

2014-04-02 Thread zumacrume
Hi all,
I am currently in a Bayesian Modeling course and am trying to implement an
analog representation model using R, WinBUGS, and R2WinBUGS.  I'm currently
stuck banging my head against an expected collection operator c error.  I
am working off of a template code, and I swear I haven't moved any
collection operators from the original code.
Here is what my script looks like in R:


# clears workspace:  
rm(list=ls(all=TRUE)) 

# sets working directories:
setwd(C:\\Users\\Nick\\Desktop\\modeling)
library(R2WinBUGS)
bugsdir = C:/Program Files/WinBUGS14

# read the data

g   = matrix(scan(g.txt, sep=,), ncol=144, nrow=3, byrow=T)
q   = matrix(scan(q.txt, sep=,), ncol=144, nrow=3, byrow=T)
S   = 3 # number of subjects
Q   = 144 # number of questions for each child
N   = 9 # maximum numbers of item list

data  = list(g, q, S, Q, N) # to be passed on to WinBUGS
myinits =   list(
  list(sigma = rep(1,S), pitmp=rep(1/N, N)))  

# parameters to be monitored:   
parameters = c(pp,ppb,sigma)

# NB. even with only 1000 iterations, the sampling can take a long time! 
# The following command calls WinBUGS with specific options.
# For a detailed description see Sturtz, Ligges,  Gelman (2005).
samples = bugs(data, inits=myinits, parameters,
model.file =NumberConcept_2_data.txt,
n.chains=1, n.iter=1000, n.burnin=100, n.thin=1,
DIC=T, bugs.directory=bugsdir,
codaPkg=F, debug=T)
# Now the values for the monitored parameters are in the samples object, 
# ready for inspection.

samples$summary

###

and here is the log file file from WinBUGS after R2WinBUGS passes it over:

###
display(log)
check(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/NumberConcept_2_data.txt)
model is syntactically correct
data(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/data.txt)
expected collection operator c
compile(1)
inits(1,C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/inits1.txt)
command #Bugs:inits cannot be executed (is greyed out)
gen.inits()
command #Bugs:gen.inits cannot be executed (is greyed out)
thin.updater(1)
update(100)
command #Bugs:update cannot be executed (is greyed out)
set(pp)
command #Bugs:set cannot be executed (is greyed out)
set(ppb)
command #Bugs:set cannot be executed (is greyed out)
set(sigma)
command #Bugs:set cannot be executed (is greyed out)
set(deviance)
command #Bugs:set cannot be executed (is greyed out)
dic.set()
command #Bugs:dic.set cannot be executed (is greyed out)
update(900)
command #Bugs:update cannot be executed (is greyed out)
coda(*,C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/coda)
command #Bugs:coda cannot be executed (is greyed out)
stats(*)
command #Bugs:stats cannot be executed (is greyed out)
dic.stats()

DIC
history(*,C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/history.odc)
command #Bugs:history cannot be executed (is greyed out)
save(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/log.odc)
save(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/log.txt)

#
WinBUGS also opens up a data window that looks like this:
#

list(g= structure(.Data= c(1.0E+00, 1.0E+00, 1.0E+00,
1.0E+00, 1.0E+00, 1.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 1.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00,
2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 1.0E+00, 1.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 1.0E+00, 2.0E+00, 

Re: [R] CORDIF test

2014-04-02 Thread Bert Gunter
google is your friend!

google r cordif test

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
H. Gilbert Welch




On Wed, Apr 2, 2014 at 6:09 AM, Elizabeth Caron-Gamache
babeth_...@icloud.com wrote:
 Hi,

 I search on your website for a definition of the CORDIF test, but it wasn’t 
 successful. I’m analyzing an article that use that test and it’s not really 
 documented on the net. The article refers to your website, so I pretend that 
 you will be able to give me a brief explanation of this test. Here is the 
 cote that talk about this test in my article :

 ‘' To compare these regressions and to see which—either body height or LLL—is 
 best related to performance (Pearson correlation coefficients comparison), a 
 CORDIF test (R software [www.r-project.org], multilevel package, ver- sion 
 2.12.1) was performed.

 Does it use parametric or non-parametric values ?
 Is it a test to compare 2 groups only or it can be used for a comparison of 
 more than two groups ?
 Why is it so hard to find information on that test on the net ?

 Thanks for your time
 Have a nice day

 Elizabeth Caron
 Physical therapist student, Laval University, Qc, Canada


 [[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] CORDIF test

2014-04-02 Thread Marc Schwartz
On Apr 2, 2014, at 8:09 AM, Elizabeth Caron-Gamache babeth_...@icloud.com 
wrote:

 Hi, 
 
 I search on your website for a definition of the CORDIF test, but it wasn’t 
 successful. I’m analyzing an article that use that test and it’s not really 
 documented on the net. The article refers to your website, so I pretend that 
 you will be able to give me a brief explanation of this test. Here is the 
 cote that talk about this test in my article : 
 
 ‘' To compare these regressions and to see which—either body height or LLL—is 
 best related to performance (Pearson correlation coefficients comparison), a 
 CORDIF test (R software [www.r-project.org], multilevel package, ver- sion 
 2.12.1) was performed.
 
 Does it use parametric or non-parametric values ?
 Is it a test to compare 2 groups only or it can be used for a comparison of 
 more than two groups ?
 Why is it so hard to find information on that test on the net ?
 
 Thanks for your time
 Have a nice day 
 
 Elizabeth Caron
 Physical therapist student, Laval University, Qc, Canada


Thanks for including the citation, which indicates that the CORDIF test is part 
of the 'multilevel' package, which is on CRAN:

  http://cran.r-project.org/web/packages/multilevel/index.html

The reason that it is likely difficult is that 'cordif' is an abbreviation for 
correlation difference, not the proper name for a test.

If you review the provided documentation for the package:

  http://cran.r-project.org/web/packages/multilevel/multilevel.pdf

you will see that there is a description of the cordif() function and a 
reference given:

Cohen, J.  Cohen, P. (1983). Applied multiple regression/correlation analysis 
for the behavioral sciences (2nd Ed.). Hillsdale, NJ: Lawrence Erlbaum 
Associates.

I would review the package documentation and reference and if you have further 
questions, contact the authors of the paper.

Regards,

Marc Schwartz

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


Re: [R] CORDIF test

2014-04-02 Thread Ista Zahn
Hi Elizabeth,

In addition to the helpful suggestions you have already received, I
would add that for simple functions like this it can be very
instructive to just look at the function definition. Loading the
multilevel package and typing 'cordif' will show you

function (rvalue1, rvalue2, n1, n2)
{
zvalue1 - 0.5 * ((log(1 + rvalue1)) - (log(1 - rvalue1)))
zvalue2 - 0.5 * ((log(1 + rvalue2)) - (log(1 - rvalue2)))
zest - (zvalue1 - zvalue2)/sqrt(1/(n1 - 3) + 1/(n2 - 3))
out - list(`z value` = zest)
return(out)
}


best.
Ista

On Wed, Apr 2, 2014 at 9:09 AM, Elizabeth Caron-Gamache
babeth_...@icloud.com wrote:
 Hi,

 I search on your website for a definition of the CORDIF test, but it wasn’t 
 successful. I’m analyzing an article that use that test and it’s not really 
 documented on the net. The article refers to your website, so I pretend that 
 you will be able to give me a brief explanation of this test. Here is the 
 cote that talk about this test in my article :

 ‘' To compare these regressions and to see which—either body height or LLL—is 
 best related to performance (Pearson correlation coefficients comparison), a 
 CORDIF test (R software [www.r-project.org], multilevel package, ver- sion 
 2.12.1) was performed.

 Does it use parametric or non-parametric values ?
 Is it a test to compare 2 groups only or it can be used for a comparison of 
 more than two groups ?
 Why is it so hard to find information on that test on the net ?

 Thanks for your time
 Have a nice day

 Elizabeth Caron
 Physical therapist student, Laval University, Qc, Canada


 [[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] Removing White spaces with NA

2014-04-02 Thread arun
Hi,
May be this helps:
dat - data.frame(Col1=c(A, , B,C, ,,D), stringsAsFactors=FALSE)
is.na(dat) - dat==''
dat$Col1
#[1] A NA  B C NA  NA  D 
A.K.



Hi All, I have a table and a column with values as below Col1
A B
C D I need to replace the Empty cells with the value NA as below
Col1
A
NA
B
C
NA
NA
D I tried a code, which was not working.
Table.name$column.name - gsub(,NA, table.name$column.name) Can anyone help 
me with this ?
Thanks and regards,
Praveen

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

2014-04-02 Thread Marc Girondot
(I posted this question in 
http://stackoverflow.com/questions/22781965/interpreting-effect-of-ordered-categorical-predictor 
without answer... I try here)


Thanks a lot
Marc

My question is very similar to this one 
(https://stat.ethz.ch/pipermail/r-help/2012-March/305357.html) but I 
fail to understand it fully. I would like to visualize the effect of an 
ordered categorical predictor after a glm.


First I generate some dummy data:

## data.frame with continuous values and 6 factors
datagenerate - data.frame(measure=c(rnorm(20, 10, 2), rnorm(30, 15, 2), 
rnorm(20, 20, 2),
rnorm(20, 25, 2), rnorm(20, 30, 2), rnorm(20, 35, 2)), factor=c(rep(A, 
20), rep(B, 30),
rep(C, 20), rep(D, 20), rep(E, 20), rep(F, 20)), 
stringsAsFactors=FALSE)

nbfactors - length(levels(datagenerate$factor))

Now I apply a glm with an unordered category:

## First factors are unordered
datagenerate$factor - as.factor(datagenerate$factor)
essaiglm - glm(measure ~ factor, datagenerate, family=gaussian())
coef_unordered - coef(summary(essaiglm))[,1]
plot(1:nbfactors, c(0, coef_unordered[2:nbfactors]), type=h, bty=n, 
las=1,

xlab=Factors, ylab=Effect)

All is ok. But I would like to do the same with ordered category:

## Now factors are ordered
datagenerate$factor - ordered(datagenerate$factor, levels=c(A, B, 
C, D, E, F))

essaiglm - glm(measure ~ factor, datagenerate, family=gaussian())
coef_ordered - coef(summary(essaiglm))[,1]

## I am not sure about this line. How the ordered factors are coded ?
x - ((0:(nbfactors-1))-(nbfactors-1)/2)/(nbfactors-1)

y - x*coef_ordered[factor.L]+x^2*coef_ordered[factor.Q]+
x^3*coef_ordered[factor.C]+x^4*coef_ordered[factor^4]+
x^5*coef_ordered[factor^5]
y - y-min(y)
plot(1:nbfactors, y, type=h, bty=n, las=1, xlab=Factors, 
ylab=Effect)
The result is highly dependent on the coding of the levels. Based on 
several tries, I propose


x - ((0:(nbfactors-1))-(nbfactors-1)/2)/(nbfactors-1)
But I am not sure.

If someone has the answer, I will be very grateful.

Thanks a lot

Marc

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


[R] 127.0.0.1:22381/doc/html/index.html hep.start won't start

2014-04-02 Thread Christian Hoffmann

Dear All,

Sorry to bother you. I narrowed my problem to the function

help.start() which causes the freezing of R by

mill endlessly after M-x R waiting for

127.0.0.1:22381/doc/html/index.html

to load.

I am using Aquamacs 3.0a (GNU Emacs 24.3.50.2)with R3.0.3, newly 
installed: sessionInfo()

---
R version 3.0.3 (2014-03-06)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] C

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

loaded via a namespace (and not attached):
[1] compiler_3.0.3 tools_3.0.3
-

The FIREWALL is responsible, deactivating will allow help.start()? Bur I 
don't want to work without the firewall!!
Settingthe firewall for  Firefox and Aquamacs to allow incoming 
connections (translated from German)will also not help.


Thanks for considering.

Christian

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

2014-04-02 Thread Abugri James
I ran the following loop on my SNP data and got an error message as
indicated
for (i in genenames){
+   current - fst1[which(fst1$Gene == i),]
+   num - nrow(current)
+   fst - max(current$fst)
+   position - mean(current$pos)
+   nposition - mean(current$newpos)
+   numhigh - nrow(current[which(current$fst  threshold),])
+   colors - mean(current$colors)
+   output - matrix(NA,nrow=1,ncol=8)
+   numthresh - paste(# SNPs  Fst = , threshold, sep=)
+   colnames(output) - c(gene, gene_old, pos, newpos, # Snps,
numthresh, Max.Fst, colors)
+   output[1,1] - i
+   output[1,2] - as.character(current[1, gene_old])
+   output[1,3] - position
+   output[1,4] - nposition
+   output[1,5] - num
+   output[1,6] - numhigh
+   output[1,7] - fst
+   output[1,8] - colors
+   maxfstgene - rbind(maxfstgene, output)
+ }
Error in output[1, 2] - as.character(current[1, gene_old]) :
  replacement has length zero
In addition: Warning message:
In mean.default(current$pos) :
  argument is not numeric or logical: returning NA
--

-- 
* The information contained in this email and any attachments may be 
legally privileged and confidential. If you are not an intended recipient, 
you are hereby notified that any dissemination, distribution, or copying of 
this e-mail is strictly prohibited. If you have received this e-mail in 
error, please notify the sender and permanently delete the e-mail and any 
attachments immediately. You should not retain, copy or use this e-mail or 
any attachments for any purpose, nor disclose all or any part of the 
contents to any other person.*

[[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] looping in R

2014-04-02 Thread Jeff Newmiller
You desperately need to read the Posting Guide (mentioned in the footer of this 
email) which warns you not to post in HTML format, and learn how to make a 
reproducible example (e.g. 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example).

The problem lies in some interaction between your data and code, and without 
both we cannot help you.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On April 2, 2014 12:15:51 PM PDT, Abugri James jabu...@uds.edu.gh wrote:
I ran the following loop on my SNP data and got an error message as
indicated
for (i in genenames){
+   current - fst1[which(fst1$Gene == i),]
+   num - nrow(current)
+   fst - max(current$fst)
+   position - mean(current$pos)
+   nposition - mean(current$newpos)
+   numhigh - nrow(current[which(current$fst  threshold),])
+   colors - mean(current$colors)
+   output - matrix(NA,nrow=1,ncol=8)
+   numthresh - paste(# SNPs  Fst = , threshold, sep=)
+   colnames(output) - c(gene, gene_old, pos, newpos, #
Snps,
numthresh, Max.Fst, colors)
+   output[1,1] - i
+   output[1,2] - as.character(current[1, gene_old])
+   output[1,3] - position
+   output[1,4] - nposition
+   output[1,5] - num
+   output[1,6] - numhigh
+   output[1,7] - fst
+   output[1,8] - colors
+   maxfstgene - rbind(maxfstgene, output)
+ }
Error in output[1, 2] - as.character(current[1, gene_old]) :
  replacement has length zero
In addition: Warning message:
In mean.default(current$pos) :
  argument is not numeric or logical: returning NA
--

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


Re: [R] looping in R

2014-04-02 Thread Duncan Murdoch

On 02/04/2014, 3:15 PM, Abugri James wrote:

I ran the following loop on my SNP data and got an error message as
indicated


I would assume that the error message is accurate: 
as.character(current[1, gene_old]) has length zero.  You'll need to 
debug why that happened.


Duncan Murdoch


for (i in genenames){
+   current - fst1[which(fst1$Gene == i),]
+   num - nrow(current)
+   fst - max(current$fst)
+   position - mean(current$pos)
+   nposition - mean(current$newpos)
+   numhigh - nrow(current[which(current$fst  threshold),])
+   colors - mean(current$colors)
+   output - matrix(NA,nrow=1,ncol=8)
+   numthresh - paste(# SNPs  Fst = , threshold, sep=)
+   colnames(output) - c(gene, gene_old, pos, newpos, # Snps,
numthresh, Max.Fst, colors)
+   output[1,1] - i
+   output[1,2] - as.character(current[1, gene_old])
+   output[1,3] - position
+   output[1,4] - nposition
+   output[1,5] - num
+   output[1,6] - numhigh
+   output[1,7] - fst
+   output[1,8] - colors
+   maxfstgene - rbind(maxfstgene, output)
+ }
Error in output[1, 2] - as.character(current[1, gene_old]) :
   replacement has length zero
In addition: Warning message:
In mean.default(current$pos) :
   argument is not numeric or logical: returning NA
--



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ASA Conference on Statistical Practice - call for short courses

2014-04-02 Thread Adams, Jean
R users,

The 2015 American Statistical Association Conference on Statistical
Practice is currently accepting proposals for short courses and tutorials.
 The conference will be held February 19-21 in New Orleans, Louisiana, USA.

Two R-related short courses were offered at the last conference, both of
which were well received:
 Elegant R Graphics with ggplot2
 An Introduction to R for Data Analysts
I am sure there would be interest in a course on interactive graphics,
e.g., using R packages shiny or googleVis.

Courses and tutorials need not be limited to R.  They may touch on any one
of the four conference themes:
 Communication, Impact, and Career Development
 Data Modeling and Analysis
 Big Data Prediction and Analytics
 Software, Programming, and Graphics

The deadline for proposal submissions is May 13, 2014.
If you are interested, you may submit your abstract on the website:
 http://www.amstat.org/meetings/csp/2015/courses.cfm

Thank you.

Jean V. Adams
on behalf of the ASA-CSP 2015 Steering Committee


`·.,,  (((º   `·.,,  (((º   `·.,,  (((º

Jean V. Adams
Statistician
U.S. Geological Survey
Great Lakes Science Center
223 East Steinfest Road
Antigo, WI 54409  USA
715-627-4317, ext. 3125  (Office)
715-216-8014  (Cell)
715-623-6773  (FAX)
http://www.glsc.usgs.gov  (GLSC web site)
http://profile.usgs.gov/jvadams  (My home page)

[[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] Icelandic Characters in Mac

2014-04-02 Thread Stefán Hrafn Jónsson
Dear R community

I have few students that use Mac. When creating graphs they inform me that
 when they use Icelandic characters in title or xlab they get some wrong
results. In stead of

Það er sætt they get .a. er s.tt period in stead of the Icelandic
character.

Any Icelandic Mac user that has a solution to this?  .




The Icelandic characters follows.

Æ æ ó Ó Ð ð,í  Í á Á é É ý Ý

http://en.wikipedia.org/wiki/Icelandic_alphabet


Thanks

Stefan Jonsson

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

2014-04-02 Thread Filippo

Hi everybody,
just wanted to know if it is possible to use the openmp library in 
Fortran code to be used within R.

I tried this simple thing:

subroutine test
!$OMP parallel
write(*,*) 'hello'
!$OMP end parallel
end subroutine test

and I compiled in the following way:

R CMD SHLIB test.f90 -fopenmp

but is seems not working.
The program correctly print me out four times 'hello' if I compile 
outside R simply using gfortran with the flag -fopenmp.

If someone can help me I would be very grateful.
Thanks in advance and regards
Filippo Monari

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


Re: [R] R2WinBUGS expected collection operator c error

2014-04-02 Thread Uwe Ligges
This is probably a BUGS rather than an R problem, hence better for a 
BUGS mailing list. But if we should help, then we need at least the 
modelfile.


Best,
Uwe Ligges



On 02.04.2014 19:10, zumacrume wrote:

Hi all,
I am currently in a Bayesian Modeling course and am trying to implement an
analog representation model using R, WinBUGS, and R2WinBUGS.  I'm currently
stuck banging my head against an expected collection operator c error.  I
am working off of a template code, and I swear I haven't moved any
collection operators from the original code.
Here is what my script looks like in R:


# clears workspace:
rm(list=ls(all=TRUE))

# sets working directories:
setwd(C:\\Users\\Nick\\Desktop\\modeling)
library(R2WinBUGS)
bugsdir = C:/Program Files/WinBUGS14

# read the data

g   = matrix(scan(g.txt, sep=,), ncol=144, nrow=3, byrow=T)
q   = matrix(scan(q.txt, sep=,), ncol=144, nrow=3, byrow=T)
S   = 3 # number of subjects
Q   = 144 # number of questions for each child
N   = 9 # maximum numbers of item list

data  = list(g, q, S, Q, N) # to be passed on to WinBUGS
myinits =   list(
   list(sigma = rep(1,S), pitmp=rep(1/N, N)))

# parameters to be monitored:   
parameters = c(pp,ppb,sigma)

# NB. even with only 1000 iterations, the sampling can take a long time!
# The following command calls WinBUGS with specific options.
# For a detailed description see Sturtz, Ligges,  Gelman (2005).
samples = bugs(data, inits=myinits, parameters,
model.file =NumberConcept_2_data.txt,
n.chains=1, n.iter=1000, n.burnin=100, n.thin=1,
DIC=T, bugs.directory=bugsdir,
codaPkg=F, debug=T)
# Now the values for the monitored parameters are in the samples object,
# ready for inspection.

samples$summary

###

and here is the log file file from WinBUGS after R2WinBUGS passes it over:

###
display(log)
check(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/NumberConcept_2_data.txt)
model is syntactically correct
data(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/data.txt)
expected collection operator c
compile(1)
inits(1,C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/inits1.txt)
command #Bugs:inits cannot be executed (is greyed out)
gen.inits()
command #Bugs:gen.inits cannot be executed (is greyed out)
thin.updater(1)
update(100)
command #Bugs:update cannot be executed (is greyed out)
set(pp)
command #Bugs:set cannot be executed (is greyed out)
set(ppb)
command #Bugs:set cannot be executed (is greyed out)
set(sigma)
command #Bugs:set cannot be executed (is greyed out)
set(deviance)
command #Bugs:set cannot be executed (is greyed out)
dic.set()
command #Bugs:dic.set cannot be executed (is greyed out)
update(900)
command #Bugs:update cannot be executed (is greyed out)
coda(*,C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/coda)
command #Bugs:coda cannot be executed (is greyed out)
stats(*)
command #Bugs:stats cannot be executed (is greyed out)
dic.stats()

DIC
history(*,C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/history.odc)
command #Bugs:history cannot be executed (is greyed out)
save(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/log.odc)
save(C:/Users/Nick/AppData/Local/Temp/RtmpIRZ1dh/log.txt)

#
WinBUGS also opens up a data window that looks like this:
#

list(g= structure(.Data= c(1.0E+00, 1.0E+00, 1.0E+00,
1.0E+00, 1.0E+00, 1.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 1.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00,
2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 1.0E+00, 1.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 1.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
2.0E+00, 2.0E+00, 2.0E+00, 1.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 2.0E+00, 2.0E+00, 2.0E+00,
1.0E+00, 2.0E+00, 

Re: [R] plotting several columns of matrix in one graph

2014-04-02 Thread arun
Hi,
May be this helps:
library(xts) 


library(xtsExtra)
data(sample_matrix)
plot(as.xts(sample_matrix),screens=1)
#or
library(zoo)
plot(as.zoo(sample_matrix), plot.type=single,col=1:ncol(sample_matrix))

You may also check ?matplot

A.K.


Hi everyone, I have started using R and although I am used to some other 
languages, I am struggling doing a plot that contains several lines which each 
correspond to a column of the Matrix which all my data. I tried to google it 
but unfortunately, it haven't found anything which helped me and also the 
description didn't really give me a hint what to do. Let's say I have Matrix 
calles Data_Set which consists of 6 columns and let's say 100 rows. in the 
first column, I have the date, which is also the x-axis of my plot. The next 
five column contain the time series, for each of them I want I line drawn in 
the plot. I have installed the lattice package and I tried several things using 
the xyplot command, but it didn't work. thanks so much for your help.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Subset error on atomic vectors why?

2014-04-02 Thread jcrosbie
I'm getting this error: Error in MOPrice$Date : $ operator is invalid for
atomic vectors

The cost is: subset(MOPrice,
as.Date(MOPrice$Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d)) 

The date column looks like:
2013-12-31 2013-12-31 2013-12-31 2013-12-31 2013-12-31







--
View this message in context: 
http://r.789695.n4.nabble.com/Subset-error-on-atomic-vectors-why-tp4688051.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] Survey

2014-04-02 Thread Thomas Lumley
On Thu, Apr 3, 2014 at 2:37 AM, Leandro Marino 
leandromar...@leandromarino.com.br wrote:

 Dear R-Users,

 I was using survey for the past years and now I am experiencing some
 problems with scripts that was working in the past.

 We are working with big data bases so I can't put all variables that I will
 use in the svydesign.


This was never supposed to work.

The variables shouldn't take up any more room in the survey design object
than they do anywhere else, but in any case the right solution when you
have enough memory for the variables in a given analysis but not for all
the variables in your dataset is to use the database-backed designs and put
the data in something like SQLite.

  -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

[[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] Icelandic Characters in Mac

2014-04-02 Thread David Winsemius

On Apr 2, 2014, at 2:18 PM, Stefán Hrafn Jónsson wrote:

 Dear R community
 
 I have few students that use Mac. When creating graphs they inform me that
 when they use Icelandic characters in title or xlab they get some wrong
 results. In stead of
 
 fia› er sætt they get .a. er s.tt period in stead of the Icelandic
 character.
 
 Any Icelandic Mac user that has a solution to this?  .
 
 
 The Icelandic characters follows.
 
 Æ æ ó Ó ‹ ›,í  Í á Á é É ‡ †
 
 http://en.wikipedia.org/wiki/Icelandic_alphabet

The default screen device is named quartz(). I'm not an Icelander, but in a US 
locale with the standard fonts I get faithful reproduction of those characters 
on a Mac running 10.7.5 with R 3.0.2

They need to be looking at:

?quartz

?quartzFonts

sans for a sans-serif font, 
serif for a serif font 
 mono for a monospaced font.

And they need to know what fonts would be appropriate to assign to the various 
families,s or they need to specify font families in their plotting calls. There 
may be a need to review how their locale settings are being specified.

-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] Subset error on atomic vectors why?

2014-04-02 Thread David Winsemius

On Apr 2, 2014, at 3:35 PM, jcrosbie wrote:

 I'm getting this error: Error in MOPrice$Date : $ operator is invalid for
 atomic vectors
 
 The cost is: subset(MOPrice,
 as.Date(MOPrice$Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d)) 
 
 The date column looks like:
 2013-12-31 2013-12-31 2013-12-31 2013-12-31 2013-12-31
 

What does str(MOPrice) return?


 View this message in context: 
 http://r.789695.n4.nabble.com/Subset-error-on-atomic-vectors-why-tp4688051.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.

David Winsemius
Alameda, CA, USA

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


Re: [R] Subset error on atomic vectors why?

2014-04-02 Thread arun
Hi,
It is not mentioned whether your dataset is a matrix of data.frame.  Also, 
please use ?dput() to show the dataset.  I get similar errors with matrix.

MOPrice - 
data.frame(Date=c(2013-12-31,2013-12-31,2013-12-31,2013-11-28),stringsAsFactors=FALSE)
subset(MOPrice, as.Date(Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d))
#Date
#4 2013-11-28
MOPrice1 - 
data.frame(Date=c(2013-12-31,2013-12-31,2013-12-31),stringsAsFactors=FALSE)
subset(MOPrice1, as.Date(Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d))
#[1] Date 

#0 rows (or 0-length row.names)

MOPrice2 - data.frame(Date=c(2013-12-31,2013-12-31,2013-12-31))
subset(MOPrice2, 
as.Date(MOPrice2$Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d))
#[1] Date
#0 rows (or 0-length row.names)
subset(MOPrice1, 
as.Date(MOPrice1$Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d))
#[1] Date
#0 rows (or 0-length row.names)
MOPrice3 - as.matrix(MOPrice1)
subset(MOPrice3, 
as.Date(MOPrice3$Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d))
#Error in MOPrice3$Date : $ operator is invalid for atomic vectors 


A.K.


On Wednesday, April 2, 2014 6:49 PM, jcrosbie ja...@crosb.ie wrote:
I'm getting this error: Error in MOPrice$Date : $ operator is invalid for
atomic vectors

The cost is: subset(MOPrice,
as.Date(MOPrice$Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d)) 

The date column looks like:
2013-12-31 2013-12-31 2013-12-31 2013-12-31 2013-12-31







--
View this message in context: 
http://r.789695.n4.nabble.com/Subset-error-on-atomic-vectors-why-tp4688051.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] ggplot: add points selectively to curves

2014-04-02 Thread Michael Friendly

Thanks, Dennis

Not quite.  I need to have the same lines as in the original, using 
plotdat, but then

add the points from your plotdat2

gg - ggplot(plotdat, aes(x = Age, y = Probability, color = Level)) +
geom_line(size=2.5) + theme_bw() + xlim(10,80) +
#geom_point(color=black, size=1.5) + # not these points
facet_grid(Sex ~ Treatment, # scales = free,
   labeller = function(x, y) sprintf(%s = %s, x, y)
   )

# want these points, added to the above plot
plotdat2 - subset(plotdat,
 as.character(Improved) == as.character(Level))



On 02/04/2014 7:09 PM, Dennis Murphy wrote:

Hi Michael:

Does this work?

plotdat2 - subset(plotdat,
  as.character(Improved) == as.character(Level))
ggplot(plotdat2, aes(x = Age, y = Probability, color = Level)) +
 geom_line(size=2.5) + theme_bw() + xlim(10,80) +
 geom_point(color=black, size=1.5) +
 facet_grid(Sex ~ Treatment,
labeller = function(x, y) sprintf(%s = %s, x, y)
)

Dennis

On Wed, Apr 2, 2014 at 7:43 AM, Michael Friendly frien...@yorku.ca wrote:

I'm working on an example of plotting predicted probabilities from a
proportional odds model.
The steps below generate a data frame, plotdat, that I want to plot with
ggplot.

library(MASS)
data(Arthritis, package=vcd)
arth.polr - polr(Improved ~ Sex + Treatment + Age, data=Arthritis,
Hess=TRUE)

# get predicted probs for categories of Improve
arth.fitp - cbind(Arthritis,
   predict(arth.polr, type=probs))
head(arth.fitp)

# reshape probs to long
library(reshape2)
plotdat - melt(arth.fitp,
 id.vars = c(Sex, Treatment, Age, Improved),
 measure.vars=c(None, Some, Marked),
 variable.name = Level,
 value.name = Probability)
## view first few rows
head(plotdat)


head(plotdat)

Sex Treatment Age Improved Level Probability
1 Male   Treated  27 Some  None   0.7326185
2 Male   Treated  29 None  None   0.7174048
3 Male   Treated  30 None  None   0.7096042
4 Male   Treated  32   Marked  None   0.6936286
5 Male   Treated  46   Marked  None   0.5702499
6 Male   Treated  58   Marked  None   0.4563432

In the plot step, I am plotting Probability vs. Age, stratified by Level,
and faceted by
Sex and Treatment.  My question concerns the use of geom_point().
The call below plots 3 points for each case, one on each Level curve.


ggplot(plotdat, aes(x = Age, y = Probability, color = Level)) +
 geom_line(size=2.5) + theme_bw() + xlim(10,80) +
 geom_point(color=black, size=1.5) +
 facet_grid(Sex ~ Treatment,
labeller = function(x, y) sprintf(%s = %s, x, y)
)

Instead,
I want to plot only one point for each case, for the value of Level that
corresponds
to the value of Improved in this data set.  Somehow, this involves something
like an aes() argument to geom_point(), with Level indexed by Improved, or
some such.
How can I do this?

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] ggplot: add points selectively to curves

2014-04-02 Thread arun
Hi,
May be this helps:
gg - ggplot(plotdat, aes(x = Age, y = Probability, color = Level)) + 
geom_line(size=2.5) + theme_bw() + xlim(10,80) + facet_grid(Sex ~ Treatment, # 
scales = free, labeller = function(x, y) sprintf(%s = %s, x, y) ) 

plotdat2 - subset(plotdat,as.character(Improved)==as.character(Level)) 


gg+geom_point(data= plotdat2, aes(x=Age, y=Probability),color=black,size=1.5)


A.K.


On Wednesday, April 2, 2014 9:22 PM, Michael Friendly frien...@yorku.ca wrote:
Thanks, Dennis

Not quite.  I need to have the same lines as in the original, using 
plotdat, but then
add the points from your plotdat2

gg - ggplot(plotdat, aes(x = Age, y = Probability, color = Level)) +
     geom_line(size=2.5) + theme_bw() + xlim(10,80) +
#    geom_point(color=black, size=1.5) +         # not these points
     facet_grid(Sex ~ Treatment, # scales = free,
                labeller = function(x, y) sprintf(%s = %s, x, y)
                )

# want these points, added to the above plot
plotdat2 - subset(plotdat,
                      as.character(Improved) == as.character(Level))



On 02/04/2014 7:09 PM, Dennis Murphy wrote:
 Hi Michael:

 Does this work?

 plotdat2 - subset(plotdat,
                       as.character(Improved) == as.character(Level))
 ggplot(plotdat2, aes(x = Age, y = Probability, color = Level)) +
      geom_line(size=2.5) + theme_bw() + xlim(10,80) +
      geom_point(color=black, size=1.5) +
      facet_grid(Sex ~ Treatment,
                 labeller = function(x, y) sprintf(%s = %s, x, y)
                 )

 Dennis

 On Wed, Apr 2, 2014 at 7:43 AM, Michael Friendly frien...@yorku.ca wrote:
 I'm working on an example of plotting predicted probabilities from a
 proportional odds model.
 The steps below generate a data frame, plotdat, that I want to plot with
 ggplot.

 library(MASS)
 data(Arthritis, package=vcd)
 arth.polr - polr(Improved ~ Sex + Treatment + Age, data=Arthritis,
 Hess=TRUE)

 # get predicted probs for categories of Improve
 arth.fitp - cbind(Arthritis,
                    predict(arth.polr, type=probs))
 head(arth.fitp)

 # reshape probs to long
 library(reshape2)
 plotdat - melt(arth.fitp,
                  id.vars = c(Sex, Treatment, Age, Improved),
                  measure.vars=c(None, Some, Marked),
                  variable.name = Level,
                  value.name = Probability)
 ## view first few rows
 head(plotdat)

 head(plotdat)
     Sex Treatment Age Improved Level Probability
 1 Male   Treated  27     Some  None   0.7326185
 2 Male   Treated  29     None  None   0.7174048
 3 Male   Treated  30     None  None   0.7096042
 4 Male   Treated  32   Marked  None   0.6936286
 5 Male   Treated  46   Marked  None   0.5702499
 6 Male   Treated  58   Marked  None   0.4563432

 In the plot step, I am plotting Probability vs. Age, stratified by Level,
 and faceted by
 Sex and Treatment.  My question concerns the use of geom_point().
 The call below plots 3 points for each case, one on each Level curve.


 ggplot(plotdat, aes(x = Age, y = Probability, color = Level)) +
      geom_line(size=2.5) + theme_bw() + xlim(10,80) +
      geom_point(color=black, size=1.5) +
      facet_grid(Sex ~ Treatment,
                 labeller = function(x, y) sprintf(%s = %s, x, y)
                 )

 Instead,
 I want to plot only one point for each case, for the value of Level that
 corresponds
 to the value of Improved in this data set.  Somehow, this involves something
 like an aes() argument to geom_point(), with Level indexed by Improved, or
 some such.
 How can I do this?

 --
 Michael Friendly     Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.  Chair, Quantitative Methods
 York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
 4700 Keele Street    Web:  http://www.datavis.ca
 Toronto, ONT  M3J 1P3 CANADA

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


-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street    Web:  http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


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


Re: [R] plotting several columns of matrix in one graph

2014-04-02 Thread arun
HI,
It is better to show a reproducible example using ?dput().  May be this helps:
#vector

vec1 - seq(as.Date(2002-01-01), as.Date(2009-12-31),by=1 day)
#Assuming that length of the vector is the same as ?nrow of matrix.

set.seed(532)
mat1 - matrix(cumsum(rnorm(length(vec1)*5)),ncol=5, 
dimnames=list(NULL,LETTERS[1:5]))

library(xts) 

library(xtsExtra)
plot(as.xts(mat1,order.by=vec1),major.format=%Y,screens=1, main=Time series 
plot, auto.legend=TRUE,auto.grid=FALSE,col=5:1)

You should also check ?legend()

A.K.







thank you so much. it tried the 2nd way and it is working perfectly. could you 
also tell me how I can select a vector which is then used for the x axis? let's 
say I want some Dates 2002 to 2009, currently I have a vector called date which 
contains of every single day from 2002 to 2009, is there a way to get this on 
the x axis (just the year)? in Addition, is there some command to add a legend, 
titles, Change Color etc? From what I find on the Internet, I just don't 
understand how that is working. thanks again for the help! 


On Wednesday, April 2, 2014 6:41 PM, arun smartpink...@yahoo.com wrote:
Hi,
May be this helps:
library(xts) 


library(xtsExtra)
data(sample_matrix)
plot(as.xts(sample_matrix),screens=1)
#or
library(zoo)
plot(as.zoo(sample_matrix), plot.type=single,col=1:ncol(sample_matrix))

You may also check ?matplot

A.K.


Hi everyone, I have started using R and although I am used to some other 
languages, I am struggling doing a plot that contains several lines which each 
correspond to a column of the Matrix which all my data. I tried to google it 
but unfortunately, it haven't found anything which helped me and also the 
description didn't really give me a hint what to do. Let's say I have Matrix 
calles Data_Set which consists of 6 columns and let's say 100 rows. in the 
first column, I have the date, which is also the x-axis of my plot. The next 
five column contain the time series, for each of them I want I line drawn in 
the plot. I have installed the lattice package and I tried several things using 
the xyplot command, but it didn't work. thanks so much for your help.

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


Re: [R] -fopenmp

2014-04-02 Thread Prof Brian Ripley

On 02/04/2014 22:30, Filippo wrote:

Hi everybody,
just wanted to know if it is possible to use the openmp library in
Fortran code to be used within R.


Yes, on a supported platform.  But

1) The posting guide tells you this is not the correct list for 
questions about compiled code.


2) 'Writing R Extensions' tells you how to do this.

3) ?SHLIB tells you about valid inputs, which do not include arbitrary 
flags.



I tried this simple thing:

subroutine test
!$OMP parallel
write(*,*) 'hello'
!$OMP end parallel
end subroutine test

and I compiled in the following way:

R CMD SHLIB test.f90 -fopenmp

but is seems not working.
The program correctly print me out four times 'hello' if I compile
outside R simply using gfortran with the flag -fopenmp.
If someone can help me I would be very grateful.
Thanks in advance and regards
Filippo Monari

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Strange sprintf Behavior

2014-04-02 Thread Michael Smith
All,

Apologies for the thread issue, and many thanks for the pointers to the
FAQs.

Thanks,
M

On 04/02/2014 10:14 PM, Jeff Newmiller wrote:
 It is poor netiquette to reply to a thread with a different subject. Please 
 start a new thread for a new subject.
 
 As for your question, see FAQ 7.31. This is standard floating point numerical 
 limitations at work.
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 --- 
 Sent from my phone. Please excuse my brevity.
 
 On April 2, 2014 4:32:26 AM PDT, Michael Smith my.r.h...@gmail.com wrote:
 All,

 I'm getting this:

 sprintf(%.17f, 0.8)
 [1] 0.80004

 Where does the `4` at the end come from? Shouldn't it be zero at the
 end? Maybe I'm missing something.

 sessionInfo()
 R version 3.0.2 (2013-09-25)
 Platform: x86_64-redhat-linux-gnu (64-bit)

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

 [10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8
 LC_IDENTIFICATION=C

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


 Thanks,

 M

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

2014-04-02 Thread Lucy Leigh
Hi everyone,
I am attempting to use the R package 'rms'
http://biostat.mc.vanderbilt.edu/wiki/Main/Rrms
to implement a PH weibull model, using the pphsm() function.

However, I get the following error,
f.ph - pphsm(f)
Warning message:
In pphsm(f) :
  at present, pphsm does not return the correct covariance matrix

I tried simply running the example on page 117 of the manual, i.e.
set.seed(1)
S - Surv(runif(100))
x - runif(100)
dd - datadist(x); options(datadist='dd')
f - psm(S ~ x, dist=exponential)
summary(f) # effects on log(T) scale
f.ph - pphsm(f)
## Not run: summary(f.ph)

But I still got the above error message.
I have looked through the R help archives, and it appears that this question 
has been asked before in 2011, but
there were no replies.
http://r.789695.n4.nabble.com/HELP-td3494640.html

Does anyone know how to get this function to work? Or if there is an 
alternative package that can implement
a Weibull PH model?
Cheers,
Lucy

[[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] 'rms' package error

2014-04-02 Thread Pascal Oettli
Hello Lucy,

If you carefully read, it is is not an error message, but a warning
message. It tells you that for the moment, if I am not mistaken,
pphsm does not return the correct covariance matrix, for any
fitting.

Regards,
Pascal

On Thu, Apr 3, 2014 at 11:29 AM, Lucy Leigh lucy.le...@newcastle.edu.au wrote:
 Hi everyone,
 I am attempting to use the R package 'rms'
 http://biostat.mc.vanderbilt.edu/wiki/Main/Rrms
 to implement a PH weibull model, using the pphsm() function.

 However, I get the following error,
 f.ph - pphsm(f)
 Warning message:
 In pphsm(f) :
   at present, pphsm does not return the correct covariance matrix

 I tried simply running the example on page 117 of the manual, i.e.
 set.seed(1)
 S - Surv(runif(100))
 x - runif(100)
 dd - datadist(x); options(datadist='dd')
 f - psm(S ~ x, dist=exponential)
 summary(f) # effects on log(T) scale
 f.ph - pphsm(f)
 ## Not run: summary(f.ph)

 But I still got the above error message.
 I have looked through the R help archives, and it appears that this question 
 has been asked before in 2011, but
 there were no replies.
 http://r.789695.n4.nabble.com/HELP-td3494640.html

 Does anyone know how to get this function to work? Or if there is an 
 alternative package that can implement
 a Weibull PH model?
 Cheers,
 Lucy

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



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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

2014-04-02 Thread 张以春
Dear R experts,


I tried to plot some figures in R using postscript(), but it always shows that 
the fugures margin is too large. I don't know how to change it. The following 
is my example:


 postscript(All.eps,width=3.27,height=1.416,pointsize=12,family=Arial)
par(mar=c(5.1,4.5,4.1,2.1));boxplot(All~Nameall,ylab= expression(Size~ (log 
[10]~mm ^2)), boxwex=0.3, main=All 
species,col=c(red,yellow,blue),ylim=c(0,4.0))
Error: plot.new() : figure margins too large


When I run the boxplot in R, it shows well, but once I run it in the 
postscript, it fails. Can someone help me on it?
Note: my operational system is windows 7.


Many thanks in advance
Yichun







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