[R] help with stepAIC and boot

2014-03-05 Thread Luca Braglia
Hello everybody.

I've a problem with stepAIC inside a boot function (i'm trying to do
bootstrap backward elimination, with a statistic function that allow one
to specify the formula of a coxph model)

For the moment the function would be aimed storing selected vars

However I've a problem in the stepAIC code (coxph seems to me to be
estimated)...the error message is

Error in terms.formula(formula, special, data = data) :
  object 'db' not found

aka stepAIC doesn't find bootstrap sample data

How can i fix it?

Many thanks in advance

-

library(boot)
library(MASS)
library(survival)

hn -
structure(list(pfs.time = c(309, 519, 318, 1114, 671, 1539, 1110,
1798, 2213, 1802, 1170, 1259, 189, 1939, 361, 1311, 1537, 706,
1934, 595, 173, 1147, 389, 854, 744, 172, 1530, 1993, 341, 1468,
540, 562, 1079, 1747, 1920, 1018, 899, 591, 1722, 400, 1099,
755, 1679, 1049, 1261, 408, 1695, 788, 324, 505, 505, 1159, 691,
924, 443, 781, 504, 1031, 205, 115, 506, 642, 637, 1426, 404,
944, 651, 863, 1758, 859, 502, 1899, 1746, 1517, 1087, 160, 1803,
706, 122, 996, 869, 611, 2484, 2438, 1095, 114, 574, 830, 2236,
616, 180, 398, 879, 281, 761, 764, 594, 874, 886, 1959, 1424,
239, 1650, 1689, 310, 1865, 2159, 1459, 980, 379, 1668, 394,
787, 1326, 1931, 2435, 356, 708, 1019, 100, 289), pfs.dummy = c(1,
0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0,
0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0,
1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1), varA = c(12.8,
19, 15.4, 21.3, 18.6, 11.4, 0, 14.6, 7.9, 5.5, 23.5, 17.1, 13.2,
13.2, 30, 11, 12.8, 30.5, 13.6, 10.1, 13.5, 23.6, 11.1, 20.8,
6.1, 7, 13.3, 11.3, 13.9, 12, 8.3, 11.9, 5.2, 6.7, 28.4, 5.8,
22.5, 12.1, 12.4, 8.8, 20.2, 34.2, 5.1, 16, 24.7, 16.9, 0, 8.1,
0, 17.6, 6.5, 16.5, 22.6, 18.3, 12.1, 16.2, 14.9, 21.3, 15.9,
2.9, 9.9, 13.3, 0, 12.8, 19.9, 17.6, 21.8, 15.9, 20.5, 13.4,
14.1, 13, 5.4, 16.3, 18.7, 13, 21, 3.7, 23.6, 17.1, 6.1, 7.4,
0, 14.9, 11.5, 29.8, 8.8, 14, 13.1, 5.5, 16.4, 11.4, 6.3, 18.1,
11.9, 14.2, 25.8, 9.6, 5.3, 22.1, 12.5, 25.6, 17.5, 7.2, 5.7,
12.8, 11.6, 22.7, 17.4, 23.7, 6.7, 10.3, 13.6, 5, 16.4, 16.1,
20.5, 15.6, 6.7, 20, 14.7), varB = c(3.3, 4.13, 14.25, 5.2,
13.25, 5, 0, 19.1, 7.2, 24.2, 12.6, 11.1, 21.32, 13.6, 36.9,
9.98, 8.51, 9.4, 8.12, 3, 31.25, 10.3, 13.1, 9.4, 6.94, 10.9,
8.6, 6.2, 27, 2.5, 12.6, 17.2, 13.2, 4.6, 17.6, 3.3, 6.7, 4.9,
12.5, 5.4, 3.9, 11.7, 0.6, 26.3, 23.9, 15.9, 0, 13.1, 0, 4.45,
5.2, 18.8, 7.73, 12.4, 4.2, 2.71, 3.4, 8.5, 15.6, 18.4, 6.72,
31.15, 0, 8.1, 25.7, 5.8, 48.7, 7.43, 6.1, 9.4, 3.9, 15.1, 5.2,
7.2, 6.8, 7.4, 2.5, 6.16, 32.9, 6.5, 15.5, 3.96, 0, 4.2, 4.94,
14.7, 7.4, 8.6, 7.2, 20.5, 5.6, 8.75, 5.6, 10.2, 2.7, 7.4, 9.9,
6.14, 2.2, 36, 2.4, 4.6, 5.9, 4.9, 21.9, 9.1, 2.5, 33.2, 11.4,
5, 2.2, 2.3, 14.9, 6, 13.9, 4.7, 30.44, 3.4, 10.7, 7, 7.9), varC = c(24.6,
48.5, 135.1, 67.9, 156, 34.3, 0, 14.6, 33.2, 75.6, 192.8, 118.4,
174.1, 113.5, 699.4, 63.1, 68, 175.1, 66.3, 17.1, 265.6, 162.1,
87.1, 122.5, 23.3, 40.8, 65.1, 46, 241.6, 17.1, 64.5, 123.9,
37.9, 17.7, 284.1, 10.3, 95.3, 42.6, 92.2, 26.8, 45.2, 238.3,
2.3, 261, 380.4, 147.4, 0, 57, 0, 45.6, 19.1, 186.8, 107.9, 143.3,
27.9, 27.8, 30.1, 110.1, 161.3, 32.2, 42, 249, 0, 54.7, 313.1,
63.8, 656, 80, 81.5, 78.4, 31.4, 110.3, 14.9, 76.1, 78.5, 59.8,
31.7, 12.1, 457.9, 62.5, 49.5, 16, 0, 37, 345, 255, 35.9, 72,
54.5, 61.8, 55.9, 57.2, 18.4, 104.2, 18.2, 66.1, 156.1, 35.4,
7.2, 523.8, 17.7, 68.4, 52.8, 19.7, 74.6, 72.5, 19.2, 498.7,
121.7, 78.4, 10.8, 14, 133.2, 17.3, 133.9, 43.8, 375.2, 32.9,
44.3, 86.5, 63.8), varD = c(4.3, 10.3, 4.7, 5.4, 6.7, 2.7,
7, 9.2, 17.7, 0, 4.6, 0, 12.1, 5.5, 0, 3.4, 7, 7.2, 10.8, 8.3,
13.7, 19.6, 0, 11.8, 0, 7.5, 0, 0, 3.2, 0, 6.2, 9.6, 0, 4, 5.1,
0, 18.8, 16.1, 6.4, 0, 12.2, 15.8, 10.1, 13.9, 0, 11.7, 15.5,
0, 13.1, 11, 0, 0, 32.7, 6.3, 5.9, 0, 0, 12.8, 0, 0, 3.8, 7.3,
3.7, 18.1, 15.6, 14.9, 21.4, 13, 0, 8.1, 9.6, 8.1, 0, 13.1, 12.1,
10.7, 8.5, 2.9, 0, 15.4, 0, 3.3, 4.8, 0, 7.5, 38.9, 3.6, 6.7,
5.7, 4.4, 18.9, 11.5, 0, 15.2, 0, 8.5, 0, 6.4, 0, 17.6, 0, 26.7,
4.6, 4.4, 0, 5.9, 9.2, 20.2, 0, 0, 10.1, 7, 11.3, 0, 4.4, 10.2,
11.2, 0, 0, 0, 4), varE = c(1.9, 3.55, 1.96, 3.1, 1.5, 0, 8.3,
0.7, 4.3, 0, 2.1, 0, 11.69, 2, 0, 2.5, 4.4, 0.8, 0.8, 9.4, 19.19,
14.2, 0, 2.3, 0, 6.7, 0, 0, 1.7, 0, 1.6, 8.3, 0, 20.6, 1.8, 0,
12.5, 15.1, 1.6, 0, 1.6, 2, 25.3, 4.2, 0, 6.55, 16.7, 0, 8.7,
4.84, 0, 0, 16.72, 8.4, 1.5, 0, 0, 3.8, 0, 0, 3.89, 1.5, 4, 15.65,
4.3, 2.5, 10.9, 3.23, 0, 2.9, 7.7, 8.3, 0, 15.6, 5.2, 3.9, 1.6,
3.52, 0, 5.4, 0, 4.3, 2.7, 0, 8, 5.1, 0.9, 2.35, 0.6, 14.2, 10.7,
8.7, 0, 10.9, 0, 2.3, 0, 1.8, 0, 8.7, 0, 16.2, 0.1, 2.8, 0, 0.2,
8.3, 7.3, 0, 0, 10.3, 0.6, 7.1, 0, 5.3, 8.2, 0.83, 0, 0, 0, 1.8
), varF = c(4.5, 21.4, 5.1, 9.4, 6.1, 0, 33.6, 5.2, 47.4, 0,
7.1, 0, 

Re: [R] Building R for better performance

2014-03-05 Thread Simon Zehnder
Jonathan,

I myself tried something like this - comparing gcc, clang and intel on a Mac. 
From my experiences in HPC on the university cluster (where we also use the 
Xeon Phi, Landeshochleistungscluster University RWTH Aachen), the Intel 
compiler has better code optimization in regard to vectorisation, etc. (clang 
is up to now suffering from a not yet implemented OpenMP library).

Here is a revolutionanalytics article about this topic: 
http://blog.revolutionanalytics.com/2010/06/performance-benefits-of-multithreaded-r.html

As I usually use the Rcpp package for C++ extensions this could give me further 
performance. Though, I already failed when trying to compile R with the Intel 
compiler and linking against the MKL (see my topic in the Intel developer zone: 
http://software.intel.com/en-us/comment/1767418 and my threads on the R-User 
list: https://stat.ethz.ch/pipermail/r-sig-mac/2013-November/010472.html). 

So, to your questions:

1) I think that most admins do not even use the Intel compiler to compile R - 
this seems to me rare. There are some people I know they do and I think they 
could be aware of it - but these are only a few. As R is growing in usage and I 
do know from regional user meetings that very large companies start using it in 
their BI units - this should be of interest.

2) I would really welcome this step because compilation with intel (especially 
on a Mac) and linking to the MKL seems to be delicate. 

I am interested in the data - so if it is possible send it via the list or 
directly to my account. Further, could you show some code that you used for the 
computations? 


Best

Simon


On 04 Mar 2014, at 22:44, Anspach, Jonathan P jonathan.p.ansp...@intel.com 
wrote:

 Greetings,
 
 I'm a software engineer with Intel.  Recently I've been investigating R 
 performance on Intel Xeon and Xeon Phi processors and RH Linux.  I've also 
 compared the performance of R built with the Intel compilers and Intel Math 
 Kernel Library to a default build (no config options) that uses the GNU 
 compilers.  To my dismay, I've found that the GNU build always runs on a 
 single CPU core, even during matrix operations.  The Intel build runs matrix 
 operations on multiple cores, so it is much faster on those operations.  
 Running the benchmark-2.5 on a 24 core Xeon system, the Intel build is 13x 
 faster than the GNU build (21 seconds vs 275 seconds).  Unfortunately, this 
 advantage is not documented anywhere that I can see.
 
 Building with the Intel tools is very easy.  Assuming the tools are installed 
 in /opt/intel/composerxe, the process is simply (in bash shell):
 
 $ . /opt/intel/composerxe/bin/compilervars.sh intel64
 $ ./configure --with-blas=-L/opt/intel/composerxe/mkl/lib/intel64 
 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm 
 --with-lapack CC=icc CFLAGS=-O2 CXX=icpc CXXFLAGS=-O2 F77=ifort FFLAGS=-O2 
 FC=ifort FCFLAGS=-O2
 $ make
 $ make check
 
 My questions are:
 1) Do most system admins and/or R installers know about this performance 
 difference, and use the Intel tools to build R?
 2) Can we add information on the advantage of building with the Intel tools, 
 and how to do it, to the installation instructions and FAQ?
 
 I can post my data if anyone is interested.
 
 Thanks,
 Jonathan Anspach
 Sr. Software Engineer
 Intel Corp.
 jonathan.p.ansp...@intel.com
 713-751-9460
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Having a plot with points and line with different colors

