[R] [R-pkgs] knitr version 1.1

2013-02-22 Thread Yihui Xie
Hi,

I released knitr 1.1 to CRAN a few days ago:
http://cran.r-project.org/package=knitr See all new features and
changes at 
https://github.com/yihui/knitr/blob/master/NEWS.md#changes-in-knitr-version-11

The version 1.0 does not imply perfect stability or maturity. The
major version number was bumped from 0.x to 1.x due to a number of
important features and the breaking of compatibility with Sweave
(http://yihui.name/knitr/demo/sweave/). A brief summary of recent
features:

1. (please regard this one as experimental) from R 3.0.0 we will be
able to compile package vignettes with knitr, even including R
Markdown vignettes (http://yihui.name/knitr/demo/vignette/)
2. the encoding argument in knit() allows one to specify the encoding
of the source document, which may benefit international users (this
has also been supported in RStudio, and the next version of LyX will
also support encoding correctly)
3. you can publish blog posts from R to WordPress using R Markdown and
the knit2wp() function
(http://yihui.name/en/2013/02/publishing-from-r-knitr-to-wordpress/)
4. Rcpp is supported in code chunks (see http://gallery.rcpp.org for
an application), and more languages have been added (Perl, Bash,
CoffeeScript, ... http://yihui.name/knitr/demo/engines/)
5. A Shiny notebook was added as a demo (http://glimmer.rstudio.com/yihui/knitr)

I thank the amazing R community; in particular, I thank all
contributors who sent me over 50 pull requests
(https://github.com/yihui/knitr/contributors) and users who reported
nearly 500 issues (https://github.com/yihui/knitr/issues), asked more
than 200 questions on StackOverflow
(http://stackoverflow.com/questions/tagged/knitr) and made hundreds of
comments in the knitr website (http://yihui.name/knitr/). If you want
to contribute or have any questions, please follow these links.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] total indirect effects in structural equation modeling using lavaan

2013-02-22 Thread yrosseel

On 02/21/2013 03:59 PM, Marios wrote:

My question...I would like to calculate the total indirect effects of
all variables on the right-hand-side of the regression eqn's so that i can
work out the total effect (indirect effects + direct effect)

I know the direct effect and i can calculate the total indirect effects by
hand but i was wondering if there is a function that can calculate this?


In the current version of lavaan (0.5-11), there is no function that 
will compute all possible indirect/total effects automatically.


What you can do is to label the coefficients, and then use the ':=' 
operator to define the total/indirect effects that you are interested 
in. Next, you could use se=boot to get a bootstrap based SE.


See the lavaan paper (http://www.jstatsoft.org/v48/i02/) section 7.4 for 
an example.


Yves.

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

2013-02-22 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Prof Brian Ripley
 Sent: Friday, February 22, 2013 8:17 AM
 To: r-help@r-project.org
 Subject: Re: [R] package ReadImages
 
 On 22/02/2013 05:44, Greg Snow wrote:
  Some possibilities:  The EBImage package on Bioconductor; the jpeg
 and
  png packages read jpeg and png images.
 
 Almost everyone using ReadImages was using it to read TIFF images,
 which package tiff can do.  See the 'Data Import/Export Manual',
 http://cran.r-project.org/doc/manuals/r-devel/R-data.html#Image-files .

Thanks, I will try.

 
  On Thu, Feb 21, 2013 at 8:26 AM, PIKAL Petr petr.pi...@precheza.cz
 wrote:
 
  Dear all
 
  I prepared some image processing routine which depended on package
  ReadImages. Basically I imported image to R, changed rgb to
  grayscale, normalised an image made some selections and changed to
  image by imagematrix.
 
  Recently I learned that this package was removed from CRAN and can
  not be used in R 3.0.0.
 
 It was archived, already being orphaned.  When R 3.0.0 is released you
 can see if it works there: I expect it to.

I tried to install it from binary on R-devel

R Under development (unstable) (2013-02-13 r61942) -- Unsuffered Consequences
Copyright (C) 2013 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-w64-mingw32/i386 (32-bit)

It does not load with error 

library(ReadImages)
Error: package 'ReadImages' was built before R 3.0.0: please re-install it

So I presume I could try to build it from sources, which can be beyound my 
expertise, if there was some tweak issues. This is probably the last resort for 
me.

Regards
Petr

 
 
  What options I have now to import image to R, change it to
 grayscale,
  make some computation or selection, change it back to image and plot
  for visual inspection.
 
  Thanks
  Petr
 
 
 --
 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.

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

2013-02-22 Thread PIKAL Petr
Hi

I understood that OP wanted to know how many columns s/he has.
Anyway, s/he got plenty of answers which can inspect and choose one which 
corresponds to the problem.

Regards
Petr

 -Original Message-
 From: Rolf Turner [mailto:rolf.tur...@xtra.co.nz]
 Sent: Friday, February 22, 2013 6:36 AM
 To: PIKAL Petr
 Cc: nandita srivastava; r-help@r-project.org
 Subject: Re: [R] (no subject)
 
 
 Huh?  This answer seems to have absolutely no bearing on the question.
 
  cheers,
 
  Rolf Turner
 
 On 02/21/2013 11:26 PM, PIKAL Petr wrote:
  Hi
 
  ?ncol
 
  Regards
  Petr
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of nandita srivastava
  Sent: Thursday, February 21, 2013 8:34 AM
  To: r-help@r-project.org
  Subject: [R] (no subject)
 
  how to sum columns in R?
 

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

2013-02-22 Thread PIKAL Petr
Thanks.

I tried EBImage several years ago for another problem, but Bioconductor 
packages have some difficulties to install in our network/firewall environment 
and I am not in a position to change it. It seems to me also an overkill for 
such simple task.

jpeg and png seems to me a bit too much simple, without direct possibility to 
transform from rgb to grayscale and normalisation.

Anyway, I will give it a try.

Petr

From: Greg Snow [mailto:538...@gmail.com]
Sent: Friday, February 22, 2013 6:45 AM
To: PIKAL Petr
Cc: r-help
Subject: Re: [R] package ReadImages

Some possibilities:  The EBImage package on Bioconductor; the jpeg and png 
packages read jpeg and png images.

On Thu, Feb 21, 2013 at 8:26 AM, PIKAL Petr 
petr.pi...@precheza.czmailto:petr.pi...@precheza.cz wrote:
Dear all

I prepared some image processing routine which depended on package ReadImages. 
Basically I imported image to R, changed rgb to grayscale, normalised an image 
made some selections and changed to image by imagematrix.

Recently I learned that this package was removed from CRAN and can not be used 
in R 3.0.0.

What options I have now to import image to R, change it to grayscale, make some 
computation or selection, change it back to image and plot for visual 
inspection.

Thanks
Petr

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



--
Gregory (Greg) L. Snow Ph.D.
538...@gmail.commailto:538...@gmail.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] total indirect effects in structural equation modeling using lavaan

2013-02-22 Thread yrosseel

On 02/22/2013 11:40 AM, Marios wrote:

Thank you very much Yves!

I have managed to get the total indirect effects that i wanted but it
seems to only work on the unstandardized coefficients. I use
standardized =TRUE in the summary command but the std.all column
has the same values as the Estimate (unstandardized) column for the
new parameters defined by the := operator. All other parameters i.e.
using ~ have been standardized.

How do i go about calculating the indirect effects based on standardized
coefficients?


You need to install 0.5-12, where the newly 'defined' parameters 
(defined by the := operator) are standardized too (just like the other 
parameters). This version is not on CRAN yet, but you can install it by 
typing in R:


install.packages(lavaan, repos=http://www.da.ugent.be;, type=source)

Yves.

--
Yves Rosseel -- http://www.da.ugent.be
Department of Data Analysis, Ghent University
http://lavaan.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] Is it possible to obtain an agglomeration schedule with R cluster analyis

2013-02-22 Thread Bob Green

Hello,

In SPSS the cluster analysis output includes an agglomerations 
schedule, which details the stages when cases are joined.


Is it possible to obtain such output when performing cluster analysis 
in R?  If so, I'd appreciate advice regarding how to obtain this information.



Any assistance is appreciated,

Regards

Bob

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 2 setGeneric's, same name, different method signatures

2013-02-22 Thread Romain Fenouil
Dear Martin Morgan,

thank you very much for your answer that made it clear to me.
Since my package is linked to yours by essence, there is no reason to
redefine the existing setGeneric functions.

As a summary, if someone is importing functions from another package, he is
supposed to know they already exist and shouldn't redefine their generic
template. This can sound stupid like that but wasn't clear to me before
putting everything in a package.
Moreover this situation is not an issue while loading another package that
potentially has functions with same names thanks to the Namespaces
implicitly encapsulating the packages.

Thank you again and I hope the package will be of interest for the community
:)

Romain.



--
View this message in context: 
http://r.789695.n4.nabble.com/2-setGeneric-s-same-name-different-method-signatures-tp4658570p4659349.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] total indirect effects in structural equation modeling using lavaan

2013-02-22 Thread Marios
Thank you very much Yves!

I have managed to get the total indirect effects that i wanted but it seems
to only work on the unstandardized coefficients. I use standardized =TRUE
in the summary command but the std.all column has the same values as
the Estimate (unstandardized) column for the new parameters defined by
the := operator. All other parameters i.e. using ~ have been
standardized.

How do i go about calculating the indirect effects based on standardized
coefficients?

Thanks again,

Marios

On 22 February 2013 10:02, yrosseel yross...@gmail.com wrote:

 On 02/21/2013 03:59 PM, Marios wrote:

 My question...I would like to calculate the total indirect effects of
 all variables on the right-hand-side of the regression eqn's so that i can
 work out the total effect (indirect effects + direct effect)

 I know the direct effect and i can calculate the total indirect effects by
 hand but i was wondering if there is a function that can calculate this?


 In the current version of lavaan (0.5-11), there is no function that will
 compute all possible indirect/total effects automatically.

 What you can do is to label the coefficients, and then use the ':='
 operator to define the total/indirect effects that you are interested in.
 Next, you could use se=boot to get a bootstrap based SE.

 See the lavaan paper 
 (http://www.jstatsoft.org/v48/**i02/http://www.jstatsoft.org/v48/i02/)
 section 7.4 for an example.

 Yves.

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


[[alternative HTML version deleted]]

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


[R] pgirmess install under linux mint 14 / a solution

2013-02-22 Thread Pierre-Henri Puech

hi there,
after bumping into a problem for installing pgirmess package in linux 
mint 14, i figured out this solution that seemed to work fine

---
* in synaptic or similar software :
installation of proj dev lib  dependances # to sort out problems of rgdal
installation of libgdal1 dev lib  dependances # to sort out problems of 
rgdal

* in R
installation of rgdal  dependances # to prevent dependance problems of 
pgirmess

*then* installation of pgirmess  dependances

hope this may help ubuntu / gnu linux users
best
p

--

Dr. Pierre-Henri Puech
Email: pierre-henri.pu...@inserm.fr
Perso: http://puechph.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] Model selection in nonstationary VAR

2013-02-22 Thread M M
Folks,
Is there any implementation available in R for the simultaneous selection of 
lag order and rank of a nonstationary VAR as described in Chao  Phillips 
(1999): Model selection in partially nonstationary vector autoregressive 
processes with reduced rank structure, J. Econ. (91).
Or any other systematic procedure for the consistent selection of lag order and 
cointegration rank? 
I understand that the usual procedure of first selecting the lag order (by AIC, 
etc.) and then the rank (by Johansen) can result in misspecification.
Thanks,
Murali
[[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] (senza oggetto)

2013-02-22 Thread Eleonora Schiano
i would like to unsubscribe from the mailing list
Thank'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.


Re: [R] (senza oggetto)

2013-02-22 Thread Ista Zahn
Hi Eleonora,

To unsubscribe, click the mailing list link at the bottom of this (and
every) r-help message, scroll to the bottom and follow the unsubscribe
instructions.

Best,
Ista

On Fri, Feb 22, 2013 at 7:02 AM, Eleonora Schiano
eleonora.schi...@gmail.com wrote:
 i would like to unsubscribe from the mailing list
 Thank'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] total indirect effects in structural equation modeling using lavaan

2013-02-22 Thread Marios
Waow awesome!!

It worked perfectly!

Thanks heaps Yves!

Greatly appreciated!

Marios

On 22 February 2013 12:45, yrosseel yross...@gmail.com wrote:

 On 02/22/2013 11:40 AM, Marios wrote:

 Thank you very much Yves!

 I have managed to get the total indirect effects that i wanted but it
 seems to only work on the unstandardized coefficients. I use
 standardized =TRUE in the summary command but the std.all column
 has the same values as the Estimate (unstandardized) column for the
 new parameters defined by the := operator. All other parameters i.e.
 using ~ have been standardized.

 How do i go about calculating the indirect effects based on standardized
 coefficients?


 You need to install 0.5-12, where the newly 'defined' parameters (defined
 by the := operator) are standardized too (just like the other
 parameters). This version is not on CRAN yet, but you can install it by
 typing in R:

 install.packages(lavaan, repos=http://www.da.ugent.be**,
 type=source)

 Yves.

 --
 Yves Rosseel -- http://www.da.ugent.be
 Department of Data Analysis, Ghent University
 http://lavaan.org


[[alternative HTML version deleted]]

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


Re: [R] Merging data in arrays

2013-02-22 Thread Rui Barradas

Hello,

I bet there are simpler solutions but I'm not thinking of anything else, 
right now.


fun - function(x, y){
f - function(a, b){
a - as.data.frame(a)
b - as.data.frame(b)
names(a)[1] - names(b)[1] - V1
res - merge(b, a, by = V1)
if(nrow(res)  0) as.matrix(res) else NULL
}
dx - dim(x)[3]
dy - dim(y)[3]
res - list()
ires - 0
for(idx in seq_len(dx)){
for(idy in seq_len(dy)){
tmp - f(x[, , idx], y[, , idy])
if(!is.null(tmp)){
ires - ires + 1
res[[ires]] - tmp
}
}
}
k - nrow(res[[1]])
m - ncol(res[[1]])
n - length(res)
array(unlist(res), dim = c(k, m, n))
}

G - fun(C, E)
identical(F, G)  #TRUE



Hope this helps,

Rui Barradas

Em 22-02-2013 03:40, Ray Cheung escreveu:

Thanks, Jeff.

Here is a simplified hypothetical sample (sorry for the clumsy code):
A1 - matrix(1:5, nrow=5, ncol=1)
A2 - matrix(6:10, nrow=5, ncol=1)
A3 - matrix(11:15, nrow=5, ncol=1)
A4 - matrix(16:20, nrow=5, ncol=1)
A5 - matrix(21:25, nrow=5, ncol=1)
A6 - matrix(26:30, nrow=5, ncol=1)
B1 - matrix(c(A1, A2, A3), nrow=5, ncol=3)
B2 - matrix(c(A2, A3, A4), nrow=5, ncol=3)
B3 - matrix(c(A3, A4, A5), nrow=5, ncol=3)
C - array(c(B1, B2, B3), dim = c(5,3,3))
D1 - matrix(c(A1, A4, A5), nrow=5, ncol=3)
D2 - matrix(c(A3, A5, A6), nrow=5, ncol=3)
E - array(c(D1, D2), dim = c(5,3,2))
In the above example, I want to merge array C to array E by matching the
column 1. That is, the resultant array F should look like this:
F1 - matrix(c(A1, A4, A5, A2, A3), nrow=5, ncol=5)
F2 - matrix(c(A3, A5, A6, A4, A5), nrow=5, ncol=5)
F - array(c(F1, F2), dim = c(5,5,2))

I want to have a more general way to do the merging because in reality, the
dimensions of C and E are very over thousands. Thank you very much.

Best Regards,
ray


On Fri, Feb 22, 2013 at 11:28 AM, Jeff Newmiller
jdnew...@dcn.davis.ca.uswrote:


I think this specification is insufficient to respond accurately to.
Please make a reproducible subset of your data (or simulated data) and
provide it in dput form, and describe your desired result data set more
clearly.


http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

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

Ray Cheung ray1...@gmail.com wrote:


Dear All,

I've 2 arrays A and B:

dim(A) = 100, 10, 1000
dim(B) = 100, 20, 900

I know there are 5 columns of values common to both arrays. I want to
ask
how to merge the 2 arrays. Thanks in advance!

Best Regards,
Ray

   [[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 two functions into one?

2013-02-22 Thread Jonsson
I am using the code below to calculate the correlation map between two
datasets. This code worked fine.

dir1 - list.files(D:thly, *.bin, full.names = TRUE)
dir2 - list.files(D:002, *.envi, full.names = TRUE)
file_tot - array(dim = c(1440, 720, 11, 2))
for(i in 1:length(dir1)) {
file_tot[, , i, 1] - readBin(dir1[i], numeric(), size = 4, 
n = 1440 * 720, signed = T)
file_tot[, , i, 2] - readBin(dir2[i], numeric(), size = 4, 
n = 1440 * 720, signed = T)
}
resultscor-apply(file_tot,c(1,2),function(x){cor(x[,1],x[,2],use =
na.or.complete)})

I would like to calculate the correlation only when the `P-value is lower
than 0.05`. so this function bellow will do the job:

 return_cor = function(x, y)  {
z = cor.test(x,y)
if(z[[3]]  0.05) {
return(z[[5]])
  } else { 
return(NA) 
}
}

However I got this error(as some pairs of my data are less then 3):

 Error in cor.test.default(x, y) : not enough finite
observations

in order to avoid this error and return NA when there are less than 3
pairs,this function does the job:

  cor_withN - function(...) {
  res - try(cor.test(...)$estimate, silent=TRUE)
  ifelse(class(res)==try-error, NA, res)
   }
Both functions worked perfectly.How can we merge both functions into one
function so we calculate correlation when P value is (certain value,
threshold) and also do the calculations even if there are less than 3 pairs.




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-merge-two-functions-into-one-tp4659365.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] Netcdf file in R

2013-02-22 Thread Anup khanal

Good afternoon,
I am a new in R. I have to work with large climate data.I am not able to read 
the netcdf file. Can anyone try with this file attached ?
Best Regards,
..Anup KhanalNorwegian Institute of science and Technology 
(NTNU)Trondheim, NorwayMob:(+47) 45174313
  __
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there a way to set the number of observations per cluster?

2013-02-22 Thread dma814
Say, under K-means, would there be a way to set a number (of
observations/members) to a clustering solution in order to obtain an evenly
distributed set of clusters?



--
View this message in context: 
http://r.789695.n4.nabble.com/Is-there-a-way-to-set-the-number-of-observations-per-cluster-tp4659366.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] Netcdf file in R

2013-02-22 Thread Gyanendra Pokharel
I can't see your attached file. Can you re-attache it?
Thanks
Gyanendra Pokharel
University of Guelph
Guelph, ON


On Fri, Feb 22, 2013 at 7:58 AM, Anup khanal za...@hotmail.com wrote:


 Good afternoon,
 I am a new in R. I have to work with large climate data.I am not able to
 read the netcdf file. Can anyone try with this file attached ?
 Best Regards,
 ..Anup KhanalNorwegian Institute of science and Technology
 (NTNU)Trondheim, NorwayMob:(+47) 45174313

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



[[alternative HTML version deleted]]

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


Re: [R] Getting htmlParse to work with Hebrew? (on windows)

2013-02-22 Thread Milan Bouchet-Valat
Le jeudi 21 février 2013 à 18:53 +0400, Lawr Eskin a écrit :
 iconv trued before in various try, same issue and result with encoding
 = unknown
 now try sub - same issue
This procedure works on Linux, but not on Windows:

library(RCurl)
library(XML)
u - http://www.cian.ru/cat.php?deal_type=2obl_id=1room1=1;
a - getURL(u, .encoding=UTF-8)
a - iconv(a, windows-1251, UTF-8)
a2 - htmlParse(sub(windows-1251, UTF-8, a))
a2

But maybe the problem is more general, and related to conversion between
encodings on Windows. What looks weird to me is that on Windows, I'm not
able to save a character string to a file in UTF-8, despite what ?file
says:
x - Все права защищены
Encoding(x)
# UTF-8
cat(x, con - file(foo, w, encoding=UTF-8)); close(con)
x2 - readLines(con - file(foo, r, encoding=UTF-8)); close(con)
Encoding(x2)
# unknown
x2
# [1] U+041AU+0443...

I know the problem happens on write because the file cannot be read
correctly on Linux either.

This Windows machine uses Windows Server 2008 with French_France.1252
locale.

 2013/2/21 Milan Bouchet-Valat nalimi...@club.fr
 Le jeudi 21 février 2013 à 18:31 +0400, Lawr Eskin a écrit :
  Hi Milan,
 
  a - getURL(con, .encoding = UTF-8)
  Encoding(a)
   [1] UTF-8
  a # Here - the UTF-8 codes looks like fine.
  htmlParse(a, encoding = UTF-8) ###again same encoding
 issue
 
 And what if you try this:
 a2 - htmlParse(sub(windows-1251, UTF-8, a))
 
 or this:
 a2 - htmlParse(iconv(a, windows-1251, UTF-8))
 
 
 Cheers
 
 
  why didn't getURL() detect and set a's encoding correctly?
  I think there are page issue because another sites works
 fine
 
  2013/2/21 Milan Bouchet-Valat nalimi...@club.fr
  Le jeudi 21 février 2013 à 16:04 +0400, Lawr Eskin a
 écrit :
   Hi Milan!
  
  
Encoding(a)
   [1] unknown
 
  Hm, here I get UTF-8, which is my locale encoding.
 
  I've tried a little more, and I discovered that
 using
  a - getURL(u, .encoding=UTF-8)
  ensures that a is in the correct encoding here. I
 know this is
  not your
  problem, but it might help: check whether
 Encoding(a) is set
  to UTF-8
  or not in that case, and whether this fixes things.
 
  I'm not sure how htmlParse() detects the encoding
 when you
  pass it a
  character vector, but it probably uses Encoding(a),
 since
  that's the
  only reliable information; if it is missing, maybe
 it falls
  back to what
  the contents of the file say (maybe even before what
 the
  encoding
  argument says), which is windows-1251, and may not
 be the
  encoding in
  which getURL() saved the character vector. The
 question would
  then be:
  why didn't getURL() detect and set a's encoding
 correctly?
 
 
  My two cents
 
 
   2013/2/21 Milan Bouchet-Valat nalimi...@club.fr
   Le jeudi 21 février 2013 à 13:16 +0400,
 Lawr Eskin a
  écrit :
Hello dear R-help mailing list.
   
   
Looks like the same issue in Russian:
   
   
   
library(RCurl)
   
library(XML)
   
u = 
  
 
 http://www.cian.ru/cat.php?deal_type=2obl_id=1room1=1;
   
a = getURL(u)
   
a # Here - the Russian is fine.
   
a2 - htmlParse(a)
   
a2 # Here it is a mess...
   
   
   
None of these seem to fix it:
   
   
   
htmlParse(a, encoding = windows-1251)
   
htmlParse(a, encoding = CP1251)
   
htmlParse(a, encoding = cp1251)
   
  

Re: [R] Netcdf file in R

2013-02-22 Thread Michael Sumner
There are at least three packages that can read NetCDF in native form,
RNetCDF, ncdf and ncdf4.

There are other options. Explore these ones.

Cheers, Mike.

On Sat, Feb 23, 2013 at 2:48 AM, Gyanendra Pokharel
gyanendra.pokha...@gmail.com wrote:
 I can't see your attached file. Can you re-attache it?
 Thanks
 Gyanendra Pokharel
 University of Guelph
 Guelph, ON


 On Fri, Feb 22, 2013 at 7:58 AM, Anup khanal za...@hotmail.com wrote:


 Good afternoon,
 I am a new in R. I have to work with large climate data.I am not able to
 read the netcdf file. Can anyone try with this file attached ?
 Best Regards,
 ..Anup KhanalNorwegian Institute of science and Technology
 (NTNU)Trondheim, NorwayMob:(+47) 45174313

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



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsum...@gmail.com

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


Re: [R] Netcdf file in R

2013-02-22 Thread Marc Schwartz
NetCDF is a binary file format and will be stripped by the list server filters. 
Don't bother attaching it unless the two of you want to communicate off-list.

Anup has not indicated what he has actually tried to do to read in the file. R 
will not natively read NetCDF files, so he will need to use a CRAN package. 

The first place to start would, as always, be with the manuals. In this case, 
the R Data Import/Export Manual:

  http://cran.r-project.org/doc/manuals/r-release/R-data.html

which provides information on at least two CRAN packages that can read these 
files. 

Spending a few minutes reading the manuals is typically enlightening.

Regards,

Marc Schwartz

On Feb 22, 2013, at 9:48 AM, Gyanendra Pokharel gyanendra.pokha...@gmail.com 
wrote:

 I can't see your attached file. Can you re-attache it?
 Thanks
 Gyanendra Pokharel
 University of Guelph
 Guelph, ON
 
 
 On Fri, Feb 22, 2013 at 7:58 AM, Anup khanal za...@hotmail.com wrote:
 
 
 Good afternoon,
 I am a new in R. I have to work with large climate data.I am not able to
 read the netcdf file. Can anyone try with this file attached ?
 Best Regards,
 ..Anup KhanalNorwegian Institute of science and Technology
 (NTNU)Trondheim, NorwayMob:(+47) 45174313

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

2013-02-22 Thread Jon Olav Skoien
I would also suggest the package raster, which usually make it much 
easier to extract spatial NetCDF-data than direct use of the 
NetCDF-packages.


Bests,
Jon

On 22-Feb-13 17:14, Marc Schwartz wrote:

NetCDF is a binary file format and will be stripped by the list server filters. 
Don't bother attaching it unless the two of you want to communicate off-list.

Anup has not indicated what he has actually tried to do to read in the file. R 
will not natively read NetCDF files, so he will need to use a CRAN package.

The first place to start would, as always, be with the manuals. In this case, 
the R Data Import/Export Manual:

   http://cran.r-project.org/doc/manuals/r-release/R-data.html

which provides information on at least two CRAN packages that can read these 
files.

Spending a few minutes reading the manuals is typically enlightening.

Regards,

Marc Schwartz

On Feb 22, 2013, at 9:48 AM, Gyanendra Pokharel gyanendra.pokha...@gmail.com 
wrote:


I can't see your attached file. Can you re-attache it?
Thanks
Gyanendra Pokharel
University of Guelph
Guelph, ON


On Fri, Feb 22, 2013 at 7:58 AM, Anup khanal za...@hotmail.com wrote:


Good afternoon,
I am a new in R. I have to work with large climate data.I am not able to
read the netcdf file. Can anyone try with this file attached ?
Best Regards,
..Anup KhanalNorwegian Institute of science and Technology
(NTNU)Trondheim, NorwayMob:(+47) 45174313

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



--
Jon Olav Skøien
Joint Research Centre - European Commission
Institute for Environment and Sustainability (IES)
Land Resource Management Unit

Via Fermi 2749, TP 440,  I-21027 Ispra (VA), ITALY

jon.sko...@jrc.ec.europa.eu
Tel:  +39 0332 789206

Disclaimer: Views expressed in this email are those of the individual and do 
not necessarily represent official views of the European Commission.

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

2013-02-22 Thread Rui Barradas

Hello,

Instead of try(cor.test) you could try(return_cor).
Also, isn't there a bug in return_cor? See the commented line below.

return_cor = function(x, y, tresh = 0.05)  {
z = cor.test(x,y)
if(z[[3]]  tresh) {
  return(z[[4]])  # not z[[5]], always zero
  } else {
return(NA)
}
}
cor_withN - function(...) {
  res - try(return_cor(...), silent=TRUE)
  ifelse(class(res)==try-error, NA, res)
}

cor_withN(1:10, 1:10 + rnorm(10))
cor_withN(1:2, 1:2 + rnorm(2))


Hope this helps,

Rui Barradas


Em 22-02-2013 15:04, Jonsson escreveu:

I am using the code below to calculate the correlation map between two
datasets. This code worked fine.

 dir1 - list.files(D:thly, *.bin, full.names = TRUE)
 dir2 - list.files(D:002, *.envi, full.names = TRUE)
 file_tot - array(dim = c(1440, 720, 11, 2))
 for(i in 1:length(dir1)) {
 file_tot[, , i, 1] - readBin(dir1[i], numeric(), size = 4,
 n = 1440 * 720, signed = T)
 file_tot[, , i, 2] - readBin(dir2[i], numeric(), size = 4,
 n = 1440 * 720, signed = T)
 }
 resultscor-apply(file_tot,c(1,2),function(x){cor(x[,1],x[,2],use =
na.or.complete)})

I would like to calculate the correlation only when the `P-value is lower
than 0.05`. so this function bellow will do the job:

  return_cor = function(x, y)  {
 z = cor.test(x,y)
 if(z[[3]]  0.05) {
 return(z[[5]])
   } else {
 return(NA)
 }
 }

However I got this error(as some pairs of my data are less then 3):

  Error in cor.test.default(x, y) : not enough finite
observations

in order to avoid this error and return NA when there are less than 3
pairs,this function does the job:

   cor_withN - function(...) {
   res - try(cor.test(...)$estimate, silent=TRUE)
   ifelse(class(res)==try-error, NA, res)
}
Both functions worked perfectly.How can we merge both functions into one
function so we calculate correlation when P value is (certain value,
threshold) and also do the calculations even if there are less than 3 pairs.




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-merge-two-functions-into-one-tp4659365.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] package ReadImages

2013-02-22 Thread Greg Snow
For some of the fancier transforms it may be easier to use an outside tool
such as Imagemagick which will do a lot of these things.  There is even a
C++ interface to imagemagick that may work nicely with packages like Rcpp
if you don't want to use an intermediate file.

But jobs like converting to grayscale can be very simple using R itself.
 Many of the functions that read in images store them as 3 dimensional
arrays and you would just need an apply command to change the 3 values for
each pixel to a grayscale value (see col2gray in the TeachingDemos package
for one way to do this, though loading in the whole package is probably
overkill for something this simple).


On Fri, Feb 22, 2013 at 1:57 AM, PIKAL Petr petr.pi...@precheza.cz wrote:

  Thanks. 

 ** **

 I tried EBImage several years ago for another problem, but Bioconductor
 packages have some difficulties to install in our network/firewall
 environment and I am not in a position to change it. It seems to me also an
 overkill for such simple task.

 ** **

 jpeg and png seems to me a bit too much simple, without direct possibility
 to transform from rgb to grayscale and normalisation.

 ** **

 Anyway, I will give it a try.

 ** **

 Petr

 ** **

 *From:* Greg Snow [mailto:538...@gmail.com]
 *Sent:* Friday, February 22, 2013 6:45 AM
 *To:* PIKAL Petr
 *Cc:* r-help

 *Subject:* Re: [R] package ReadImages

  ** **

 Some possibilities:  The EBImage package on Bioconductor; the jpeg and png
 packages read jpeg and png images.  

 ** **

 On Thu, Feb 21, 2013 at 8:26 AM, PIKAL Petr petr.pi...@precheza.cz
 wrote:

 Dear all

 I prepared some image processing routine which depended on package
 ReadImages. Basically I imported image to R, changed rgb to grayscale,
 normalised an image made some selections and changed to image by
 imagematrix.

 Recently I learned that this package was removed from CRAN and can not be
 used in R 3.0.0.

 What options I have now to import image to R, change it to grayscale, make
 some computation or selection, change it back to image and plot for visual
 inspection.

 Thanks
 Petr

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



 

 ** **

 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com 




-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] How to do generalized linear mixed effects models

2013-02-22 Thread Ross Boylan
On 2/21/2013 6:02 PM, Mitchell Maltenfort wrote:
 One more link to look at

 http://glmm.wikidot.com/faq

 This is the r-sig-mixed-models FAQ.
Thanks so much for pointing that out.  That seems to confirm that what I 
want is lme4, in particular glmer().
Ross

 On Thu, Feb 21, 2013 at 8:53 PM, Ross Boylan r...@biostat.ucsf.edu 
 mailto:r...@biostat.ucsf.edu wrote:

 I want to analyze binary, multinomial, and count outcomes (as well
 as the occasional continuous one) for clustered data.
 The more I search the less I know, and so I'm hoping the list can
 provide me some guidance about which of the many alternatives to
 choose.

 The nlme package seemed the obvious place to start.  However, it
 seems to be using specifications from nls, which does non-linear
 least squares.  I found the documentation opaque, and I'd prefer
 to stay in the generalized linear model framework and, ideally,
 maximum likelihood estimators.  (A recent review found maximum
 likelihood estimators using quadrature performed better than
 penalized likelhood methods, which specifically included glmmPQL
 in MASS: http://www.ncbi.nlm.nih.gov/pubmed/20949128).

 The lme4 package apparently supports generalized linear models.
  The title of the package is lme4: Linear mixed-effects models
 using S4 classes but the brief description is Fit linear and
 generalized linear mixed-effects models.

 Various people, including Douglas Bates in 2011
 (http://lme4.r-forge.r-project.org/slides/2011-01-11-Madison/5GLMM.pdf)
 who is an author of both nlme and lme4, seem to use it. Some 2007
 slides by Chris Manning:
 http://nlp.stanford.edu/~manning/courses/ling289/GLMM.pdf
 http://nlp.stanford.edu/%7Emanning/courses/ling289/GLMM.pdf also
 use lme4.

 However,
 http://cran.cnr.berkeley.edu/web/views/SocialSciences.html says
 the lme4 package, which largely supersedes nlme for *linear*
 mixed models, suggesting nlme is the most appropriate choice.

 Finally, there's gee in the same problem area.  Since I'm fuzzy on
 the underlying theory, and actually want to use the models to
 generate individual level imputations (and I know GEE is about the
 marginal distributions), I'd also rather avoid it.

 Thanks for any guidance.  Summarizing, the candidates include at least
 nlme
 glmmPQL (in MASS)
 lme4
 gee

 I think lme4 is what I want, despite the title and the Social
 Science task page.

 Ross Boylan


 P.S. Zero inflated models would be nice too.

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

2013-02-22 Thread lara sowale
I am sorry to bug you, I am having this error whenever I want to run
random effects regression in software R: Error in if (sigma2$id  0)
stop(paste(the estimated variance of the,  :
   missing value where TRUE/FALSE needed.

Please help me look into it.

[[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] remove rows in data frame by average

2013-02-22 Thread David Winsemius

On Feb 21, 2013, at 2:15 PM, William Dunlap wrote:

 Many find the functions in the plyr package more convenient to use than the
 do.call(rbind, lapply(split(...),...) business:
 
 library(plyr)
 ddply(dat1, .(Subject,Block),  summarize, MeanFeature1=mean(Feature1), 
 MeanFeature2=mean(Feature2))
Subject Block MeanFeature1 MeanFeature2
  1   1 1 55.0 29.0
  2   1 2 42.5 38.5
  3   1 3 64.0 14.0
 
 Change the calls to 'mean' to calls to other summary functions like 'sum' or 
 'max' as you wish. 

Apropos something less complex than the do.call( lapply( split...)) business: 
The same sort of operation is provided by `aggregate` when the function to be 
applied on all columns is the same:

 aggregate(dat1[, c('Feature1', 'Feature2')] , dat1[, c(Subject, Block)], 
 FUN=mean)
  Subject Block Feature1 Feature2
1   1 1 55.0 29.0
2   1 2 42.5 38.5
3   1 3 64.0 14.0

-- 
David

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of arun
 Sent: Thursday, February 21, 2013 1:45 PM
 To: Johannes Brand
 Cc: R help
 Subject: Re: [R] remove rows in data frame by average
 
 Hi,
 
 May be this helps:
 
 dat1- read.table(text=
 Subject Block Trial Feature1 Feature2
 1  1  1  48  40
 1  1  2   62  18
 1 2  134  43
 1  2  2   51 34
 1  3  1   64  14
 ,sep=,header=TRUE)
 
 
  res1-do.call(rbind,lapply(split(dat1,dat1$Block),function(x)
 data.frame(unique(x[,1:2]),t(colMeans(x[,-c(1:3)])
  res1
 #  Subject Block Feature1 Feature2
 #1   1 1 55.0 29.0
 #2   1 2 42.5 38.5
 #3   1 3 64.0 14.0
 
 
 #With multiple subjects:
 dat2- read.table(text=
 Subject Block Trial Feature1 Feature2
 1  1  1  48  40
 1  1  2   62  18
 1 2  134  43
 1  2  2   51 34
 1  3  1   64  14
 2  1  1   48  35
 2  1  2   54  15
 2  2  1   49  50
 2  2  2   64  40
 2  3  1   38  28
 ,sep=,header=TRUE)
 
  
 res2-do.call(rbind,lapply(split(dat2,list(dat2$Subject,dat2$Block)),function(x)
 data.frame(unique(x[,1:2]),t(colMeans(x[,-c(1:3)])
 res2-do.call(rbind,split(res2,res2$Subject))
 res2
  # Subject Block Feature1 Feature2
 #1   1 1 55.0 29.0
 #2   1 2 42.5 38.5
 #3   1 3 64.0 14.0
 #4   2 1 51.0 25.0
 #5   2 2 56.5 45.0
 #6   2 3 38.0 28.0
 
 
 
 A.K.
 
 
 
 - Original Message -
 From: Johannes Brand brandjohan...@gmx.de
 To: r-help@r-project.org
 Cc:
 Sent: Thursday, February 21, 2013 12:02 PM
 Subject: [R] remove rows in data frame by average
 
 Dear all,
 
 I have a data frame, which looks like this:
 
 Subject | Block | Trial | Feature1 | Feature2 
 1 | 1 | 1 | ... | ...
 1 | 1 | 2 | ... | ...
 1 | 2 | 1 | ... | ...
 1 | 2 | 2 | ... | ...
 1 | 3 | 1 | ... | ...
 ...| ...| ...| ... | ...
 
 Can I remove the Trial column by averaging all the rows and without using
 a for loop?
 
 At the end my data frame should look like this:
 
 Subject | Block | Feature1 | Feature2 
 1 | 1 | ... | ...
 1 | 2 | ... | ...
 1 | 3 | ... | ...
 ...| ...| ... | ...
 
 Thank you a lot for your help.
 
 Best,
 Johannes
 


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.


[R] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Rich Shepard

  With multiple panels in a lattice trellis plot the sequence is, for
example, 1, 10, 11, 12, 2, 3, 4. I want the sequence to be 1, 2, 3, 4, 10,
11, 12.

  Reading ?strip.default and the appropriate section in the Lattice book I'm
not seeing how to specify the 'human' numeric order rather than the computer
numeric order.

  A pointer will be appreciated.

TIA,

Rich

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


Re: [R] HELP!!!

2013-02-22 Thread David Winsemius

On Feb 22, 2013, at 11:02 AM, lara sowale wrote:

 I am sorry to bug you, I am having this error whenever I want to run
 random effects regression in software R: Error in if (sigma2$id  0)
 stop(paste(the estimated variance of the,  :
   missing value where TRUE/FALSE needed.
 
 Please help me look into it.

Please read the Posting Guide and after doing so repost with a question that 
admits of some possiblity of answering.

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

Yes, and that, too.
-- 
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] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread David Winsemius

On Feb 22, 2013, at 11:02 AM, Rich Shepard wrote:

  With multiple panels in a lattice trellis plot the sequence is, for
 example, 1, 10, 11, 12, 2, 3, 4. I want the sequence to be 1, 2, 3, 4, 10,
 11, 12.
 

It appears these may be factors. No much in the way of code can be offered 
since you have provided none of hte requested details.


  Reading ?strip.default and the appropriate section in the Lattice book I'm
 not seeing how to specify the 'human' numeric order rather than the computer
 numeric order.
 
  A pointer will be appreciated.
 

 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

Many pointers have been offered, but you have refused to heed them.

 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] HELP!!!

2013-02-22 Thread jim holtman
Run with:

options(error=utils::recover)

Then at the point of the error you will be able to examine sigma2$id
which is probably not a numeric.  Any time you get an error like this,
if you have been using the above statement in your script (which I
always have turned on), you will be able to discover for yourself most
of your bugs.  Debugging is an important talent to learn if you are
going to be writing programs/scripts.

On Fri, Feb 22, 2013 at 2:02 PM, lara sowale lara.d...@gmail.com wrote:
 I am sorry to bug you, I am having this error whenever I want to run
 random effects regression in software R: Error in if (sigma2$id  0)
 stop(paste(the estimated variance of the,  :
missing value where TRUE/FALSE needed.

 Please help me look into it.

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



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


Re: [R] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Rich Shepard

On Fri, 22 Feb 2013, David Winsemius wrote:


It appears these may be factors. No much in the way of code can be offered
since you have provided none of hte requested details.


  Yes, David, strip labels are factors. What sort of detail would you like
to see to advise me on how to specify the order of these factors?

  Do you want a data set?

  Here is an example command:


xyplot(sb.d$quant ~ sb.d$sampdate | sb.d$site, ylim=range(sb.d$quant), 
xlim=range(sb.d$sampdate), main='Antimony By Time', ylab='Concentraion (mg/L)', 
xlab='Time')


Rich

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


Re: [R] HELP!!!

2013-02-22 Thread Nicole Ford
Wow, Jim- fun tid bit!  Unrelated to op, but I will say thank you- as I know it 
will be useful!

~Nicole Ford
Ph.D. Student
Graduate Assistant/ Instructor
Department of Government and International Affairs
University of South Florida
office: SOC 012M
e: nmhi...@mail.usf.edu
http://gia.usf.edu/student/nford/

Sent from my iPhone

On Feb 22, 2013, at 2:23 PM, jim holtman jholt...@gmail.com wrote:

 Run with:
 
 options(error=utils::recover)
 
 Then at the point of the error you will be able to examine sigma2$id
 which is probably not a numeric.  Any time you get an error like this,
 if you have been using the above statement in your script (which I
 always have turned on), you will be able to discover for yourself most
 of your bugs.  Debugging is an important talent to learn if you are
 going to be writing programs/scripts.
 
 On Fri, Feb 22, 2013 at 2:02 PM, lara sowale lara.d...@gmail.com wrote:
 I am sorry to bug you, I am having this error whenever I want to run
 random effects regression in software R: Error in if (sigma2$id  0)
 stop(paste(the estimated variance of the,  :
   missing value where TRUE/FALSE needed.
 
 Please help me look into it.
 
[[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.
 
 
 
 -- 
 Jim Holtman
 Data Munger Guru
 
 What is the problem that you are trying to solve?
 Tell me what you want to do, not how you want to do it.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

[[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] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Bert Gunter
Manually change the ordering of the levels in the factor to that which
you want (see ?factor if necessary) and replot.

-- Bert

On Fri, Feb 22, 2013 at 11:17 AM, David Winsemius
dwinsem...@comcast.net wrote:

 On Feb 22, 2013, at 11:02 AM, Rich Shepard wrote:

  With multiple panels in a lattice trellis plot the sequence is, for
 example, 1, 10, 11, 12, 2, 3, 4. I want the sequence to be 1, 2, 3, 4, 10,
 11, 12.


 It appears these may be factors. No much in the way of code can be offered 
 since you have provided none of hte requested details.


  Reading ?strip.default and the appropriate section in the Lattice book I'm
 not seeing how to specify the 'human' numeric order rather than the computer
 numeric order.

  A pointer will be appreciated.


 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

 Many pointers have been offered, but you have refused to heed them.

 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


[R] R on mac not installing packages

2013-02-22 Thread londonphd

Hi, I have not been able to use R in my macbook pro. I am getting the
following error message every time i try to install a package

* installing *source* package ‘Hmisc’ ...
** package ‘Hmisc’ successfully unpacked and MD5 sums checked
** libs
*** arch - i386
sh: make: command not found
ERROR: compilation failed for package ‘Hmisc’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/Hmisc’
* installing *source* package ‘quadprog’ ...
** libs
*** arch - i386
sh: make: command not found
ERROR: compilation failed for package ‘quadprog’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/quadprog’
ERROR: dependency ‘Hmisc’ is not available for package ‘its’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/its’
ERROR: dependency ‘quadprog’ is not available for package ‘tseries’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/tseries’

The downloaded source packages are in

‘/private/var/folders/c7/jrjv78_x6f53l3sw_w715gk0gn/T/RtmpS4sYUx/downloaded_packages’


I look forward to your help, plsease




--
View this message in context: 
http://r.789695.n4.nabble.com/R-on-mac-not-installing-packages-tp4659392.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] Getting htmlParse to work with Hebrew? (on windows)

2013-02-22 Thread Lawr Eskin
I thiknk that I have to install Linux on VM... There is a shortest way

by the way, could you please advise how to rebuild 'XML' package for R with
latest libxml sources? Who may do that?
or is it possible to build the new R package based on another non-C sorced
parsers based like on PyPY, erlang and so on?

2013/2/22 Milan Bouchet-Valat nalimi...@club.fr

 Le jeudi 21 février 2013 à 18:53 +0400, Lawr Eskin a écrit :
  iconv trued before in various try, same issue and result with encoding
  = unknown
  now try sub - same issue
 This procedure works on Linux, but not on Windows:

 library(RCurl)
 library(XML)
 u - http://www.cian.ru/cat.php?deal_type=2obl_id=1room1=1;
 a - getURL(u, .encoding=UTF-8)
 a - iconv(a, windows-1251, UTF-8)
 a2 - htmlParse(sub(windows-1251, UTF-8, a))
 a2

 But maybe the problem is more general, and related to conversion between
 encodings on Windows. What looks weird to me is that on Windows, I'm not
 able to save a character string to a file in UTF-8, despite what ?file
 says:
 x - Все права защищены
 Encoding(x)
 # UTF-8
 cat(x, con - file(foo, w, encoding=UTF-8)); close(con)
 x2 - readLines(con - file(foo, r, encoding=UTF-8)); close(con)
 Encoding(x2)
 # unknown
 x2
 # [1] U+041AU+0443...

 I know the problem happens on write because the file cannot be read
 correctly on Linux either.

 This Windows machine uses Windows Server 2008 with French_France.1252
 locale.

  2013/2/21 Milan Bouchet-Valat nalimi...@club.fr
  Le jeudi 21 février 2013 à 18:31 +0400, Lawr Eskin a écrit :
   Hi Milan,
  
   a - getURL(con, .encoding = UTF-8)
   Encoding(a)
[1] UTF-8
   a # Here - the UTF-8 codes looks like fine.
   htmlParse(a, encoding = UTF-8) ###again same encoding
  issue
 
  And what if you try this:
  a2 - htmlParse(sub(windows-1251, UTF-8, a))
 
  or this:
  a2 - htmlParse(iconv(a, windows-1251, UTF-8))
 
 
  Cheers
 
 
   why didn't getURL() detect and set a's encoding correctly?
   I think there are page issue because another sites works
  fine
  
   2013/2/21 Milan Bouchet-Valat nalimi...@club.fr
   Le jeudi 21 février 2013 à 16:04 +0400, Lawr Eskin a
  écrit :
Hi Milan!
   
   
 Encoding(a)
[1] unknown
  
   Hm, here I get UTF-8, which is my locale encoding.
  
   I've tried a little more, and I discovered that
  using
   a - getURL(u, .encoding=UTF-8)
   ensures that a is in the correct encoding here. I
  know this is
   not your
   problem, but it might help: check whether
  Encoding(a) is set
   to UTF-8
   or not in that case, and whether this fixes things.
  
   I'm not sure how htmlParse() detects the encoding
  when you
   pass it a
   character vector, but it probably uses Encoding(a),
  since
   that's the
   only reliable information; if it is missing, maybe
  it falls
   back to what
   the contents of the file say (maybe even before what
  the
   encoding
   argument says), which is windows-1251, and may not
  be the
   encoding in
   which getURL() saved the character vector. The
  question would
   then be:
   why didn't getURL() detect and set a's encoding
  correctly?
  
  
   My two cents
  
  
2013/2/21 Milan Bouchet-Valat nalimi...@club.fr
Le jeudi 21 février 2013 à 13:16 +0400,
  Lawr Eskin a
   écrit :
 Hello dear R-help mailing list.


 Looks like the same issue in Russian:



 library(RCurl)

 library(XML)

 u = 
   
  
  http://www.cian.ru/cat.php?deal_type=2obl_id=1room1=1;

 a = getURL(u)

 a # Here - the Russian is fine.

 a2 - htmlParse(a)

 a2 # Here it is a mess...


   

[R] Fwd: difficulty defining variables as categorical using Gower with DAISY

2013-02-22 Thread Joanna Papakonstantinou

 I am using the iris dataset that contains mixed variables (some columns are 
 numeric and some categorical).
  
 
  iris
 Sepal.Length Sepal.Width Petal.Length Petal.WidthSpecies
 15.1 3.5  1.4 0.2 setosa
 24.9 3.0  1.4 0.2 setosa
 34.7 3.2  1.3 0.2 setosa
 44.6 3.1  1.5 0.2 setosa
 .
 .
 .

 I am trying to use the Gower metric so that I may specify that some columns 
 contain categorical data.
  iris.clust-daisy(iris, metric = gower, stand = FALSE, type = 
  list(factor=Species))
 
But it is saying that the type= I, I, I, I, N
so obviously it is not reading the variable types correctly.

Could someone please tell me how to specify the types correctly?

Thank you.
  
 **
  
 Joanna Papakonstantinou, Ph.D.
 

[[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] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Rich Shepard

On Fri, 22 Feb 2013, Bert Gunter wrote:


Manually change the ordering of the levels in the factor to that which you
want (see ?factor if necessary) and replot.


Bert,

  I'll do this.

  I looked at ?factor and will try is.ordered() to see if that makes a
difference.

Many thanks,

Rich

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


Re: [R] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread David Winsemius

On Feb 22, 2013, at 11:29 AM, Rich Shepard wrote:

 On Fri, 22 Feb 2013, David Winsemius wrote:
 
 It appears these may be factors. No much in the way of code can be offered
 since you have provided none of hte requested details.
 
  Yes, David, strip labels are factors. What sort of detail would you like
 to see to advise me on how to specify the order of these factors?
 
  Do you want a data set?
 
  Here is an example command:
 
 xyplot(sb.d$quant ~ sb.d$sampdate | sb.d$site, ylim=range(sb.d$quant), 
 xlim=range(sb.d$sampdate), main='Antimony By Time', ylab='Concentraion 
 (mg/L)', xlab='Time')

My response can be seen on your cross-posted SO question. 

-- 
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] R on mac not installing packages

2013-02-22 Thread David Winsemius
The system is reporting that it cannot find `make`. It appears that you have 
not installed XCode on you Mac, or that you did with an earlier version for 
which you have not updated, or something else which has broken your 
installation. Please read the MacOS FAQ. (And post further such question on the 
SIG-Mac mailing list.)

On Feb 22, 2013, at 12:15 PM, londonphd wrote:

 
 Hi, I have not been able to use R in my macbook pro. I am getting the
 following error message every time i try to install a package
 
 * installing *source* package ‘Hmisc’ ...
 ** package ‘Hmisc’ successfully unpacked and MD5 sums checked
 ** libs
 *** arch - i386
 sh: make: command not found
 ERROR: compilation failed for package ‘Hmisc’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/Hmisc’
 * installing *source* package ‘quadprog’ ...
 ** libs
 *** arch - i386
 sh: make: command not found
 ERROR: compilation failed for package ‘quadprog’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/quadprog’
 ERROR: dependency ‘Hmisc’ is not available for package ‘its’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/its’
 ERROR: dependency ‘quadprog’ is not available for package ‘tseries’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/tseries’
 
 The downloaded source packages are in
 
 ‘/private/var/folders/c7/jrjv78_x6f53l3sw_w715gk0gn/T/RtmpS4sYUx/downloaded_packages’
 
 
 I look forward to your help, plsease
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/R-on-mac-not-installing-packages-tp4659392.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] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Bert Gunter
You do not need to use ordered factors.

newfac - factor(oldfac, lev= ...) ## will do it. e.g.

 x - factor(letters[1:3]) ## default ordering is alphabetic (mod locale)
 x
[1] a b c
Levels: a b c
 y - factor(x,lev=letters[3:1])  ## reorder the levels
 y
[1] a b c
Levels: c b a

-- Bert

On Fri, Feb 22, 2013 at 1:22 PM, Rich Shepard rshep...@appl-ecosys.com wrote:
 On Fri, 22 Feb 2013, Bert Gunter wrote:

 Manually change the ordering of the levels in the factor to that which you
 want (see ?factor if necessary) and replot.


 Bert,

   I'll do this.

   I looked at ?factor and will try is.ordered() to see if that makes a
 difference.

 Many thanks,

 Rich

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] R on mac not installing packages

2013-02-22 Thread Prof Brian Ripley

On 22/02/2013 21:26, David Winsemius wrote:

The system is reporting that it cannot find `make`. It appears that you have 
not installed XCode on you Mac, or that you did with an earlier version for 
which you have not updated, or something else which has broken your 
installation. Please read the MacOS FAQ. (And post further such question on the 
SIG-Mac mailing list.)


For the record, such information is in the 'R Installation and 
Administration Manual', as from R-patched (and hence R 2.15.3 and R 
3.0.0).  See e.g. 
http://cran.r-project.org/doc/manuals/r-release/R-admin.html#Mac-OS-X .


On recent versions of OS X it is not Xcode you need, but the 'Xcode 
command-line tools'.  These can be installed from inside Xcode 
(Preferences-Downloads-Components) or separately.


For Hmisc you will need a matching Fortran compiler: see that manual.


On Feb 22, 2013, at 12:15 PM, londonphd wrote:



Hi, I have not been able to use R in my macbook pro. I am getting the
following error message every time i try to install a package

* installing *source* package ‘Hmisc’ ...
** package ‘Hmisc’ successfully unpacked and MD5 sums checked
** libs
*** arch - i386
sh: make: command not found
ERROR: compilation failed for package ‘Hmisc’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/Hmisc’
* installing *source* package ‘quadprog’ ...
** libs
*** arch - i386
sh: make: command not found
ERROR: compilation failed for package ‘quadprog’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/quadprog’
ERROR: dependency ‘Hmisc’ is not available for package ‘its’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/its’
ERROR: dependency ‘quadprog’ is not available for package ‘tseries’
* removing ‘/Users/ravshonbek/Library/R/2.15/library/tseries’

The downloaded source packages are in

‘/private/var/folders/c7/jrjv78_x6f53l3sw_w715gk0gn/T/RtmpS4sYUx/downloaded_packages’


I look forward to your help, plsease




--
View this message in context: 
http://r.789695.n4.nabble.com/R-on-mac-not-installing-packages-tp4659392.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.




--
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] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread David Winsemius

On Feb 22, 2013, at 1:22 PM, Rich Shepard wrote:

 On Fri, 22 Feb 2013, Bert Gunter wrote:
 
 Manually change the ordering of the levels in the factor to that which you
 want (see ?factor if necessary) and replot.
 
 Bert,
 
  I'll do this.
 
  I looked at ?factor and will try is.ordered() to see if that makes a
 difference.

`is.ordered` will return TRUE if it is an ordered factor. That's not what you 
want to know and using `as.ordered` would also fail to provide the needed 
ordering. You need to provide a proper levels argument to the factor function. 
And you will find that making an ordered factor will probably have undesirable 
side effects.

-- 

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] R on mac not installing packages

2013-02-22 Thread Marc Schwartz

On Feb 22, 2013, at 3:46 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote:

 On 22/02/2013 21:26, David Winsemius wrote:
 The system is reporting that it cannot find `make`. It appears that you have 
 not installed XCode on you Mac, or that you did with an earlier version for 
 which you have not updated, or something else which has broken your 
 installation. Please read the MacOS FAQ. (And post further such question on 
 the SIG-Mac mailing list.)
 
 For the record, such information is in the 'R Installation and Administration 
 Manual', as from R-patched (and hence R 2.15.3 and R 3.0.0).  See e.g. 
 http://cran.r-project.org/doc/manuals/r-release/R-admin.html#Mac-OS-X .
 
 On recent versions of OS X it is not Xcode you need, but the 'Xcode 
 command-line tools'.  These can be installed from inside Xcode 
 (Preferences-Downloads-Components) or separately.
 
 For Hmisc you will need a matching Fortran compiler: see that manual.


It seems reasonable to ask however, why he is installing source CRAN packages 
on OSX when the default OSX install would be binaries, if he installed R by 
using Simon's OSX binary. 

If he installed R from source, he should have already had the requisite 
compiler related tools installed.

Perhaps I need more coffee late on a Friday, but something seems inconsistent 
here.

Regards,

Marc Schwartz


 
 On Feb 22, 2013, at 12:15 PM, londonphd wrote:
 
 
 Hi, I have not been able to use R in my macbook pro. I am getting the
 following error message every time i try to install a package
 
 * installing *source* package ‘Hmisc’ ...
 ** package ‘Hmisc’ successfully unpacked and MD5 sums checked
 ** libs
 *** arch - i386
 sh: make: command not found
 ERROR: compilation failed for package ‘Hmisc’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/Hmisc’
 * installing *source* package ‘quadprog’ ...
 ** libs
 *** arch - i386
 sh: make: command not found
 ERROR: compilation failed for package ‘quadprog’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/quadprog’
 ERROR: dependency ‘Hmisc’ is not available for package ‘its’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/its’
 ERROR: dependency ‘quadprog’ is not available for package ‘tseries’
 * removing ‘/Users/ravshonbek/Library/R/2.15/library/tseries’
 
 The downloaded source packages are in
 
 ‘/private/var/folders/c7/jrjv78_x6f53l3sw_w715gk0gn/T/RtmpS4sYUx/downloaded_packages’
 
 
 I look forward to your help, plsease

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

2013-02-22 Thread Elaine Kuo
Hello



I am using lattice bwplot to draw migration distance of three groups of
birds.

The boxplots from the left to right is displayed

in alphabetic order of the boxplot names, as the default setting.



However, I would like the boxplots from the left to right to be displayed
according to the migration distance from the short values to the long ones.

In the data below, from the left to the right should be Gruiformes,
Falconiiformes, and Charadriiformes.



Please kindly advise how to modify the code below.

The data is as below.

Thank you.


Elaine





Code

Library(lattice)

bwplot(migration_distance~bird)





data

migration distance (km)bird group

10987  Charadriiformes

9867Charadriiformes

8702Charadriiformes

9432Charadriiformes

9054Charadriiformes

5087   Falconiiformes

5783   Falconiiformes

5298Falconiiformes

5687   Falconiiformes

3987Gruiformes

3298Gruiformes

3567Gruiformes

3409Gruiformes

3321Gruiformes

3598Gruiformes

[[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] locating boxplot in bwplot (lattice)

2013-02-22 Thread Ben Bolker
Elaine Kuo elaine.kuo.tw at gmail.com writes:

 
 Hello
 
 I am using lattice bwplot to draw migration distance of three groups of
 birds.
 
 The boxplots from the left to right is displayed
 in alphabetic order of the boxplot names, as the default setting.
 
 However, I would like the boxplots from the left to right to be displayed
 according to the migration distance from the short values to the long ones.
 
 In the data below, from the left to the right should be Gruiformes,
 Falconiiformes, and Charadriiformes.
 
 Please kindly advise how to modify the code below.
 

 Define the order of the levels of your factor 
accordingly. Take a look at

http://stackoverflow.com/questions/15033107/
  specifing-order-of-lattice-plot-panels

(broken URL to meet gmane line length limits)

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


Re: [R] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Rich Shepard

On Fri, 22 Feb 2013, David Winsemius wrote:


`is.ordered` will return TRUE if it is an ordered factor. That's not what
you want to know and using `as.ordered` would also fail to provide the
needed ordering. You need to provide a proper levels argument to the
factor function. And you will find that making an ordered factor will
probably have undesirable side effects.


  Thank you, David. That was the conclusion I was approaching as I tried
is.ordered and as.ordered and saw they did not affec the needed changes.
I'll look at levels or sort the input data file before reading it into R.

Rich

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


Re: [R] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Rich Shepard

On Fri, 22 Feb 2013, Bert Gunter wrote:


You do not need to use ordered factors.
newfac - factor(oldfac, lev= ...) ## will do it. e.g.


x - factor(letters[1:3]) ## default ordering is alphabetic (mod locale)
x

[1] a b c
Levels: a b c

y - factor(x,lev=letters[3:1])  ## reorder the levels
y

[1] a b c
Levels: c b a


Bert,

  Makes sense. I wonder if this will work when only a portion of the site
IDs need to be explicitly ordered. There are 64 sites in all. Might be
easier to sort the text file.

Thanks again,

Rich

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


Re: [R] HELP!!!

2013-02-22 Thread Ben Bolker
David Winsemius dwinsemius at comcast.net writes:

 On Feb 22, 2013, at 11:02 AM, lara sowale wrote:
 
  I am sorry to bug you, I am having this error whenever I want to run
  random effects regression in software R: Error in if (sigma2$id  0)
  stop(paste(the estimated variance of the,  :
missing value where TRUE/FALSE needed.
  
  Please help me look into it.
 
 Please read the Posting Guide and after doing so repost with 
 a question that admits of some possiblity of answering.

  In case you need the URL: http://www.r-project.org/posting-guide.html

  Some google-detection (searching for if sigma2$id error)
suggests that the OP is using the ercomp package, but beyond
that the question is still (as you suggest) unanswerable.

 Ben Bolker

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

2013-02-22 Thread jason tyler
Hi all,

I was installing a package *RBGL* of bioconductor. However, I had some
issues while installing it. I asked the devel group of bioconductor and
they told me to consult this group. Here is my conversation with the
bioconductor group related to the problem


*Me-*
I was trying to install the RBGL package using the following command

biocLite(RBGL)

However, I got the following error
*
installing *source* package ‘RBGL’ ...
untarring boost include tree...
** libs
/usr/bin/clang++ -I/usr/local/Cellar/r/2.15.1/R.framework/Resources/include
-DNDEBUG  -I/usr/local/Cellar/readline/6.2.4/include -isystem
/usr/local/include -I/usr/X11/include   -Irbgl_trimmed_boost_1_49_0 -fPIC
-Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7  -c
bbc.cpp -o bbc.o
/usr/bin/clang++ -I/usr/local/Cellar/r/2.15.1/R.framework/Resources/include
-DNDEBUG  -I/usr/local/Cellar/readline/6.2.4/include -isystem
/usr/local/include -I/usr/X11/include   -Irbgl_trimmed_boost_1_49_0 -fPIC
-Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7  -c
cliques.cpp -o cliques.o
cliques.cpp:26:31: error: redefinition of 'p' as different kind of symbol
std::pairEdge, bool p;
  ^
rbgl_trimmed_boost_1_49_0/boost/mpl/assert.hpp:149:42: note: previous
definition is here
BOOST_MPL_AUX_ASSERT_CONSTANT( bool, p = !p_type::value );
 ^
rbgl_trimmed_boost_1_49_0/boost/mpl/assert.hpp:56:58: note: expanded from
macro 'BOOST_MPL_AUX_ASSERT_CONSTANT'
#   define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
 ^
cliques.cpp:53:19: error: expression is not assignable
p = edge(*va1, *va2, g);
~ ^
cliques.cpp:54:25: error: member reference base type
'mpl_::assert_arg_pred_notboost::detail::is_iterator_traversalboost::random_access_traversal_tag::anonymous
enum at
  rbgl_trimmed_boost_1_49_0/boost/mpl/assert.hpp:149:5' is not a
structure or union
if ( !p.second ) return FALSE;*


Any suggestions how to overcome this or what is causing this issue?

*Vincent Gray(of bioconductor group) - *
please provide sessionInfo() and result of gcc -v

*Me-*
gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~28/src/configure
--disable-checking --enable-werror --prefix=/Applications/Xcode.
app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm-
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin11 --enable-llvm=/private/var/
tmp/llvmgcc42/llvmgcc42-2336.11~28/dst-llvmCore/Developer/usr/local
--program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11
--target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)


*sessionInfo() Results*

R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin11.4.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] BiocInstaller_1.8.3

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

Thanks

Regards,
Jason

*Vincent Gray - *
OK, I didn't read your log too well, so I missed that you are using
clang++.  Theoretically it will work

http://blog.llvm.org/2010/05/clang-builds-boost.html

I am using the gcc supplied in Xcode 4.0.2, with

bash-3.2$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~123/src/configure
--disable-checking --enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10-
--host=x86_64-apple-darwin10 --target=i686-apple-darwin10
--with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

this has no problem installing RBGL from source.  your R is a little out of
date but I don't think that's an issue.

I have minimal experience with clang++ and you may have to take this to
R-help or R-devel if you are not going to use Xcode- based compilation, as
that's what we are basing our builds/tests on.  I did try

bash-3.2$ clang++ -v
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
bash-3.2$ clang++ -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names
-undefined dynamic_lookup -single_module -multiply_defined suppress
-L/Users/stvjc/ExternalSoft/READLINE-62-DIST/lib -lreadline
-L//Users/stvjc/ExternalSoft/LIBICONV-64/lib -liconv
-L/Users/stvjc/ExternalSoft/jpeg-6b -ljpeg -o cliques.so cliques.o

Re: [R] Help xyplot

2013-02-22 Thread Peter Maclean
Hi Mackay and anybody
(a) Is it possible to select randomly (let say five grids) and plot?
(b) Is it possible to plot five nearest grid in one figure?
The original question and improved codes:


#I am ploting gridded time series data. I would like the actual lat 
#and lon value appear on the graph-if possible inside the graph as 
#numbers. If there is also more elegant ways to plot the graphs I 
#will appreciate more suggestions.
#
library(ggplot2)
library(lattice)
month - c(Jan, Feb, Mar, Apr, May, Jun, Jul,
Aug, Sep, Oct, Nov, Dec)
month - factor(month, levels = month.abb)
data - as.data.frame(expand.grid(lon=seq(4,5, 1), lat=seq(-3,-2,1),
year=seq(2010, 2012,1), month=month))
n=nrow(data)
data$prec - rgamma(n, 2, 0.25)
data$year - factor(data$year)
data$lon  - factor(data$lon)
data$lat  - factor(data$lat)
ndata - data[order(data$lon, data$lat),]
fix(ndata)
max - max(ndata$prec, na.rm=TRUE)
min - min(ndata$prec, na.rm=TRUE)

#Plot the graph and save as pdf by Mackay suggestion
pdf(H:/file.pdf)
library(latticeExtra)
useOuterStrips(
xyplot(prec~month|year*paste(lat,lon), data=ndata,
as.table = T,
type = c(l, l,p), ylim=c(min, max),
layout=c(1,4)) )
dev.off()#The actual data have more than 5 thousand data points, Just want to 
plot a few
#selected randomly. Also, if I can put 5 data points (nearest grids) in one 
graph
#will be more helpful.


Peter Maclean
Department of Economics
UDSM
[[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] Fitting this data with a gaussian would be great

2013-02-22 Thread Samantha Warnes
Hello,I'm still working with this data set, and trying to fit it with a 
nonlinear model. Here is my data
 small - 
 c(507680,507670,508832,510184,511272,513380,515828,519160,525046,534046,547982,567124,590208,614506,637876,656846,669054,672976,668800,656070,637136,614342,590970,570752,554480,542882,535630,531276,528682,527682,527020,526834,526802,526860)


test - glm(dnorm(x), data=small)
Error in formula.default(object, env = baseenv()) : invalid formula


I have tried a variety of options for the formula with the same effect. What I 
want to do with this data is simply fit it with a non linear model, most likely 
a gaussian.


Thanks in advance,
Samantha

[[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] Fitting this data with a gaussian would be great

2013-02-22 Thread Ben Bolker
Samantha Warnes warnes at wisc.edu writes:

 
 Hello,I'm still working with this data set, and 
 trying to fit it with a nonlinear model. Here is my data
  small - c(507680,507670,508832,510184,511272,513380,515828,
  519160,525046,
  534046,547982,567124,590208,614506,637876,656846,669054,672976,668800,
656070,637136,614342,590970,570752,554480,542882,535630,531276,528682,
  527682,527020,526834,526802,526860)
 
 test - glm(dnorm(x), data=small)
 Error in formula.default(object, env = baseenv()) : invalid formula
 

  I'm sorry, but as stated the question doesn't make much sense.
  You haven't stated your nonlinear model at all, and you haven't
said anything about any predictor variables.
  
  If you want fit a *constant* normal model you can

1. Compute the mean and standard deviation of the data (which
are the parameters of the model): mean(small), sd(small)

2. use an intercept-only model with lm(small~1) or glm(small~1)
(although the latter is definitely overkill)

3. You *can* use a nonlinear fitting method to estimate an
intercept-only model

nls(small~a,start=list(a=564000))

but it doesn't really mean much.

  Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] assign index to colnames(matrix)

2013-02-22 Thread Prew, Paul
Hello,  I’m trying to follow the syntax of a script from a journal website.  
In order to create a regression formula used later in the script, the 
regression matrix must have column names “X1”, “X2”, etc.  I have tried 
to assign these column names to my matrix ScoutRSM.mat using a for loop, but I 
don’t know how to interpret the error message.  Suggestions?  Thanks, Paul



== instructions about dimnames(X)[[2]] = X1,X2,...  ===


function(binstr)
{
  # makes formula for regression
  # must make sure dimnames(X)[[2]] = X1,X2,...
  ind-which(binstr==1)
  rht - paste(X, ind, sep=, collapse=+)
  ans-paste(y ~ , rht)
  return(as.formula(ans))
}


###
##  my for loop  ##
###

for (i in 1:dim(ScoutRSM.mat)[2]  {
colnames(ScoutRSM.mat)[i] - paste(X, i, sep = “”))
}

 for(i in 1:dim(ScoutRSM.mat)[2]) {
+   colnames(ScoutRSM.mat)[i] - paste(X,i, sep = )
+ }
Error in `colnames-`(`*tmp*`, value = X1) :
  length of 'dimnames' [2] not equal to array extent


~~
  ScoutRSM.mat  ~~
~~

 dput(ScoutRSM.mat)
structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, -1, 1, -1, 0, -1, 0, 0, 0, 1, 1, 0, 1, -1, 1, -1, 1, 0, -1,
-0.464, -0.516, -0.48, 1, -0.008, 0.486, 0, 0.524, -0.96, -1,
-0.526, 1, 0.47, 0.49, 0, 0.53, -0.866, -0.6, 0.227, -1, -0.895,
1.289, 0.181, 0.204, -1, 0.199, -0.908, -1, -1, 1.289, 1.289,
0.204, -1, 0.213, -0.922, -1, -0.84, -1, 0.2, -1, -1, 0.05, -1,
1.136, -0.861, -0.861, -1, 1.136, 0.193, 0.047, -1, -1, -0.733,
-1, -0.817, 0.14, -1, 1, 0.127, -0.05, 1, -1, -0.797, -0.797,
0.123, -1, -1, -0.04, 1, 1, -0.75, 0, 0.464, -0.516, 0.48, 0,
0.008, 0, 0, 0, -0.96, -1, 0, 1, -0.47, 0.49, 0, 0.53, 0, 0.6,
-0.227, -1, 0.895, 0, -0.181, 0, 0, 0, -0.908, -1, 0, 1.289,
-1.289, 0.204, 1, 0.213, 0, 1, 0.84, -1, -0.2, 0, 1, 0, 0, 0,
-0.861, -0.861, 0, 1.136, -0.193, 0.047, 1, -1, 0, 1, 0.817,
0.14, 1, 0, -0.127, 0, 0, 0, -0.797, -0.797, 0, -1, 1, -0.04,
-1, 1, 0, 0, -0.105, 0.516, 0.429, 1.289, -0.001, 0.099, 0, 0.104,
0.872, 1, 0.526, 1.289, 0.606, 0.1, 0, 0.113, 0.799, 0.6, 0.39,
0.516, -0.096, -1, 0.008, 0.025, 0, 0.596, 0.827, 0.861, 0.526,
1.136, 0.091, 0.023, 0, -0.53, 0.635, 0.6, 0.379, -0.072, 0.48,
1, -0.001, -0.024, 0, -0.524, 0.765, 0.797, -0.065, -1, -0.47,
-0.02, 0, 0.53, 0.65, 0, -0.19, 1, -0.179, -1.289, -0.181, 0.01,
1, 0.226, 0.782, 0.861, 1, 1.464, 0.249, 0.01, 1, -0.213, 0.676,
1, -0.185, -0.14, 0.895, 1.289, 0.023, -0.01, -1, -0.199, 0.724,
0.797, -0.123, -1.289, -1.289, -0.008, -1, 0.213, 0.692, 0, 0.686,
-0.14, -0.2, -1, -0.127, -0.003, -1, -1.136, 0.686, 0.686, -0.123,
-1.136, -0.193, -0.002, -1, -1, 0.55, 0, 1, 1, 1, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0.215, 0.266, 0.23, 1, 0, 0.236,
0, 0.275, 0.922, 1, 0.277, 1, 0.221, 0.24, 0, 0.281, 0.75, 0.36,
0.051, 1, 0.801, 1.66, 0.033, 0.042, 1, 0.04, 0.825, 1, 1, 1.66,
1.66, 0.042, 1, 0.045, 0.85, 1, 0.705, 1, 0.04, 1, 1, 0.003,
1, 1.292, 0.742, 0.742, 1, 1.292, 0.037, 0.002, 1, 1, 0.537,
1, 0.667, 0.02, 1, 1, 0.016, 0.003, 1, 1, 0.635, 0.635, 0.015,
1, 1, 0.002, 1, 1, 0.563, 0, 0.105, 0.516, -0.429, 0, 0.001,
0, 0, 0, 0.872, 1, 0, 1.289, -0.606, 0.1, 0, 0.113, 0, -0.6,
-0.39, 0.516, 0.096, 0, -0.008, 0, 0, 0, 0.827, 0.861, 0, 1.136,
-0.091, 0.023, 0, -0.53, 0, -0.6, -0.379, -0.072, -0.48, 0, 0.001,
0, 0, 0, 0.765, 0.797, 0, -1, 0.47, -0.02, 0, 0.53, 0, 0, 0.19,
1, 0.179, 0, 0.181, 0, 0, 0, 0.782, 0.861, 0, 1.464, -0.249,
0.01, -1, -0.213, 0, -1, 0.185, -0.14, -0.895, 0, -0.023, 0,
0, 0, 0.724, 0.797, 0, -1.289, 1.289, -0.008, 1, 0.213, 0, 0,
-0.686, -0.14, 0.2, 0, 0.127, 0, 0, 0, 0.686, 0.686, 0, -1.136,
0.193, -0.002, 1, -1, 0, 0, 0.088, -0.516, 0.086, -1.289, 0.001,
0.005, 0, 0.119, -0.751, -0.861, -0.526, 1.464, 0.117, 0.005,
0, -0.113, -0.585, -0.6, 0.086, 0.072, -0.429, 1.289, 0, -0.005,
0, -0.104, -0.695, -0.797, 0.065, -1.289, -0.606, -0.004, 0,
0.113, -0.599, 0, -0.318, 0.072, 0.096, -1, 0.001, -0.001, 0,
-0.596, -0.659, -0.686, 0.065, -1.136, -0.091, -0.001, 0, -0.53,
-0.476, 0, 0.155, 0.14, 0.179, -1.289, -0.023, -0.001, 1, -0.226,
-0.623, -0.686, 0.123, -1.464, -0.249, 0, 1, -0.213, -0.507,
0, -0.464, -0.516, -0.48, 0, -0.008, 0, 0, 0, -0.96, -1, 0, 1,
0.47, 0.49, 0, 0.53, 0, -0.6, 0.227, -1, -0.895, 0, 0.181, 0,
0, 0, -0.908, -1, 0, 1.289, 1.289, 0.204, -1, 0.213, 0, -1, -0.84,
-1, 0.2, 0, -1, 0, 0, 0, -0.861, -0.861, 0, 1.136, 0.193, 0.047,
-1, -1, 0, -1, -0.817, 0.14, -1, 0, 0.127, 0, 0, 0, -0.797, -0.797,
0, -1, -1, -0.04, 1, 1, 0, 0, -0.215, 0.266, -0.23, 0, 0, 0,
0, 0, 0.922, 1, 0, 1, -0.221, 0.24, 0, 0.281, 0, -0.36, -0.051,
1, -0.801, 0, -0.033, 0, 0, 0, 0.825, 1, 0, 1.66, -1.66, 0.042,
-1, 0.045, 0, -1, -0.705, 1, -0.04, 0, -1, 0, 0, 0, 0.742, 0.742,
0, 1.292, -0.037, 0.002, -1, 1, 0, -1, -0.667, 0.02, -1, 0, -0.016,
0, 

Re: [R] Controlling Order of Panels in Lattice Trellis Plots

2013-02-22 Thread Bert Gunter
As you appear not to know, or at least have not stated, **what** you
want to do, how can you expect anyone to tell you **how** to do it?

Cheers,
Bert

On Fri, Feb 22, 2013 at 2:33 PM, Rich Shepard rshep...@appl-ecosys.com wrote:
 On Fri, 22 Feb 2013, Bert Gunter wrote:

 You do not need to use ordered factors.
 newfac - factor(oldfac, lev= ...) ## will do it. e.g.

 x - factor(letters[1:3]) ## default ordering is alphabetic (mod locale)
 x

 [1] a b c
 Levels: a b c

 y - factor(x,lev=letters[3:1])  ## reorder the levels
 y

 [1] a b c
 Levels: c b a


 Bert,

   Makes sense. I wonder if this will work when only a portion of the site
 IDs need to be explicitly ordered. There are 64 sites in all. Might be
 easier to sort the text file.

 Thanks again,

 Rich

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] assign index to colnames(matrix)

2013-02-22 Thread Jim Lemon

On 02/23/2013 11:34 AM, Prew, Paul wrote:

Hello,  I’m trying to follow the syntax of a script from a journal website.  
In order to create a regression formula used later in the script, the 
regression matrix must have column names “X1�, “X2�, etc.  I have tried 
to assign these column names to my matrix ScoutRSM.mat using a for loop, but I 
don’t know how to interpret the error message.  Suggestions?  Thanks, Paul



== instructions about dimnames(X)[[2]] = X1,X2,...  ===


function(binstr)
{
   # makes formula for regression
   # must make sure dimnames(X)[[2]] = X1,X2,...
   ind-which(binstr==1)
   rht- paste(X, ind, sep=, collapse=+)
   ans-paste(y ~ , rht)
   return(as.formula(ans))
}


###
##  my for loop  ##
###

for (i in 1:dim(ScoutRSM.mat)[2]  {
colnames(ScoutRSM.mat)[i]- paste(X, i, sep = “�))
}


for(i in 1:dim(ScoutRSM.mat)[2]) {

+   colnames(ScoutRSM.mat)[i]- paste(X,i, sep = )
+ }
Error in `colnames-`(`*tmp*`, value = X1) :
   length of 'dimnames' [2] not equal to array extent


Hi Paul,
You don't really need the loop, try:

colnames(ScoutRSM.mat)-paste(X,1:dim(ScoutRSM.mat)[2],sep=)

Jim

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


Re: [R] R on mac not installing packages

2013-02-22 Thread londonphd
Many thanks to all who replied to this post. the problem has now been sorted
out. i installed GCC-10.7-v2.pkg, now i can install packages from source 



--
View this message in context: 
http://r.789695.n4.nabble.com/R-on-mac-not-installing-packages-tp4659392p4659414.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 R CMD check --as-cran

2013-02-22 Thread Tao Wang
Hi Everyone!

This is my first time using R-help. I am trying to do R CMD check before 
uploading my package to CRAN.

R CMD check --as-cran my package folder.

However, it spits out this warning:

pdf is needed for checks on size reduction of PDFs

I searched online but found no clue to solve this problem. Can someone tell me 
what could be wrong with my package?

Thanks a lot!

Tao




UT Southwestern Medical Center
The future of medicine, today.

[[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] Climate Spatial plot

2013-02-22 Thread Bedassa Regassa
Dear Sir,

I am beginner in using R. I am working on climate and like to plot spatial
but I can't able to go ahead. I know it is too simply but not for me. Here
is attached the data and my sample script. I am waiting R-users to solve my
problem.  Your help is valuable for me. Thank you.


-- 
---
*Bedassa Regassa Cheneka*
*Adama Science and Technology Univesity*
*Natural Resource Management*
*P.O.BOX---193*
*Assela *
Ethiopia
-
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help with R CMD check --as-cran

2013-02-22 Thread Joshua Wiley
Hi Tao,

I wonder if you are on Windows?  If so, make sure you have qpdf
installed, and the location is in your path.

Cheers,

Josh

On Fri, Feb 22, 2013 at 3:32 PM, Tao Wang tao.w...@utsouthwestern.edu wrote:
 Hi Everyone!

 This is my first time using R-help. I am trying to do R CMD check before 
 uploading my package to CRAN.

 R CMD check --as-cran my package folder.

 However, it spits out this warning:

 pdf is needed for checks on size reduction of PDFs

 I searched online but found no clue to solve this problem. Can someone tell 
 me what could be wrong with my package?

 Thanks a lot!

 Tao


 

 UT Southwestern Medical Center
 The future of medicine, today.

 [[alternative HTML version deleted]]

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



--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/

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


Re: [R] help with R CMD check --as-cran

2013-02-22 Thread David Winsemius

On Feb 22, 2013, at 5:52 PM, Joshua Wiley wrote:

 Hi Tao,
 
 I wonder if you are on Windows?  If so, make sure you have qpdf
 installed, and the location is in your path.
 
 Cheers,
 
 Josh
 
 On Fri, Feb 22, 2013 at 3:32 PM, Tao Wang tao.w...@utsouthwestern.edu wrote:
 Hi Everyone!
 
 This is my first time using R-help. I am trying to do R CMD check before 
 uploading my package to CRAN.
 
 R CMD check --as-cran my package folder.
 
 However, it spits out this warning:
 
 pdf is needed for checks on size reduction of PDFs
 
 I searched online but found no clue to solve this problem. Can someone tell 
 me what could be wrong with my package?


I believe this was crossposted to StackOverflow where the questioner has later 
reported figuring out that warning was inaccurate but harmless.

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


[R] Issue with matrices within nested for-loops

2013-02-22 Thread Jonathan Richar
Greetings!

I am trying to compare simulated environmental conditions from a model
against a recruitment time series for a species of crab by first dropping 5
data points, and then using the remainder to attempt to simulate the
missing data as a measure of best fit and using the following code:


all.mat-as.matrix(comb,ncol=ncol(comb),nrow=nrow(comb))
obs-as.matrix(R2,24,1)
mod-all.mat

results-numeric(ncol(mod))


for(i in mod) {
x-mod[,i]
resid - matrix(NA, 1000, 5)
for(k in 1:1000) {
sub-sample(1:24,19)
fit-lm(obs~x,subset=sub)
cf-coef(fit)
p - cf[1] + cf[2] * x[-sub]
resid[k,] - obs[-sub] - p
}
results[i] - mean(resid^2)
}


where* R2* is a 24x1 matrix with recruitment data, *comb* was a cbind()
object combining two matrices and *all.mat* is the final 565x24 matrix of
modeled environmental scenarios. When the script is run the first 99
scenarios are processed properly and I get readable output. At scenario 100
however, I get this message:

*Error in na.omit.data.frame(list(obs = c(0.414153096303487,
1.39649463342491,  : subscript out of bounds*

Which I understand to mean that the bounds of the indicated vector/matrix
have been violated. I am however at a loss as to how to resolve this. Any
advice would be appreciated

Cheers!

JR

-- 

Jonathan Richar
Doctoral candidate
UAF SFOS Fisheries Division
17101 Pt. Lena Loop Rd.
University of Alaska Fairbanks
Juneau, AK 99801
Phone: (907) 796-5459

[[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] assign index to colnames(matrix)

2013-02-22 Thread Prew, Paul
Jim, thank you, that worked great.

Paul Prew  |  Statistician
651-795-5942   |   fax 651-204-7504 
Ecolab Research Center  | Mail Stop ESC-F4412-A 
655 Lone Oak Drive  |  Eagan, MN 55121-1560 

-Original Message-
From: Jim Lemon [mailto:j...@bitwrit.com.au] 
Sent: Friday, February 22, 2013 7:22 PM
To: Prew, Paul
Cc: r-help@r-project.org
Subject: Re: [R] assign index to colnames(matrix)

On 02/23/2013 11:34 AM, Prew, Paul wrote:
 Hello,  I’m trying to follow the syntax of a script from a journal 
 website.  In order to create a regression formula used later in the 
 script, the regression matrix must have column names “X1”, 
 “X2”, etc.  I have tried to assign these column names to my matrix 
 ScoutRSM.mat using a for loop, but I don’t know how to interpret the 
 error message.  Suggestions?  Thanks, Paul


 
 == instructions about dimnames(X)[[2]] = X1,X2,...  === 
 

 function(binstr)
 {
# makes formula for regression
# must make sure dimnames(X)[[2]] = X1,X2,...
ind-which(binstr==1)
rht- paste(X, ind, sep=, collapse=+)
ans-paste(y ~ , rht)
return(as.formula(ans))
 }


 ###
 ##  my for loop  ## 
 ###

 for (i in 1:dim(ScoutRSM.mat)[2]  {
 colnames(ScoutRSM.mat)[i]- paste(X, i, sep = “”)) }

 for(i in 1:dim(ScoutRSM.mat)[2]) {
 +   colnames(ScoutRSM.mat)[i]- paste(X,i, sep = ) }
 Error in `colnames-`(`*tmp*`, value = X1) :
length of 'dimnames' [2] not equal to array extent

Hi Paul,
You don't really need the loop, try:

colnames(ScoutRSM.mat)-paste(X,1:dim(ScoutRSM.mat)[2],sep=)

Jim

CONFIDENTIALITY NOTICE: 
This e-mail communication and any attachments may contain proprietary and 
privileged information for the use of the designated recipients named above. 
Any unauthorized review, use, disclosure or distribution is prohibited. 
If you are not the intended recipient, please contact the sender by reply 
e-mail and destroy all copies of the original message.

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

2013-02-22 Thread John
Petr,

Another program that may be useful is ImageJ which has a great many
useful analytic plugins.  The program is written in Java and it
supports a good many different image file formats.  You should also be
able to use Octave to normalize an image.

JWDougherty

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


Re: [R] Issue with matrices within nested for-loops

2013-02-22 Thread Bert Gunter
 Which I understand to mean that the bounds of the indicated vector/matrix
 have been violated. I am however at a loss as to how to resolve this

... Presumably because you haven't learned to use R's debugging tools.
So time to learn. See the debugging Chapter of the R Language Manual
and the Help files of the referenced functions. Also ?recover and set
the error option as described there so you can browse in the frame in
which the error was triggered. Also check ?traceback

Someone (but not me!) may have the patience to go thru your code and
pick out the error(s); but if you write code, you need to learn how to
debug code for yourself instead of posting to the list every time.
Consider it part of your doctoral training.

Cheers,
Bert



 Jonathan Richar
 Doctoral candidate
 UAF SFOS Fisheries Division
 17101 Pt. Lena Loop Rd.
 University of Alaska Fairbanks
 Juneau, AK 99801
 Phone: (907) 796-5459

 [[alternative HTML version deleted]]

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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

2013-02-22 Thread philippe massicotte
Dear R users. 

I'm new with layout and I can't figure how to teak my graphs. 

I have the following code: 

layout(matrix(c(1,2,3), 3, 1, byrow = TRUE), heights=c(0.3,0.3,0.6)) 
boxplot(rnorm(100), horizontal=TRUE, axes=FALSE) 
boxplot(rnorm(100), horizontal=TRUE, axes=FALSE) 
hist(rnorm(100)) 


Is it possible to have the two horizontal boxplot closer to each other? 

With regards, 
Phil


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