2014-03-05 Thread Baro
Hi experts

I want to have a plot, which consist of line and points something like this:

plot(data, type=o)

but I would like that lines and point have different colors. for example
line should be blue and points should be black

how can I do that in R?

[[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] Having a plot with points and line with different colors

2014-03-05 Thread Jim Lemon

On 03/05/2014 08:59 PM, Baro wrote:

Hi experts

I want to have a plot, which consist of line and points something like this:

plot(data, type=o)

but I would like that lines and point have different colors. for example
line should be blue and points should be black

how can I do that in R?


Hi Baro,
There are a few ways to do this, here are two. Probably the easiest is 
to plot the lines, then add the symbols with points, allowing the line 
to have one color and the point another.


You can overplot the o type of plot with points of a different color, 
but this occasionally leads to color bleed on the points if the 
overplotting is not exact.


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] Having a plot with points and line with different colors

2014-03-05 Thread Baro
thanks Jim,

could you please show me some example?


On Wed, Mar 5, 2014 at 2:02 AM, Jim Lemon j...@bitwrit.com.au wrote:

 On 03/05/2014 08:59 PM, Baro wrote:

 Hi experts

 I want to have a plot, which consist of line and points something like
 this:

 plot(data, type=o)

 but I would like that lines and point have different colors. for example
 line should be blue and points should be black

 how can I do that in R?

  Hi Baro,
 There are a few ways to do this, here are two. Probably the easiest is to
 plot the lines, then add the symbols with points, allowing the line to
 have one color and the point another.

 You can overplot the o type of plot with points of a different color,
 but this occasionally leads to color bleed on the points if the
 overplotting is not exact.

 Jim


[[alternative HTML version deleted]]

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


Re: [R] Having a plot with points and line with different colors

2014-03-05 Thread Jim Lemon

On 03/05/2014 09:09 PM, Baro wrote:

thanks Jim,

could you please show me some example?



# plot lines, then points
plot(1:5,type=l,col=blue)
points(1:5,col=black)
# plot both, then overplot points
plot(1:5,type=o,col=blue)
points(1:5,col=black)

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] Is this a mistake in 'An Introduction to R'?

2014-03-05 Thread peter dalgaard

On 04 Mar 2014, at 21:21 , Geoff Loveman ge...@lovemans.co.uk wrote:

 
 
 In 'An Introduction to R', section 11.7 on nonlinear least squares fitting,
 the following example is given for obtaining the standard errors of the
 estimated parameters:
 
 To obtain the approximate standard errors (SE) of the estimates we do:
 sqrt(diag(2*out$minimum/(length(y) - 2) * solve(out$hessian)))The 2 in the
 line above represents the number of parameters.
 
 I know the inverted Hessian is multiplied by the mean square error and that
 the denominator of the MSE is the degrees of freedom (number of samples -
 number of parameters) but why does the numerator of the MSE (which is the
 RSS) get multiplied by the number of parameters? I have read through
 explanations of the method for obtaining the SE but I don't see where the
 MSE gets multiplied by the number of parameters or why this is needed as
 shown in the example?
 


There are two 2's in that line, and I'd expect that only the last one has to do 
with the number of parameters, and the other one has to do with whether the 
Hessian is the second derivative of the sum of squares or of the negative 
loglikelihood function (half the sum of squares).

Quick check: In a linear model, we have

ssd = || Y- X beta ||^2
gradient = -2 (Y - X beta )'X
Hessian H = 2 X'X

and as we know, V(beta) = sigma^2 (X'X)^-1 = 2 sigma^2 H^-1

-pd

 Thanks for any help!
 
 Geoff Loveman
 Tech lead SMERAS
 QQ Maritime Life Support
 
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Is-this-a-mistake-in-An-Introduction-to-R-tp4686217.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.

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


[R] Sweave: cat() in a chunk with option results=tex doesn't producelinebreaks at the end of a character string anymore

2014-03-05 Thread Gerrit Eichner

Hello, everyone,

I am struggling with an Sweave-problem that didn't occur sofar (and I have 
no clue what I might have changed in my system; see below). The following 
example *.Rnw file's only task is (for simplicity) to output text with a 
little bit of TeX-code with linebreaks (e. g., to be better readable):



\documentclass{article}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\

echo=FALSE, results=tex=
cat( Text 2 (through cat()) with a respected newline here\n,
 and likewise two tabs here\t\t followed by two double-backslashes ,
 and IGNORED newline escape characters at the end. \n \n,
 sep = )

cat( Text 3 (through cat()) just to finish this example and ,
 with also IGNORED newline escapes at its end. \n \n, sep = )
@
\end{document}



When processed by Sweave I obtain the following TeX file:


\documentclass{article}
\usepackage{Sweave}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\

Text 2 (through cat()) with a respected newline here
and likewise two tabs here		 followed by two 
double-backslashes and IGNORED newline escape characters at the end.\\ 
Text 3 (through cat()) to finish this example and with also IGNORED 
newline escapes at its end. \end{document}



the point being that the linebreaks (\n) at the ends of the output 
character strings have been completely ignored.


I wasn't successful in searching the archive, RSeek, SE and the like. Any 
idea where and how to continue to search, or what to do to get back 
Sweave's old behavior (except for reinstalling R ... which of course is 
still an option)? Thanks for any hint!


 Best regards  --  Gerrit

PS:

sessionInfo()

R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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

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

other attached packages:
[1] fortunes_1.5-2

loaded via a namespace (and not attached):
[1] grid_3.0.2  lattice_0.20-27 tools_3.0.2



-
Dr. Gerrit Eichner   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner

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


Re: [R] Sweave: cat() in a chunk with option results=tex doesn't producelinebreaks at the end of a character string anymore

2014-03-05 Thread Duncan Murdoch

On 05/03/2014 7:32 AM, Gerrit Eichner wrote:

Hello, everyone,

I am struggling with an Sweave-problem that didn't occur sofar (and I have
no clue what I might have changed in my system; see below). The following
example *.Rnw file's only task is (for simplicity) to output text with a
little bit of TeX-code with linebreaks (e. g., to be better readable):


\documentclass{article}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\

echo=FALSE, results=tex=
cat( Text 2 (through cat()) with a respected newline here\n,
   and likewise two tabs here\t\t followed by two double-backslashes ,
   and IGNORED newline escape characters at the end. \n \n,
   sep = )

cat( Text 3 (through cat()) just to finish this example and ,
   with also IGNORED newline escapes at its end. \n \n, sep = )
@
\end{document}



When processed by Sweave I obtain the following TeX file:


\documentclass{article}
\usepackage{Sweave}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\

Text 2 (through cat()) with a respected newline here
and likewise two tabs here   followed by two
double-backslashes and IGNORED newline escape characters at the end.\\
Text 3 (through cat()) to finish this example and with also IGNORED
newline escapes at its end. \end{document}


the point being that the linebreaks (\n) at the ends of the output
character strings have been completely ignored.


See the strip.white option in ?RweaveLatex.

Duncan Murdoch



I wasn't successful in searching the archive, RSeek, SE and the like. Any
idea where and how to continue to search, or what to do to get back
Sweave's old behavior (except for reinstalling R ... which of course is
still an option)? Thanks for any hint!

   Best regards  --  Gerrit

PS:
 sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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

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

other attached packages:
[1] fortunes_1.5-2

loaded via a namespace (and not attached):
[1] grid_3.0.2  lattice_0.20-27 tools_3.0.2



-
Dr. Gerrit Eichner   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner

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

2014-03-05 Thread Thomas
I have a matrix where each entry represents a data subject's type, 1  
or 0:


n - 10
ntype - rbinom(n, 1, 0.5)

and I'd like to sample say 3 subjects from ntype where those subjects  
who are Type 1 are selected with probability say 0.75, and Type 0 with  
(1-0.75). (So the sample would produce a list with three indices each  
referring to a position within ntype.)


Can anyone suggest a way to do this please?

Thank you,

Thomas Chesney
This message and any attachment are intended solely for the addressee and may 
contain confidential information. If you have received this message in error, 
please send it back to me, and immediately delete it.   Please do not use, copy 
or disclose the information contained in this message or in any attachment.  
Any views or opinions expressed by the author of this email do not necessarily 
reflect the views of the University of Nottingham.

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

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


Re: [R] Sweave: cat() in a chunk with option results=texdoesn'tproducelinebreaks at the end of a character string anymore

2014-03-05 Thread Gerrit Eichner

Thanks, Duncan,

but, sorry, including

\SweaveOpts{strip.white=true}

doesn't help. Have tried that before and forgot to mention; sorry!

BTW: using \SweaveOpts{strip.white=true}, i.e., with quotation marks as 
requested in RweaveLatex()'s help file, throws out


Error in match.arg(options$strip.white, c(true, false, all)) :
  'arg' should be one of true, false, all

which used to happen before (on my system) so that I used to use it w/o 
quotes successfully. (!?)



Still big question marks ... Any further ideas?

 Regards -- Gerrit


On Wed, 5 Mar 2014, Duncan Murdoch wrote:


On 05/03/2014 7:32 AM, Gerrit Eichner wrote:

Hello, everyone,

I am struggling with an Sweave-problem that didn't occur sofar (and I have
no clue what I might have changed in my system; see below). The following
example *.Rnw file's only task is (for simplicity) to output text with a
little bit of TeX-code with linebreaks (e. g., to be better readable):


\documentclass{article}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\

echo=FALSE, results=tex=
cat( Text 2 (through cat()) with a respected newline here\n,
   and likewise two tabs here\t\t followed by two double-backslashes 
,

   and IGNORED newline escape characters at the end. \n \n,
   sep = )

cat( Text 3 (through cat()) just to finish this example and ,
   with also IGNORED newline escapes at its end. \n \n, sep = )
@
\end{document}



When processed by Sweave I obtain the following TeX file:


\documentclass{article}
\usepackage{Sweave}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\

Text 2 (through cat()) with a respected newline here
and likewise two tabs here   followed by two
double-backslashes and IGNORED newline escape characters at the end.\\
Text 3 (through cat()) to finish this example and with also IGNORED
newline escapes at its end. \end{document}


the point being that the linebreaks (\n) at the ends of the output
character strings have been completely ignored.


See the strip.white option in ?RweaveLatex.

Duncan Murdoch



I wasn't successful in searching the archive, RSeek, SE and the like. Any
idea where and how to continue to search, or what to do to get back
Sweave's old behavior (except for reinstalling R ... which of course is
still an option)? Thanks for any hint!

   Best regards  --  Gerrit

PS:
 sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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

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

other attached packages:
[1] fortunes_1.5-2

loaded via a namespace (and not attached):
[1] grid_3.0.2  lattice_0.20-27 tools_3.0.2



-
Dr. Gerrit Eichner   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sweave: cat() in a chunk with option results=texdoesn'tproducelinebreaks at the end of a character string anymore

2014-03-05 Thread Duncan Murdoch

On 05/03/2014 9:29 AM, Gerrit Eichner wrote:

Thanks, Duncan,

but, sorry, including

\SweaveOpts{strip.white=true}

doesn't help. Have tried that before and forgot to mention; sorry!


true is the default.  You want false.

Duncan Murdoch



BTW: using \SweaveOpts{strip.white=true}, i.e., with quotation marks as
requested in RweaveLatex()'s help file, throws out

Error in match.arg(options$strip.white, c(true, false, all)) :
'arg' should be one of true, false, all

which used to happen before (on my system) so that I used to use it w/o
quotes successfully. (!?)


Still big question marks ... Any further ideas?

   Regards -- Gerrit


On Wed, 5 Mar 2014, Duncan Murdoch wrote:

 On 05/03/2014 7:32 AM, Gerrit Eichner wrote:
 Hello, everyone,

 I am struggling with an Sweave-problem that didn't occur sofar (and I have
 no clue what I might have changed in my system; see below). The following
 example *.Rnw file's only task is (for simplicity) to output text with a
 little bit of TeX-code with linebreaks (e. g., to be better readable):


 \documentclass{article}
 \begin{document}
 Text 1 (not through cat()) followed by a double-backslash and
 a blank line, i.e., a linebreak.\\

 echo=FALSE, results=tex=
 cat( Text 2 (through cat()) with a respected newline here\n,
and likewise two tabs here\t\t followed by two double-backslashes
 ,
and IGNORED newline escape characters at the end. \n \n,
sep = )

 cat( Text 3 (through cat()) just to finish this example and ,
with also IGNORED newline escapes at its end. \n \n, sep = )
 @
 \end{document}



 When processed by Sweave I obtain the following TeX file:


 \documentclass{article}
 \usepackage{Sweave}
 \begin{document}
 Text 1 (not through cat()) followed by a double-backslash and
 a blank line, i.e., a linebreak.\\

 Text 2 (through cat()) with a respected newline here
 and likewise two tabs here  followed by two
 double-backslashes and IGNORED newline escape characters at the end.\\
 Text 3 (through cat()) to finish this example and with also IGNORED
 newline escapes at its end. \end{document}


 the point being that the linebreaks (\n) at the ends of the output
 character strings have been completely ignored.

 See the strip.white option in ?RweaveLatex.

 Duncan Murdoch


 I wasn't successful in searching the archive, RSeek, SE and the like. Any
 idea where and how to continue to search, or what to do to get back
 Sweave's old behavior (except for reinstalling R ... which of course is
 still an option)? Thanks for any hint!

Best regards  --  Gerrit

 PS:
  sessionInfo()
 R version 3.0.2 (2013-09-25)
 Platform: x86_64-w64-mingw32/x64 (64-bit)

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

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

 other attached packages:
 [1] fortunes_1.5-2

 loaded via a namespace (and not attached):
 [1] grid_3.0.2  lattice_0.20-27 tools_3.0.2



 -
 Dr. Gerrit Eichner   Mathematical Institute, Room 212
 gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
 Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
 Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner

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

2014-03-05 Thread Suzen, Mehmet
If I understood correctly, you need weighted sampling. Try 'prob'
argument from 'sample'.  For your example:

n - 10
ntype - rbinom(n, 1, 0.5)
myProbs - rep(1/10, 10) # equally likely
myProbs[ which(ntype == 0)] - 0.75/7 # Divide so the sum will be 1.0
myProbs[ which(ntype == 1)] - 0.25/3
sample(ntype,3, prob=myProbs)




On 5 March 2014 15:20, Thomas thomas.ches...@nottingham.ac.uk wrote:
 I have a matrix where each entry represents a data subject's type, 1 or 0:

 n - 10
 ntype - rbinom(n, 1, 0.5)

 and I'd like to sample say 3 subjects from ntype where those subjects who
 are Type 1 are selected with probability say 0.75, and Type 0 with (1-0.75).
 (So the sample would produce a list with three indices each referring to a
 position within ntype.)

 Can anyone suggest a way to do this please?

 Thank you,

 Thomas Chesney
 This message and any attachment are intended solely for the addressee and
 may contain confidential information. If you have received this message in
 error, please send it back to me, and immediately delete it.   Please do not
 use, copy or disclose the information contained in this message or in any
 attachment.  Any views or opinions expressed by the author of this email do
 not necessarily reflect the views of the University of Nottingham.

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

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

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


Re: [R] Sampling according to type

2014-03-05 Thread Suzen, Mehmet
 myProbs[ which(ntype == 0)] - 0.75/7 # Divide so the sum will be 1.0
 myProbs[ which(ntype == 1)] - 0.25/3

Here of course you need to divide by number of 0s and 1s,  7 and 3
were was just an example.

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


Re: [R] Having a plot with points and line with different colors

2014-03-05 Thread David Carlson
Alternatively use type=c instead of l which will create line
breaks where the points will go.

plot(1:5,type=c, col=blue)
points(1:5,col=black)

David

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon
Sent: Wednesday, March 5, 2014 4:08 AM
To: Baro
Cc: R help
Subject: Re: [R] Having a plot with points and line with
different colors

On 03/05/2014 09:09 PM, Baro wrote:
 thanks Jim,

 could you please show me some example?


# plot lines, then points
plot(1:5,type=l,col=blue)
points(1:5,col=black)
# plot both, then overplot points
plot(1:5,type=o,col=blue)
points(1:5,col=black)

Jim

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

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


Re: [R] Sweave: cat() in a chunk with option results=texdoesn'tproducelinebreaksatthe end of a character string anymore

2014-03-05 Thread Gerrit Eichner

Thanks, Duncan,

I got it! I missread/-understood strip.white's meaning and thought it 
would refer only to blank lines within real code chunks (i.e., to those 
between \begin{Schunk} and \end{Schunk}), but not to the (TeX-)output 
which was generated by code chunks with results=tex.


My goal: I don't want blank lines at the beginning or end of real R 
output between \begin{Schunk} and \end{Schunk}), but want to be able to 
create linebreaks using cat( \n) explicitly in chunks with results=tex


The solution appears to be: use strip.white=false locally in case of 
need, i.e., as the option for the respective code chunks (which also have 
results=tex, and from which I want only linebreaks in the TeX-output).


Actually, embarrassingly simple.

 Thanks again -- Gerrit


On Wed, 5 Mar 2014, Duncan Murdoch wrote:


On 05/03/2014 9:29 AM, Gerrit Eichner wrote:

Thanks, Duncan,

but, sorry, including

\SweaveOpts{strip.white=true}

doesn't help. Have tried that before and forgot to mention; sorry!


true is the default.  You want false.

Duncan Murdoch



BTW: using \SweaveOpts{strip.white=true}, i.e., with quotation marks as
requested in RweaveLatex()'s help file, throws out

Error in match.arg(options$strip.white, c(true, false, all)) :
'arg' should be one of true, false, all

which used to happen before (on my system) so that I used to use it w/o
quotes successfully. (!?)


Still big question marks ... Any further ideas?

   Regards -- Gerrit


On Wed, 5 Mar 2014, Duncan Murdoch wrote:

 On 05/03/2014 7:32 AM, Gerrit Eichner wrote:
 Hello, everyone,

 I am struggling with an Sweave-problem that didn't occur sofar (and I 
have
 no clue what I might have changed in my system; see below). The 
following

 example *.Rnw file's only task is (for simplicity) to output text with a
 little bit of TeX-code with linebreaks (e. g., to be better readable):


 \documentclass{article}
 \begin{document}
 Text 1 (not through cat()) followed by a double-backslash and
 a blank line, i.e., a linebreak.\\

 echo=FALSE, results=tex=
 cat( Text 2 (through cat()) with a respected newline here\n,
and likewise two tabs here\t\t followed by two 
double-backslashes

 ,
and IGNORED newline escape characters at the end. \n \n,
sep = )

 cat( Text 3 (through cat()) just to finish this example and ,
with also IGNORED newline escapes at its end. \n \n, sep = )
 @
 \end{document}



 When processed by Sweave I obtain the following TeX file:


 \documentclass{article}
 \usepackage{Sweave}
 \begin{document}
 Text 1 (not through cat()) followed by a double-backslash and
 a blank line, i.e., a linebreak.\\

 Text 2 (through cat()) with a respected newline here
 and likewise two tabs here  followed by two
 double-backslashes and IGNORED newline escape characters at the end.\\
 Text 3 (through cat()) to finish this example and with also IGNORED
 newline escapes at its end. \end{document}


 the point being that the linebreaks (\n) at the ends of the output
 character strings have been completely ignored.

 See the strip.white option in ?RweaveLatex.

 Duncan Murdoch


 I wasn't successful in searching the archive, RSeek, SE and the like. 
Any

 idea where and how to continue to search, or what to do to get back
 Sweave's old behavior (except for reinstalling R ... which of course 
is

 still an option)? Thanks for any hint!

Best regards  --  Gerrit

 PS:
  sessionInfo()
 R version 3.0.2 (2013-09-25)
 Platform: x86_64-w64-mingw32/x64 (64-bit)

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

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

 other attached packages:
 [1] fortunes_1.5-2

 loaded via a namespace (and not attached):
 [1] grid_3.0.2  lattice_0.20-27 tools_3.0.2



 -
 Dr. Gerrit Eichner   Mathematical Institute, Room 212
 gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
 Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
 Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Having a plot with points and line with different colors

2014-03-05 Thread Baro
Thanks a lot for your helps


On Wed, Mar 5, 2014 at 7:53 AM, David Carlson dcarl...@tamu.edu wrote:

 Alternatively use type=c instead of l which will create line
 breaks where the points will go.

 plot(1:5,type=c, col=blue)
 points(1:5,col=black)

 David

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon
 Sent: Wednesday, March 5, 2014 4:08 AM
 To: Baro
 Cc: R help
 Subject: Re: [R] Having a plot with points and line with
 different colors

 On 03/05/2014 09:09 PM, Baro wrote:
  thanks Jim,
 
  could you please show me some example?
 

 # plot lines, then points
 plot(1:5,type=l,col=blue)
 points(1:5,col=black)
 # plot both, then overplot points
 plot(1:5,type=o,col=blue)
 points(1:5,col=black)

 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.



[[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] histograms embedded in a plot (as alternative to jitter)

2014-03-05 Thread Bernard North
Dear R list,

I am plotting a discrete valued number on the y axis against a continuous 
variable on the x axis.
To allow sample size to be viewed for the discrete groups I am using vertical 
jitter.
So my code is along the lines of
y-rpois(500,2)
x-rnorm(500,y,1)
plot(x,jitter(y))

It has not been suggested that a more informative view of the sample size might 
be if a histogram could be inserted into the plot (instead of the jittered rows 
of points) for the values at each y-value
Many thanks if anyone can think of a way to do this





This email may contain information that is privileged, confidential or 
otherwise protected from disclosure.
It must not be used by, or its contents copied or disclosed to, persons other 
than the addressee.
If you have received this email in error please notify the sender immediately 
and delete the email.
This message has been scanned for viruses.\ \ \ [[alter...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] margins and device: different results with pdf() and svg()

2014-03-05 Thread Agustin Lobo
The following works fine with either the plot window or a pdf device:

pdf(test.pdf,width=12,height=8)
par(mar=c(5,4,4,5))
plot(421:450,1:30,xlim=c(300,1100), ylim=c(0,100),
type=l,col=blue,xlab=Wavelength,ylab=Transmittance %)
lines(401:1000, (401:1000)/10,col=green)
par(new=TRUE)
axis(4)
mtext(Reflectance,side=4,line=3)
title(Filters MCA01)
dev.off()

but if I use svg() I get a wrong plot.

Why? Any way to get the same plot in svg as in pdf?

Thanks
Agus

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

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
LC_TIME=es_ES.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=es_ES.UTF-8LC_MESSAGES=en_US.UTF-8
LC_PAPER=es_ES.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] MASS_7.3-29 reshape_0.8.4   plyr_1.8ggplot2_0.9.3.1
raster_2.2-12   rgdal_0.8-14sp_1.0-14

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4   dichromat_2.0-0digest_0.6.4
grid_3.0.2 gtable_0.1.2   labeling_0.2
 [7] lattice_0.20-24munsell_0.4.2  proto_0.3-10
RColorBrewer_1.0-5 reshape2_1.2.2 scales_0.2.3
[13] stringr_0.6.2  tools_3.0.2



-- 
Agustin Lobo
aloboa...@gmail.com

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


[R] pdf: plotting very small points

2014-03-05 Thread Rebecca.Hiller
Dear all,

Ghostscript (version 9.05) cannot open pdfs produced with R (version 3.0.2) 
that contain very small points in plots. Other pdf readers (evince, 
AcrobatReader) are able to open the file. If setting cex=0, the pdf is readable 
again:

# does open with gs
pdf(cex_small.pdf)
plot(1,1,cex=10^-3)
dev.off()

# does not open with gs
pdf(cex_verysmall.pdf)
plot(1,1,cex=10^-4)
dev.off()

# does open with gs
pdf(cex_zero.pdf)
plot(1,1,cex=0)
dev.off()

For sure, I can check the value assigned to cex before plotting. However, this 
is rather inconvenient. I need to convert the graphs using convert to other 
file formats, hence simply using another pdf readers is not an option either. 
Any suggestions?

Cheers,
Rebecca Hiller

[[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] To obtain a graph by geom_bar or other

2014-03-05 Thread Michel ARNAUD
Hi

I have the dataframe following :
data.frame(Annee =c(rep(2004,200), rep(2005,200)),
CiradMed =  c(rep(Cirad,100), rep(Med, 100),
rep(Cirad,100), rep(Med, 100)) ,
Type=c(rep(T1, 25), rep(T2, 20), rep(T3, 30), rep(T4, 25),
rep(T1, 20), rep(T2, 30), rep(T3, 40), rep(T4, 10),
rep(T1, 25), rep(T2, 30), rep(T3, 35), rep(T4, 10),
rep(T1, 15), rep(T2, 35), rep(T3, 40), rep(T4, 10)) ,
stringsAsFactors=FALSE)

Is it possible to build with ggplot the same graph obtained by graphics 
packages (see the joined file) ?
I tried by using geom_bar(position=dodge) but it is not correct.

Thank you for your help
Michel


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

2014-03-05 Thread Milton O Faison
I have a script that works fine if I copy the whole thing from from a text 
editor and paste it into R, but doesn't execute properly if the file is called 
by the source command. Any clues on how to fix this? I can post the script if 
necessary.

o

M. Omar Faison, PhD
Director, Office of Sponsored Programs and Research
Virginia State University
804-631-3330
http://twitter.com/omarfaison


“The information in this email and any attachments may be confidential and 
privileged. Access to this email by anyone other than the intended addressee is 
unauthorized. If you are not the intended recipient (or the employee or agent 
responsible for delivering this information to the intended recipient) please 
notify the sender by reply email and immediately delete this email and any 
copies from your computer and/or storage system. The sender does not authorize 
the use, distribution, disclosure or reproduction of this email (or any part of 
its contents) by anyone other than the intended recipient(s).

No representation is made that this email and any attachments are free of 
viruses. Virus scanning is recommended and is the responsibility of the 
recipient.”

[[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] pdf: plotting very small points

2014-03-05 Thread Duncan Murdoch

On 05/03/2014 8:34 AM, rebecca.hil...@meteoswiss.ch wrote:

Dear all,

Ghostscript (version 9.05) cannot open pdfs produced with R (version 3.0.2) 
that contain very small points in plots. Other pdf readers (evince, 
AcrobatReader) are able to open the file. If setting cex=0, the pdf is readable 
again:

# does open with gs
pdf(cex_small.pdf)
plot(1,1,cex=10^-3)
dev.off()

# does not open with gs
pdf(cex_verysmall.pdf)
plot(1,1,cex=10^-4)
dev.off()

# does open with gs
pdf(cex_zero.pdf)
plot(1,1,cex=0)
dev.off()

For sure, I can check the value assigned to cex before plotting. However, this 
is rather inconvenient. I need to convert the graphs using convert to other 
file formats, hence simply using another pdf readers is not an option either. 
Any suggestions?


From your description, it sounds like a Ghostscript bug, so you might 
want to report it to them.  But a simple workaround is to just round 
your cex values, e.g. use round(cex, 2) and 0.001 will become 0.


Duncan Murdoch

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


Re: [R] Specifying strip.names in Lattice plots [UPDATE]

2014-03-05 Thread Rich Shepard

On Tue, 4 Mar 2014, Rich Shepard wrote:


What I want to learn how to do is either 1) put the ylab in the strip or
2) eliminate the strip as redundant.


  The latest iteration, and the accompanying warning message:

xyplot(cbind(dalles.disch.ts, dalles.temp.ts), main = Columbia River @ The
Dalles, xlab = Date (Year.Month), ylab = c(Temperature (C),Discharge
(cfs)), strip = FALSE, strip.left = strip.custom(par.strip.text =
trellis.par.get(c(Mean Temperature,Mean Discharge

Warning message: In if (name %in% names(lattice.theme[[.Device]]))
lattice.theme[[.Device]][[name]] else NULL :
  the condition has length  1 and only the first element will be used

  Please correct the syntax in the xyplot() function so the two strips have
the desired text.

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] Specifying strip.names in Lattice plots [SEMI-RESOLVED]

2014-03-05 Thread Rich Shepard

On Wed, 5 Mar 2014, Rich Shepard wrote:


2) eliminate the strip as redundant.


  Did this. It works.

  Would like to learn how to use par.strip.text to change the text on each
strip, but removing them when redundant works for this figure.

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] Shortest connected path in a matrix

2014-03-05 Thread McCloskey, Bryan
Here is some example data (hopefully the monospace formatting is preserved):

a   b   c   d   e
-   -   -   -   -
1 | F | T | F | T | F |
-   -   -   -   -
2 | T | F | T | F | T |
-   -   -   -   -
3 | T | T | F | F | F |
-   -   -   -   -
4 | F | T | F | T | F |
-   -   -   -   -
5 | F | T | F | F | T |
-   -   -   -   -

So, for cell b1, the shortest possible path to a true value in row 5 is
b1-a2-a3-b4-b5 (distance: sqrt(2) + 1 + sqrt(2) + 1).

* Shortest paths are not necessarily unique, but I just need to find the
length.

* If it's computationally hard to guarantee the absolute shortest path, I
can probably live with nearly shortest paths.

* Paths can backtrack, so the shortest path from cell e2 to row 4 is
e2-d1-c2-b3-b4-b5.

I need to calculate the shortest path for all true cells to all rows
further down the matrix. I'm afraid I'm going to have to write some sort of
recursive path-tracing algorithm, but I'm hoping there's a package already
in existence that accomplishes this already...

-bryan

On Tue, Mar 4, 2014 at 1:13 PM, McCloskey, Bryan bmcclos...@usgs.govwrote:

 I have a binary rectangular T/F matrix; I need to be able to calculate the
 shortest path (i.e., Pythagorean distance) between a populated cell in row
 j and any populated cell in some row j+n.

 For instance, if I have a chessboard with random black/white square
 colors, I need the shortest distance (linear distance, not number of steps)
 for a king to get from a specified black space on the first row, to _any_
 black space in a specified further row, traveling only on black spaces.

 Any idea? Thanks,

 -bryan


[[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] Shortest connected path in a matrix

2014-03-05 Thread Bert Gunter
(Mod my ignorance)

This appears to be computer science/math problem and has nothing
specifically to do with statistics nor R. So I suggest you post on a more
appropriate venue rather than here.

Cheers,
Bert


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Wed, Mar 5, 2014 at 9:44 AM, McCloskey, Bryan bmcclos...@usgs.govwrote:

 Here is some example data (hopefully the monospace formatting is
 preserved):

 a   b   c   d   e
 -   -   -   -   -
 1 | F | T | F | T | F |
 -   -   -   -   -
 2 | T | F | T | F | T |
 -   -   -   -   -
 3 | T | T | F | F | F |
 -   -   -   -   -
 4 | F | T | F | T | F |
 -   -   -   -   -
 5 | F | T | F | F | T |
 -   -   -   -   -

 So, for cell b1, the shortest possible path to a true value in row 5 is
 b1-a2-a3-b4-b5 (distance: sqrt(2) + 1 + sqrt(2) + 1).

 * Shortest paths are not necessarily unique, but I just need to find the
 length.

 * If it's computationally hard to guarantee the absolute shortest path, I
 can probably live with nearly shortest paths.

 * Paths can backtrack, so the shortest path from cell e2 to row 4 is
 e2-d1-c2-b3-b4-b5.

 I need to calculate the shortest path for all true cells to all rows
 further down the matrix. I'm afraid I'm going to have to write some sort of
 recursive path-tracing algorithm, but I'm hoping there's a package already
 in existence that accomplishes this already...

 -bryan

 On Tue, Mar 4, 2014 at 1:13 PM, McCloskey, Bryan bmcclos...@usgs.gov
 wrote:

  I have a binary rectangular T/F matrix; I need to be able to calculate
 the
  shortest path (i.e., Pythagorean distance) between a populated cell in
 row
  j and any populated cell in some row j+n.
 
  For instance, if I have a chessboard with random black/white square
  colors, I need the shortest distance (linear distance, not number of
 steps)
  for a king to get from a specified black space on the first row, to _any_
  black space in a specified further row, traveling only on black spaces.
 
  Any idea? Thanks,
 
  -bryan
 

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Shortest connected path in a matrix

2014-03-05 Thread Suzen, Mehmet
You may want to check bioconductor packages doing graph algorithms.
Maybe this one:
http://www.bioconductor.org/packages/release/bioc/manuals/RBGL/man/RBGL.pdf
See  for example ?dijkstra.sp

On 5 March 2014 18:44, McCloskey, Bryan bmcclos...@usgs.gov wrote:
 Here is some example data (hopefully the monospace formatting is preserved):

 a   b   c   d   e
 -   -   -   -   -
 1 | F | T | F | T | F |
 -   -   -   -   -
 2 | T | F | T | F | T |
 -   -   -   -   -
 3 | T | T | F | F | F |
 -   -   -   -   -
 4 | F | T | F | T | F |
 -   -   -   -   -
 5 | F | T | F | F | T |
 -   -   -   -   -

 So, for cell b1, the shortest possible path to a true value in row 5 is
 b1-a2-a3-b4-b5 (distance: sqrt(2) + 1 + sqrt(2) + 1).

 * Shortest paths are not necessarily unique, but I just need to find the
 length.

 * If it's computationally hard to guarantee the absolute shortest path, I
 can probably live with nearly shortest paths.

 * Paths can backtrack, so the shortest path from cell e2 to row 4 is
 e2-d1-c2-b3-b4-b5.

 I need to calculate the shortest path for all true cells to all rows
 further down the matrix. I'm afraid I'm going to have to write some sort of
 recursive path-tracing algorithm, but I'm hoping there's a package already
 in existence that accomplishes this already...

 -bryan

 On Tue, Mar 4, 2014 at 1:13 PM, McCloskey, Bryan bmcclos...@usgs.govwrote:

 I have a binary rectangular T/F matrix; I need to be able to calculate the
 shortest path (i.e., Pythagorean distance) between a populated cell in row
 j and any populated cell in some row j+n.

 For instance, if I have a chessboard with random black/white square
 colors, I need the shortest distance (linear distance, not number of steps)
 for a king to get from a specified black space on the first row, to _any_
 black space in a specified further row, traveling only on black spaces.

 Any idea? Thanks,

 -bryan


 [[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] books and datasets

2014-03-05 Thread Carlos Hernandez
Dear R-users, I am looking for books and R examples that focus on the
analysis of advertising, marketing, web metrics, and social media datasets.
I wonder if you have recommendations for me. Thanks much!

[[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] Two maps with different legends with spplot

2014-03-05 Thread Gian

Hi all, 
I am using spplot to plot two maps in the same device. In my
case, I have a map of a certain variable and the same map of the standard
deviation of the same variable. The range of the second is much smaller
than the range of the first so my wish is to plot both but to have them on
different scales for the color legend (hence, to have two separated
legends). Is it
possible?

I have worked out a way to do that, which passes through stretching the
second variable to the range of the first, and then work hardly on the key
list  from within the trellis object structure. 
I was wondering if there is a more straightforward way. 

Thanks,

Gianluca

Inviato da iPhone

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


Re: [R] alternative to wireframe()

2014-03-05 Thread MacQueen, Don
Have you looked at persp() ?

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/4/14 2:56 AM, Rainer M Krug rai...@krugs.de wrote:

Hi

I am slowly getting enough of wireframe() from the package lattice, as
it is to complicated for what I need and does not really do what I
want. I am using it to produce a (surprise!) wireframe plot (see example
below). 
The plot function is part of plot.tss in a package which I am working
on, and the plot looks nice, but I would like to have the option to use
it as part of a layout(), which does not work.

Also, I did not get a real handle if I have to wrap the wireframe
function into a print().

So I am looking for a simpler alternative, which produces a similar plot
to the one created by the example below. I would prefer a different
legend and I would like to have the 3D plot respect the layout() command
above.

Any suggestions which function I could use?

Thanks,

Rainer


--8---cut here---start-8---
library(lattice)
x - structure(list(threshold1 = c(21, 74.5, 128, 181.5, 235, 21,
74.5, 128, 181.5, 235, 21, 74.5, 128, 181.5, 235, 21, 74.5, 128,
181.5, 235, 21, 74.5, 128, 181.5, 235), threshold2 = c(0, 0,
0, 0, 0, 61.25, 61.25, 61.25, 61.25, 61.25, 122.5, 122.5, 122.5,
122.5, 122.5, 183.75, 183.75, 183.75, 183.75, 183.75, 245, 245,
245, 245, 245), overallAccuracy = c(0.606076276664512, 0.606076276664512,
0.606076276664512, 0.606076276664512, 0.606076276664512,
0.594182288299935,
0.597026502908856, 0.605559146735617, 0.606076276664512,
0.606076276664512,
0.6120232708468, 0.62262443438914, 0.633742727860375, 0.611376858435682,
0.606076276664512, 0.618616677440207, 0.630122818358112,
0.706658047834518,
0.695151906916613, 0.606076276664512, 0.393923723335488,
0.405429864253394,
0.482740788623142, 0.58655462184874, 0.606076276664512), sensitivity =
c(0, 
0, 0, 0, 0, 0.012471283229406, 0.0118148999015425, 0.00393829996718083,
0, 0, 0.130620282244831, 0.126025598949787, 0.0912372825730226,
0.0141122415490647, 0, 0.598949786675418, 0.594355103380374,
0.526419428946505, 0.296685264194289, 0, 1, 0.995405316704956,
0.927469642271086, 0.661962586150312, 0), specificity = c(1,
1, 1, 1, 1, 0.972269624573379, 0.977389078498293, 0.996587030716723,
1, 1, 0.924914675767918, 0.945392491467577, 0.986348122866894,
0.99957337883959, 1, 0.631399317406143, 0.653370307167236,
0.823805460750853,
0.954138225255973, 1, 0, 0.0219709897610922, 0.193686006825939,
0.537542662116041, 1), tss = c(0, 0, 0, 0, 0, -0.0152590921972152,
-0.010796021600164, 0.000525330683904368, 0, 0, 0.0555349580127491,
0.0714180904173634, 0.0775854054399168, 0.0136856203886551, 0,
0.230349104081562, 0.24772541054761, 0.350224889697358,
0.250823489450262,
0, 0, 0.0173763064660479, 0.121155649097025, 0.199505248266353,
0), kappa = c(0, 0, 0, 0, 0, -0.0182824920390604, -0.0129583064846108,
0.000635541910639162, 0, 0, 0.0639760122213153, 0.0828765513813943,
0.0918579943188013, 0.0165372451769894, 0, 0.223843122923358,
0.242311121014362, 0.363093208690974, 0.28206036774748, 0, 0,
0.0137627491763651, 0.100591615720438, 0.187264280971332, 0),
pP = c(0L, 0L, 0L, 0L, 0L, 38L, 36L, 12L, 0L, 0L, 398L, 384L,
278L, 43L, 0L, 1825L, 1811L, 1604L, 904L, 0L, 3047L, 3033L,
2826L, 2017L, 0L), pA = c(0L, 0L, 0L, 0L, 0L, 130L, 106L,
16L, 0L, 0L, 352L, 256L, 64L, 2L, 0L, 1728L, 1625L, 826L,
215L, 0L, 4688L, 4585L, 3780L, 2168L, 0L), aA = c(4688L,
4688L, 4688L, 4688L, 4688L, 4558L, 4582L, 4672L, 4688L, 4688L,
4336L, 4432L, 4624L, 4686L, 4688L, 2960L, 3063L, 3862L, 4473L,
4688L, 0L, 103L, 908L, 2520L, 4688L), aP = c(3047L, 3047L,
3047L, 3047L, 3047L, 3009L, 3011L, 3035L, 3047L, 3047L, 2649L,
2663L, 2769L, 3004L, 3047L, 1222L, 1236L, 1443L, 2143L, 3047L,
0L, 14L, 221L, 1030L, 3047L), n = 7735L), .Names = c(threshold1,
threshold2, overallAccuracy, sensitivity, specificity,
tss, kappa, pP, pA, aA, aP, n), class = TSS, link =
.Primitive(), largerPres1 = TRUE, largerPres2 = FALSE, threshold1 =
c(21, 
74.5, 128, 181.5, 235), threshold2 = c(0, 61.25, 122.5, 183.75,
245), dimension = 2)

columns - c(tss, sensitivity, specificity)
column.col - rainbow(length(columns))
xp - rep(x$threshold1, length(columns))
yp - rep(x$threshold2, length(columns))
zp - NULL
for (i in 1:length(columns)) {
zp - c(zp, x[[columns[i]]])
}

grp - rep(columns, each=length(x$tss))

###
layout(matrix(1:4, ncol=2), c(1,2,3,4))
###

wireframe(
zp ~ xp * yp,
xlab = threshold 1,
ylab = threshold 2,
zlab = paste(columns, collapse=\n),
groups = grp,
par.settings = simpleTheme(
alpha = 0.7,
col = column.col,
),
scales = list(arrows = FALSE),
auto.key = TRUE
)
--8---cut here---end---8---

-- 
Rainer M. Krug

email: RMKrugatgmaildotcom

__
R-help@r-project.org mailing list

Re: [R] problem with previous code

2014-03-05 Thread Elio Shijaku
Hi Arun,

Yes, that last command m1[indx2N] - m2[sort(indx1)] did exactly the trick,
now the variable and their values are perfectly matched. Thanks a lot for
your great help.

Best,

Elio


On Wed, Mar 5, 2014 at 1:17 AM, arun smartpink...@yahoo.com wrote:



 Hi Elio,

 If you change the last line of the code:

 m1[indx2N] - m2[indx1]

 to
 m1[indx2N] - m2[sort(indx1)]

  sum(m1[rownames(m1)==p79,])
 #[1] 191
  sum(m2[rownames(m2)==p79,])
 #[1] 191


 The problem is in the order of the colnames/rownames in each of the
 datasets.  I tested it on something like:
 m1 - matrix(0,12,12,dimnames=rep(list(paste0(a,1:12)),2))
  set.seed(49)
  m2 -
 matrix(sample(0:2,4*4,replace=TRUE),ncol=4,dimnames=rep(list(c(a4,a6,a9,a12)),2))

 which didn't show the problem.


 But, if I change the order of colnames:

 m1 - matrix(0,12,12,dimnames=rep(list(paste0(a,c(1:3,8:12,4:7))),2))

 set.seed(49)
  m2 -
 matrix(sample(0:2,4*4,replace=TRUE),ncol=4,dimnames=rep(list(c(a9,a4,a6,a12)),2))
 vec1 - paste0(rownames(m1)[row(m1)],colnames(m1)[col(m1)])
 vec2 - paste0(rownames(m2)[row(m2)],colnames(m2)[col(m2)])
 indx - match(vec1,vec2)
 indx1 - indx[!is.na(indx)]

 indx2 - match(vec2,vec1)
 indx2N - indx2[!is.na(indx2)]
 m1[indx2N] - m2[sort(indx1)]
 m1


 Hope this helps.
 A.K.






 On Tuesday, March 4, 2014 3:16 PM, Elio Shijaku sel...@gmail.com wrote:

 Hi Arun,

 Sorry to disturb, but while trying your code to combine two matrices of
 unequal dimensions, I noticed a problem, the sum for each variable does not
 match, but the overall variables sum does match for both matrices,
 something isn't going right, perhaps the variables are getting mixed up,
 any idea??

 Here is the code you sent me and the zipped files for testing:


 dat1 -
 read.table(mtest.txt,header=TRUE)
 dim(dat1)

 dat2 -
 read.table(1998res_x.txt,header=TRUE)
 dim(dat2)
 m1 - as.matrix(dat1)
 m2 - as.matrix(dat2)
 vec1 -
 paste0(rownames(m1)[row(m1)],colnames(m1)[col(m1)])
 vec2 - paste0(rownames(m2)[row(m2)],colnames(m2)[col(m2)])
 indx - match(vec1,vec2)
 indx1 - indx[!is.na(indx)]
 indx2 - match(vec2,vec1)
 indx2N - indx2[!is.na(indx2)]
 m1[indx2N] - m2[indx1]

 Thanks a lot!!


 Best,


 Elio


[[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] Script question

2014-03-05 Thread MacQueen, Don
You haven't said what, exactly, doesn't execute properly means (please
read the posting guide).

At a guess, you need to put
  print()
around the expressions whose output you aren't seeing.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/5/14 6:19 AM, Milton O Faison mfai...@vsu.edu wrote:

I have a script that works fine if I copy the whole thing from from a
text editor and paste it into R, but doesn't execute properly if the file
is called by the source command. Any clues on how to fix this? I can post
the script if necessary.

o

M. Omar Faison, PhD
Director, Office of Sponsored Programs and Research
Virginia State University
804-631-3330
http://twitter.com/omarfaison


³The information in this email and any attachments may be confidential
and privileged. Access to this email by anyone other than the intended
addressee is unauthorized. If you are not the intended recipient (or the
employee or agent responsible for delivering this information to the
intended recipient) please notify the sender by reply email and
immediately delete this email and any copies from your computer and/or
storage system. The sender does not authorize the use, distribution,
disclosure or reproduction of this email (or any part of its contents) by
anyone other than the intended recipient(s).

No representation is made that this email and any attachments are free of
viruses. Virus scanning is recommended and is the responsibility of the
recipient.²

   [[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] books and datasets

2014-03-05 Thread Bert Gunter
Google is your friend!

Cheers,
Bert


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Wed, Mar 5, 2014 at 10:40 AM, Carlos Hernandez carlos.u...@gmail.comwrote:

 Dear R-users, I am looking for books and R examples that focus on the
 analysis of advertising, marketing, web metrics, and social media datasets.
 I wonder if you have recommendations for me. Thanks much!

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] histograms embedded in a plot (as alternative to jitter)

2014-03-05 Thread David Carlson
Not histograms, but here are two alternatives. The first gives
you kernel density plots for each value and the second uses
violin plots. Both plot points if there are fewer than 5.

set.seed(42)
y-rpois(500,2)
x-rnorm(500,y,1)

plot(x,y, type=n)
for (i in seq(min(y), max(y), by=1)) {
  if (length(x[y==i])5) {
points(x[y==i], rep(i, length(x[y==i])))
  } else {
a - density(x[y==i])
polygon(a$x, a$y+i, col=gray)
  }
}

require(vioplot)
plot(x,y, type=n)
for (i in seq(min(y), max(y), by=1)) {
  if (length(x[y==i])5) {
points(x[y==i], rep(i, length(x[y==i])))
  } else {
vioplot(x[y==i], horizontal=TRUE, add=TRUE, at=i,
col=gray)
  }
}

-
David L Carlson
Department of Anthropology
Texas AM University
College Station, TX 77840-4352

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Bernard North
Sent: Wednesday, March 5, 2014 7:44 AM
To: r-help@r-project.org
Subject: [R] histograms embedded in a plot (as alternative to
jitter)

Dear R list,

I am plotting a discrete valued number on the y axis against a
continuous variable on the x axis.
To allow sample size to be viewed for the discrete groups I am
using vertical jitter.
So my code is along the lines of
y-rpois(500,2)
x-rnorm(500,y,1)
plot(x,jitter(y))

It has not been suggested that a more informative view of the
sample size might be if a histogram could be inserted into the
plot (instead of the jittered rows of points) for the values at
each y-value
Many thanks if anyone can think of a way to do this





This email may contain information that is privileged,
confidential or otherwise protected from disclosure.
It must not be used by, or its contents copied or disclosed to,
persons other than the addressee.
If you have received this email in error please notify the
sender immediately and delete the email.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Specifying strip.names in Lattice plots [UPDATE]

2014-03-05 Thread Duncan Mackay
Hi Rich

Without an example it is hard to work out.

trellis.par.get(c(... 

is not correct, see

names(trellis.par.get())

try

strip= strip.custom(factor.levels = c(string vector of names for each
panel), par.strip.text = list(cex = 0.8) ),

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Rich Shepard
Sent: Thursday, 6 March 2014 03:29
To: r-help@r-project.org
Subject: Re: [R] Specifying strip.names in Lattice plots [UPDATE]

On Tue, 4 Mar 2014, Rich Shepard wrote:

 What I want to learn how to do is either 1) put the ylab in the strip or
 2) eliminate the strip as redundant.

   The latest iteration, and the accompanying warning message:

xyplot(cbind(dalles.disch.ts, dalles.temp.ts), main = Columbia River @ The
Dalles, xlab = Date (Year.Month), ylab = c(Temperature (C),Discharge
(cfs)), strip = FALSE, strip.left = strip.custom(par.strip.text =
trellis.par.get(c(Mean Temperature,Mean Discharge

Warning message: In if (name %in% names(lattice.theme[[.Device]]))
lattice.theme[[.Device]][[name]] else NULL :
   the condition has length  1 and only the first element will be used

   Please correct the syntax in the xyplot() function so the two strips have
the desired text.

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.

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

2014-03-05 Thread catalin roibu
Dear all,

Is there a possibility to remove the panel (with names) from a lattice plot?

Thank you very much for your help!

---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
   +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

[[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] AIX 7.1 and R build problems

2014-03-05 Thread Mike Beddo
Has anyone managed to build R-3.0.2 from source on AIX 7.1 using gcc 4.2.0. The 
configure script finishes with:

...
checking whether wctrans exists and is declared... no
checking whether iswblank exists and is declared... no
checking whether wctype exists and is declared... no
checking whether iswctype exists and is declared... no
configure: error: Support for MBCS locales is required.

Scanning through the config.log the configure script seems to be happy with the 
C99 compliance at hand. I have tried reading NEWS, README, and R-Help archives 
but I can't get past this. I'm all Google'd out. Is my compiler too old?

_
Michael Beddo
Senior Scientist

Data Ventures, Inc.
1475 Central Ave. Suite 230  |  Los Alamos, NM 87544
tel  505.695.2132 
http://www.dataventures.com  |  Advanced - Effective - Actionable - Proven. 
Analytics

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

2014-03-05 Thread Bert Gunter
I am not sure what you mean by remove (reproducible example??,
code??) but see the skip argument of xyplot, which says:

skip:

A logical vector (default FALSE), replicated to be as long as the
number of panels (spanning all pages). For elements that are TRUE, the
corresponding panel position is skipped; i.e., nothing is plotted in
that position. The panel that was supposed to be drawn there is now
drawn in the next available panel position, and the positions of all
the subsequent panels are bumped up accordingly. This may be useful
for arranging plots in an informative manner.


Presumably you can omit data that you don't wish to be plotted via the
subset argument, or changing it to NA, or removing it from your
data.

If your issue is getting rid of unwanted empty factor levels, that can
be done by the drop.unused.levels argument.

If I haven't guessed what you mean, either explain more clearly or
hope that someone else does.


Cheers,

Bert


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Wed, Mar 5, 2014 at 1:11 PM, catalin roibu catalinro...@gmail.com wrote:
 Dear all,

 Is there a possibility to remove the panel (with names) from a lattice plot?

 Thank you very much for your help!

 ---
 Catalin-Constantin ROIBU
 Lecturer PhD, Forestry engineer
 Forestry Faculty of Suceava
 Str. Universitatii no. 13, Suceava, 720229, Romania
 office phone +4 0230 52 29 78, ext. 531
 mobile phone   +4 0745 53 18 01
+4 0766 71 76 58
 FAX:+4 0230 52 16 64
 silvic.usv.ro

 [[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] Remove lattice panel

2014-03-05 Thread Duncan Mackay
Hi

If you want to remove a panel with no plots in  it see

?lattice::xyplot 
and look for drop.unused.levels

If you want to remove a factor that has plot values in it then the easiest
way may be to create a column of the factor and NA the values of the panel,
relevel the factor and use the column instead
Otherwise an example via dput would be needed for further help

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of catalin roibu
Sent: Thursday, 6 March 2014 07:11
To: r-help@r-project.org
Subject: [R] Remove lattice panel

Dear all,

Is there a possibility to remove the panel (with names) from a lattice plot?

Thank you very much for your help!

---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
   +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

[[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] histograms embedded in a plot (as alternative to jitter)

2014-03-05 Thread Jim Lemon

On 03/06/2014 12:44 AM, Bernard North wrote:

Dear R list,

I am plotting a discrete valued number on the y axis against a continuous 
variable on the x axis.
To allow sample size to be viewed for the discrete groups I am using vertical 
jitter.
So my code is along the lines of
y-rpois(500,2)
x-rnorm(500,y,1)
plot(x,jitter(y))

It has not been suggested that a more informative view of the sample size might 
be if a histogram could be inserted into the plot (instead of the jittered rows 
of points) for the values at each y-value
Many thanks if anyone can think of a way to do this


Hi Bernard,
You can use the subplot function in the TeachingDemos package to do 
things like this.


Jim

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


[R] ZeligChoice - error

2014-03-05 Thread cauder

Dear R-users, 
nbsp; 
On the basis of ZeligChoice Manual I wrote several commands to create a plot of 
probabilities for a bivariate logit model. However, after sim() command I 
receive information about non-conformable arguments. Could you interpret the 
message? R is, as far as I know, the only statistical programme that enable to 
estimate not only bivariate probit, but also bivariate logit model... 
nbsp; 
Regards, 
Thank you in advance 
nbsp; 
library(ZeligChoice) danelt;-read.csv(dlaer.csv, header=TRUE, sep=;) 
z.out2lt;-zelig(list(mu1=c1~age+male+company+educ_4+educ_3+educ_2,mu2=c2~age+male+eduk_4+eduk_3+eduk_2),model=blogit,data=dane)
 x.low2 lt;- setx(z.out2, male = 1) x.high2 lt;- setx(z.out2, male = 0) 
s.out2 lt;- sim(z.out2, x1 = x.low2, x = x.high2, num = 500) AFTER THIS 
COMMAND I RECEIVE THE ANSWER ABOUT AN EROR: 
Error in all.coef[[1]] %*% as.matrix(xm[[1]]) : non-conformable arguments 
plot(s.out2) summary(z.out2) coef(z.out2) vcov(z.out2) 
nbsp; 
nbsp; 
nbsp; 






--
View this message in context: 
http://r.789695.n4.nabble.com/ZeligChoice-error-tp4686285.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] Fitting two parameter observations into copulas

2014-03-05 Thread Yang Yang
Hi,

I have one set of observations containing two parameters.

How to fit it into copula (estimate the parameter of the copula and the
margin function)?

Let's say the margin distribution are log-normal distributions, and the
copula is Gumbel copula.

The data is as below:

1   974.0304 1010
2  6094.2672 1150
3  3103.2720 1490
4  1746.1872 1210
5  6683.7744 3060
6  6299.6832 3330
7  4784.0112 1550
8  1472.4288  607
9  3758.5728 1970
10 4381.2144 1350
11 5391.7056 2120
12 5353.3872 2560
13 3036.0960 2200
14 2016.9216 1190
15 2024.2224  670
16 2255.1264  970
17 2813.7024 1060
18 3889.5552 1290
19 2365.2950 2370
20 4471.6320 1450
21 2263.2048 1660
22 3047.9760 1170
23 2415.6144 2040
24 2249.5968  764
25 1379.7216  903
26 2743.3728 1140
27 2143.3680 1120
28 1396.9152  538
29 2385.5904  535
30 3966.5808 1720
31 3315.1680 1310
32 5822.1072 1660
33 2646.2160 1260
34 3592.9440 1050
35 6689.4336 1440
36  802.5264  785
37 1371.2544  595
38 1474.3728  390
39 1588.7232  731
40 5647.7952 1685
41 3832.0560 1245
42 2409.2208 1671
43 1978.6464 1073
44 6344.5248 1169
45 1654.9488 1380
46 3341.4336 2137
47 3563.0064 1543
48 4345.8336  825
49 1039.0464  572
50  727.4448  993
51 2271.0240 1360
52 5255.9712 1730
53 5972.0112 2150
54 2710.5840 1240
55 2314.3968  920
56  521.7264  572
57 3534.8832 1110
58 1471.4352 1010
59 2963.0448 1540
60 3431.1168 1320
61 2715.9408 1210
62 5161.7088 1260
63 2853.8352  870
64 4264.8336 1784
65 5605.5888 1720
66 3861.4752 1170
67 4537.5120 4290
68 4561.2720 2090
69 2652.7392  815
70 3610.1376 1670
71 6972.1776 2870
72 2654.4672  699
73 2982.0960 1020
74 3959.9280 1140
75 1224.2880 1370
76 2309.3860 2260


I have finished the univariate analysis for both parameter, estimated
the distribution fitted the log-normal distribution. And I install
the copula package, the function fitCopula required a parameter
for the copula, I didn't quite understand, because this is the one
which I am going to estimate. Also, how to convert the distribution
(log-normal) to uniform marginal distribution for copula analysis?

ibrary(copula)
gumbel.cop - gumbelCopula(dim=2)
myMvd - mvdc(gumbel.cop, c(lnorm,lnorm), list(list(meanlog =
7.1445391,sdlog=0.4568783), list(meanlog = 7.957392,sdlog=0.559831)))
x - rmvdc(myMvd, 1000)
fit - fitMvdc(x, myMvd, c(7.1445391,0.4568783,7.957392,0.559831))


the meanlog and sdlog value are derived from the data set. error message

Error in if (alpha - 1  .Machine$double.eps^(1/3)) return(rCopula(n, :

missing value where TRUE/FALSE needed 

How to choose the copula parameter with the given data, and the margin
distributions derived from the data set?


Thank you very much for your help.

best regards,

Yang Yang

GFZ-Potsdam

[[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] Is this a mistake in 'An Introduction to R'?

2014-03-05 Thread Geoff Loveman
Peter

I see there is no mistake. The phrase about the 'number of parameters' confused 
me, it is a little ambiguous.
Many thanks for taking the time to help me.

Geoff



 On 5 Mar 2014, at 11:20, Peter Dalgaard-2 [via R] 
 ml-node+s789695n4686243...@n4.nabble.com wrote:
 
 
 On 04 Mar 2014, at 21:21 , Geoff Loveman [hidden email] wrote: 
 
  
  
  In 'An Introduction to R', section 11.7 on nonlinear least squares fitting, 
  the following example is given for obtaining the standard errors of the 
  estimated parameters: 
  
  To obtain the approximate standard errors (SE) of the estimates we do: 
  sqrt(diag(2*out$minimum/(length(y) - 2) * solve(out$hessian)))The 2 in the 
  line above represents the number of parameters. 
  
  I know the inverted Hessian is multiplied by the mean square error and that 
  the denominator of the MSE is the degrees of freedom (number of samples - 
  number of parameters) but why does the numerator of the MSE (which is the 
  RSS) get multiplied by the number of parameters? I have read through 
  explanations of the method for obtaining the SE but I don't see where the 
  MSE gets multiplied by the number of parameters or why this is needed as 
  shown in the example? 
 
 
 
 There are two 2's in that line, and I'd expect that only the last one has to 
 do with the number of parameters, and the other one has to do with whether 
 the Hessian is the second derivative of the sum of squares or of the negative 
 loglikelihood function (half the sum of squares). 
 
 Quick check: In a linear model, we have 
 
 ssd = || Y- X beta ||^2 
 gradient = -2 (Y - X beta )'X 
 Hessian H = 2 X'X 
 
 and as we know, V(beta) = sigma^2 (X'X)^-1 = 2 sigma^2 H^-1 
 
 -pd 
 
  Thanks for any help! 
  
  Geoff Loveman 
  Tech lead SMERAS 
  QQ Maritime Life Support 
  
  
  
  
  
  -- 
  View this message in context: 
  http://r.789695.n4.nabble.com/Is-this-a-mistake-in-An-Introduction-to-R-tp4686217.html
  Sent from the R help mailing list archive at Nabble.com. 
  
  __ 
  [hidden email] mailing list 
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 -- 
 Peter Dalgaard, Professor 
 Center for Statistics, Copenhagen Business School 
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark 
 Phone: (+45)38153501 
 Email: [hidden email]  Priv: [hidden email] 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 
 
 If you reply to this email, your message will be added to the discussion 
 below:
 http://r.789695.n4.nabble.com/Is-this-a-mistake-in-An-Introduction-to-R-tp4686217p4686243.html
 To unsubscribe from Is this a mistake in 'An Introduction to R'?, click here.
 NAML




--
View this message in context: 
http://r.789695.n4.nabble.com/Is-this-a-mistake-in-An-Introduction-to-R-tp4686217p4686291.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] Building R for better performance

2014-03-05 Thread Anspach, Jonathan P
Simon,

Thanks for the information and links.  First of all, did you ever resolve your 
problem?  If not, did you file an issue in Intel Premier Support?  That's the 
best way to bring it to our attention.  If you don't want to do that I can try 
to get a compiler or MKL support engineer to look at your Intel Developer Zone 
discussion.  I have no experience with OS X, so I wouldn't be much help.

I got the benchmark script, which I've attached, from Texas Advanced Computing 
Center.  Here are my results (elapsed times, in secs):


 gcc build (default)
 icc/MKL build
Creation, transp., deformation of a 5000x5000 matrix
3.25  2.95
5000x5000 normal distributed random matrix ^1000
   5.13  1.52
Sorting of 14,000,000 random values 
 1.61  1.64
5600x5600 cross-product matrix (b = a' * a) 
  97.44  0.56
Linear regr. over a 4000x4000 matrix (c = a \ b')   
46.06   0.49
FFT over 4,800,000 random values
   0.65   0.61
Eigenvalues of a 1200x1200 random matrix
  5.55   1.37
Determinant of a 5000x5000 random matrix
  34.18   0.55
Cholesky decomposition of a 6000x6000 matrix
37.07   0.47
Inverse of a 3200x3200 random matrix
 29.49   0.57
3,500,000 Fibonacci numbers calculation (vector calc)   
   1.310.38
Creation of a 6000x6000 Hilbert matrix (matrix calc)
 0.77 0.99
Grand common divisors of 400,000 pairs (recursion)  
  0.63 0.56
Creation of a 1000x1000 Toeplitz matrix (loops) 
2.24 2.34
Escoufier's method on a 90x90 matrix (mixed)
   9.55 6.02
Total   
  274.93
   21.01

Regards,
Jonathan Anspach
Sr. Software Engineer
Intel Corp.
jonathan.p.ansp...@intel.com
713-751-9460


-Original Message-
From: Simon Zehnder [mailto:szehn...@uni-bonn.de] 
Sent: Wednesday, March 05, 2014 3:55 AM
To: Anspach, Jonathan P
Cc: r-help@r-project.org
Subject: Re: [R] Building R for better performance

Jonathan,

I myself tried something like this - comparing gcc, clang and intel on a Mac. 
From my experiences in HPC on the university cluster (where we also use the 
Xeon Phi, Landeshochleistungscluster University RWTH Aachen), the Intel 
compiler has better code optimization in regard to vectorisation, etc. (clang 
is up to now suffering from a not yet implemented OpenMP library).

Here is a revolutionanalytics article about this topic: 
http://blog.revolutionanalytics.com/2010/06/performance-benefits-of-multithreaded-r.html

As I usually use the Rcpp package for C++ extensions this could give me further 
performance. Though, I already failed when trying to compile R with the Intel 
compiler and linking against the MKL (see my topic in the Intel developer zone: 
http://software.intel.com/en-us/comment/1767418 and my threads on the R-User 
list: https://stat.ethz.ch/pipermail/r-sig-mac/2013-November/010472.html). 

So, to your questions:

1) I think that most admins do not even use the Intel compiler to compile R - 
this seems to me rare. There are some people I know they do and I think they 
could be aware of it - but these are only a few. As R is growing in usage and I 
do know from regional user meetings that very large companies start using it in 
their BI units - this should be of interest.

2) I would really welcome this step because compilation with intel (especially 
on a Mac) and linking to the MKL seems to be delicate. 

I am interested in the data - so if it is possible send it via the list or 
directly to my account. Further, could you show some code that 

Re: [R] Building R for better performance

2014-03-05 Thread ce

Hi Jonathan,

I think most people would be interested in such a tool, because main complaint 
of R is its slowness for some operations and big data.
Even thought the intel software is paying , I could install it free since I am 
not selling any software and work for non-profit. 
I compiled successfully on my opensuse.. My question is : after make install , 
do I need to give special options to install.packages or they will be complied 
with icc automatically ?

Regards
CE


-Original Message-
From: Anspach, Jonathan P [jonathan.p.ansp...@intel.com]
Date: 03/05/2014 12:28 AM
To: r-help@r-project.org r-help@r-project.org
Subject: [R] Building R for better performance

Greetings,

I'm a software engineer with Intel.  Recently I've been investigating R 
performance on Intel Xeon and Xeon Phi processors and RH Linux.  I've also 
compared the performance of R built with the Intel compilers and Intel Math 
Kernel Library to a default build (no config options) that uses the GNU 
compilers.  To my dismay, I've found that the GNU build always runs on a single 
CPU core, even during matrix operations.  The Intel build runs matrix 
operations on multiple cores, so it is much faster on those operations.  
Running the benchmark-2.5 on a 24 core Xeon system, the Intel build is 13x 
faster than the GNU build (21 seconds vs 275 seconds).  Unfortunately, this 
advantage is not documented anywhere that I can see.

Building with the Intel tools is very easy.  Assuming the tools are installed 
in /opt/intel/composerxe, the process is simply (in bash shell):

$ . /opt/intel/composerxe/bin/compilervars.sh intel64
$ ./configure --with-blas=-L/opt/intel/composerxe/mkl/lib/intel64 
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm 
--with-lapack CC=icc CFLAGS=-O2 CXX=icpc CXXFLAGS=-O2 F77=ifort FFLAGS=-O2 
FC=ifort FCFLAGS=-O2
$ make
$ make check

My questions are:
1) Do most system admins and/or R installers know about this performance 
difference, and use the Intel tools to build R?
2) Can we add information on the advantage of building with the Intel tools, 
and how to do it, to the installation instructions and FAQ?

I can post my data if anyone is interested.

Thanks,
Jonathan Anspach
Sr. Software Engineer
Intel Corp.
jonathan.p.ansp...@intel.com
713-751-9460

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

2014-03-05 Thread Lucy Leigh

Hi everyone,
I am not new to R, but new to running survival models in R.

I am trying to create some basic KM curves, using the following code:


library(survival)
library(KMsurv)

(import data etc - basic right censored, with continuously observed time of 
death)

sleepfit - survfit(Surv(timeb, death), data = sleep)

Here timeb is measured is survival in years, death is a 1/0 indicator (1 = 
event = death), and the dataset is called sleep.


But I get the following error

Error in UseMethod(survfit, formula) :
  no applicable method for 'survfit' applied to an object of class Surv

I'm not sure what I'm doing wrong, as I followed the example from
the following paper 
http://anson.ucdavis.edu/~hiwang/teaching/10fall/R_tutorial%201.pdf , page 4 as 
a guide.



I also tried

sleepfit - survfit(Surv(timeb, death==1), data = sleep)

and

sleepfit - survfit(Surv(starttime, endtime, death), data = sleep)



Can anyone tell me what I might be doing wrong?
Thanks,
Lucy



[[alternative HTML version deleted]]

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


Re: [R] AIX 7.1 and R build problems

2014-03-05 Thread Prof Brian Ripley

Such questions belong on R-devel -- see the posting guide.

On 05/03/2014 22:28, Mike Beddo wrote:

Has anyone managed to build R-3.0.2 from source on AIX 7.1 using gcc 4.2.0. The 
configure script finishes with:

...
checking whether wctrans exists and is declared... no
checking whether iswblank exists and is declared... no
checking whether wctype exists and is declared... no
checking whether iswctype exists and is declared... no
configure: error: Support for MBCS locales is required.

Scanning through the config.log the configure script seems to be happy with the 
C99 compliance at hand. I have tried reading NEWS, README, and R-Help archives 
but I can't get past this. I'm all Google'd out. Is my compiler too old?


No (but it is old and possible it was built incorrectly).

Those functions are part of C99, and we have no idea why your compiler 
on your box is not finding them.  As your IT support for help.



_
Michael Beddo
Senior Scientist

Data Ventures, Inc.
1475 Central Ave. Suite 230  |  Los Alamos, NM 87544
tel  505.695.2132
http://www.dataventures.com  |  Advanced - Effective - Actionable - Proven. 
Analytics

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