Re: [R] what constitutes a 'complete sentence'?

2015-07-08 Thread peter dalgaard

On 07 Jul 2015, at 16:52 , Max Kuhn mxk...@gmail.com wrote:

 
 What are we trying to fix?
 
 

Two things, actually.

(1) An error message that sends the package developer on a wild goose chase, 
because it is both out of sync both with what is wanted, and what is checked 
for.
(2) The description in the WRE manual is somewhat self-contradicting, and could 
probably be improved.

To my mind, the tricky one is (1). (2) should be easier because there is space 
to elaborate.
(1) needs to be succinct, which is hard if there is no single term for what is 
being required. I'm beginning to think that the best we can do is along the 
lines of Malformed Description field: Missing end punctuation.. If more 
checks are devised, add more messages.
 
-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] valid LRT between MASS::polr and nnet::multinom

2015-07-08 Thread John Fox
Dear Steve,

The short answer is no, but the test you propose is in my experience usually 
a close approximation to a valid test.

The proportional-odds and multinomial-logistic regression models differ in two 
ways: the po model has an equal-coefficients (parallel-regressions) assumptions 
(except for intercepts) and so has fewer parameters; the po model models 
cumulative logits, while the mnl model models individual-category logits. As a 
consequence of the latter difference, the po model is not a specialization of 
the mnl model, as required by the LR test. A proper test of the po 
(equal-coefficients) assumption is to fit a cumulative-logit model with this 
constraint. You can do this with the vglm() function in the VGAM package using 
the cumulative family.

Here is an example:

-- snip -

 library(effects) # for WVS data
 library(nnet) # for multinom()
 library(MASS) # for polr()
 library(VGAM) # for vglm()
Loading required package: stats4
Loading required package: splines
 
 mod.polr - polr(poverty ~ gender + religion + degree + country*poly(age,3),
+data=WVS)
 coef(mod.polr)
 gendermale religionyes   
degreeyes 
  0.1691953   0.1684846   
0.1413380 
  countryNorway   countrySweden  
countryUSA 
 -0.3217821  -0.5732783   
0.6040006 
  poly(age, 3)1   poly(age, 3)2   poly(age, 
3)3 
 19.9101983 -10.2208416   
6.1157062 
countryNorway:poly(age, 3)1 countrySweden:poly(age, 3)1countryUSA:poly(age, 
3)1 
-17.0042706  -9.4160841   
1.5577738 
countryNorway:poly(age, 3)2 countrySweden:poly(age, 3)2countryUSA:poly(age, 
3)2 
 17.3824147  17.3856575  
10.1575695 
countryNorway:poly(age, 3)3 countrySweden:poly(age, 3)3countryUSA:poly(age, 
3)3 
  3.5181428   2.3652443  
-8.4004861 
 logLik(mod.polr)
'log Lik.' -5182.602 (df=20)
 
 mod.vglm.p - vgam(poverty ~ gender + religion + degree + country*poly(age,3),
+data=WVS, family=cumulative(parallel=TRUE)) 
 coef(mod.vglm.p) # same within rounding as polr except for sign
  (Intercept):1   (Intercept):2  
gendermale 
  0.2139034   2.0267774  
-0.1691716 
religionyes   degreeyes   
countryNorway 
 -0.1684541  -0.1413316   
0.3218158 
  countrySweden  countryUSA   poly(age, 
3)1 
  0.5733987  -0.6040348 
-19.9340368 
  poly(age, 3)2   poly(age, 3)3 countryNorway:poly(age, 
3)1 
 10.2120529  -6.1558215  
17.0535729 
countrySweden:poly(age, 3)1countryUSA:poly(age, 3)1 countryNorway:poly(age, 
3)2 
  9.4712722  -1.5238183 
-17.3344400 
countrySweden:poly(age, 3)2countryUSA:poly(age, 3)2 countryNorway:poly(age, 
3)3 
-17.3422095 -10.1469673  
-3.4087977 
countrySweden:poly(age, 3)3countryUSA:poly(age, 3)3 
 -2.2649306   8.4423869 
 logLik(mod.vglm.p) # same (within rounding error)
[1] -5182.601
 
 mod.multinom - multinom(poverty ~ gender + religion + degree + 
 country*poly(age,3),
+  data=WVS)
# weights:  60 (38 variable)
initial  value 5911.632725 
iter  10 value 5162.749080
iter  20 value 5007.247684
iter  30 value 4995.375350
iter  40 value 4989.909216
iter  50 value 4987.650806
iter  60 value 4987.190310
iter  70 value 4987.131548
iter  80 value 4987.075422
final  value 4987.073531 
converged
 logLik(mod.multinom)
'log Lik.' -4987.074 (df=38)
 length(coef(mod.multinom))
[1] 38
 
 mod.vglm.np - vgam(poverty ~ gender + religion + degree + 
 country*poly(age,3),
+data=WVS, family=cumulative(parallel=FALSE))
 logLik(mod.vglm.np) # close but not the same as multinom
[1] -4988.865
 length(coef(mod.vglm.np)) # same no. of coefs
[1] 38

 snip --

Best,
 John


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


On Wed, 8 Jul 2015 04:18:58 +
 Steve Taylor steve.tay...@aut.ac.nz wrote:
 Dear R-helpers,
 
 Does anyone know if the likelihoods calculated by these two packages are 
 comparable in this way?  
 
 That is, is this a valid likelihood ratio test?
 
 # Reproducable example:
 library(MASS)
 library(nnet)
 data(housing)
 polr1 = 

[R] R-project on App-V 5

2015-07-08 Thread Gilfred Tan

Hi

Here at Aberdeen Asset Management .  We are in the process of looking to move 
to a VDI environment (based on Win7) and are wanting to deploy the R-project 
via Microsoft App-V 5.  Based around this I have a series of technical queries 
regarding your application.

Firstly can I ask you to please provide me (or point me towards a download 
location) the current version of software, including an installation guide, and 
any updates / patches needed?

The company that is packaging our applications into the App-V environment have 
asked us the following questions (feel free to point me to the install guide 
where applicable on these queries):

  - are there any pre-requisites (such as Java for instance) or dependant 
applications?
  - is the app 32-bit or 64-bit?
  - is there any 16-bit code in the app?
  - is it compatible with Win7 64 bit?.
  - does is support RDSH (64bit XenApp 7.6)
  - does it support App-V 5?
  -  any other vendor technical support contact.
  - how are updates managed and what is their typical frequency?
  - Are there licensing details regarding the product, and if so please advise 
on how it is controlled / locked down.

Please come back to me with any questions you may have on my requests, 
otherwise thanks in advance for the assistance.

Regards

Gilfred Tan
Discovery Engineer
Aberdeen Asset Management Asia Limited (Reg. No. 199105448E)
Tel: +65 6395 2642
aberdeen-asset.comhttp://www.aberdeen-asset.com/
Find out how aspects of everyday life embody our philosophy at Aberdeen
simplyaberdeen.comhttp://www.simplyaberdeen.com


This email and any attachment are confidential and may contain privileged and 
copyright information. It is intended solely for the addressee. If you are not 
the intended recipient, please notify the sender immediately and delete this 
email. In accordance with good business practice and applicable regulations, 
all electronic communications with the Aberdeen Asset Management Group of 
companies may be monitored and retained. Aberdeen Asset Management PLC, Company 
Number: SC82015, Registered Office: Ten Queen's Terrace, Aberdeen AB10 1YG 
Scotland. 
For further information please visit our website: http://www.aberdeen-asset.com 
and www.aberdeen-asset.com/aam.nsf/AAM/privacy.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Jim Lemon
Hi Rosa,
As you are using base graphics, here is an example that might be of
use. As we don't have access to your data, I have used something
similar to the toy data in the example for the panes function. This
could be done better using the split.screen function, so let me know
if you would like an example using that.

 library(plotrix)
 # start a wide plotting device
 x11(width=10,height=4)
 y-runif(100)
 oldpar-panes(matrix(1:6,nrow=2,byrow=TRUE),widths=c(1,1,1.7))
 par(mar=c(0,2,1.8,0))
 boxplot(y,axes=FALSE)
 axis(2)
 box()
 par(mar=c(0,0,1.8,0))
 tab.title(Boxplot of y,tab.col=#88dd88,cex=1)
 y_hist-hist(y,axes=FALSE,breaks=seq(0,1,length.out=5))
 box()
 tab.title(Histogram of y,tab.col=#dd8800,cex=1)
 par(mar=c(0,0,1.8,12))
 pie(y_hist$counts,col=2:9)
 tab.title(Pie chart of y categories,tab.col=#dd,cex=1)
 box()
 par(mar=c(2,2,1.8,0))
 plot(y,xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 axis(2)
 box()
 tab.title(Scatterplot of y,tab.col=#aabbcc,cex=1)
 par(mar=c(2,0,1.8,0))
 plot(sort(y),xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 box()
 tab.title(Scatterplot of y sorted,tab.col=#ddbc44,cex=1)
 # center the title at the middle of the fifth plot
 mtext(Overall title of plot,side=1,line=0.8,cex=1.5)
 par(mar=c(2,0,1.8,12))
 plot(diff(y),xaxs=i,xlim=c(0,100),axes=FALSE,col=2:9)
 axis(4)
 box()
 tab.title(Scatterplot of diff(y),tab.col=#ff33cc,cex=1)
 legend(115,1.8,
  c(Boxplot,Histogram,Pie chart,Scatterplot,Sort,Diff),
  fill=c(#88dd88,#dd8800,#dd,#aabbcc,#ddbc44,#ff33cc),
  xpd=NA)

Jim




On Wed, Jul 8, 2015 at 1:05 PM, David Winsemius dwinsem...@comcast.net wrote:

 On Jul 7, 2015, at 2:45 PM, Rosa Oliveira wrote:

 Iam trying to plot 6 graphs in one single plot and I was able to, 
 nonetheless I wanted that all graphs had just 1 common legend, as the legend 
 is the same for all the 6 graphs and there is no sense in repeating it 6 
 times and even more, the legends in each graph sometimes don’t fit the graph.

 Is there a way to put just one legend for all the 6 graphs ate the same time?

 I was told to use a trellis graph, but after days of trying to do that I 
 wasn’t able to.

 Can anyone help me?


 library(ggplot2)
 library(reshape)


 library(lattice)

 Why did you load those packages above? As far as I can see you did not use 
 any lattice or ggplot2 functions. (Also see no reshape or reshape2 functions 
 in use.)

 par(mfrow=c(2,3))
 mse.alpha1 -read.csv(file=graphs_mse_alpha1.csv,head=TRUE,sep=,)

 And there you lose us. We are unable to see your data. The `legend` function 
 can put the legend anywhere. You may need to set par(xpd=TRUE) if the 
 location is outside the current plot area. If you wnated just one legend then 
 you mus ask yourself why you are issuing multiple legend calls. I see the 
 token-`legend` a total of 12 times in the code below.


 attach(mse.alpha1)
 names(mse1000.alpha1)
 mse.alpha2 -read.csv(file=graphs_mse_alpha2.csv,head=TRUE,sep=,)
 attach(mse.alpha2)
 names(mse.alpha2)
 nsample==50

 plot(mse.alpha1$lambda[mse.alpha1$nsample==50],
 mse.alpha1$mse.naive[mse.alpha1$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.RegCal[mse.alpha1$nsample==50],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.PL[mse.alpha1$nsample==50],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=50)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))

 plot(mse.alpha1$lambda[mse.alpha1$nsample==250],
 mse.alpha1$mse.naive[mse.alpha1$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.RegCal[mse.alpha1$nsample==250],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.PL[mse.alpha1$nsample==250],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=250)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))


 plot(mse.alpha1$lambda[mse.alpha1$nsample==1000],
 mse.alpha1$mse.naive[mse.alpha1$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample== 
 1000],mse.alpha1$mse.RegCal[mse.alpha1$nsample== 1000],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample== 
 1000],mse.alpha1$mse.PL[mse.alpha1$nsample== 1000],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=1000)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))

 plot(mse.alpha2$lambda[mse.alpha2$nsample==50],
 

Re: [R] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Rosa Oliveira
Dear Jim,

first of all, thank you very much :) 


can you please explain me how to use split.screen?

I’m felling so silly, I could not run your example because of 
x11(width=10,height=4). I already installed package XQuartz because X11 library 
was missing , nonetheless, after I have installed it, “ Error in 
.External2(C_X11, d$display, d$width, d$height, d$pointsize,  : 
  unable to start device X11
In addition: Warning message:
In x11(width = 10, height = 4) :
  unable to open connection to X11 display ‘' 


I didn’t started the x11 server on my mac ;) 

Now I got the graphs ;)

I attach my previous graphs and my data, so you can see :)









I’m very naive and new in R :(

Thanks again for your help ;)

Atenciosamente,
Rosa Oliveira
Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

Many admire, few know
Hippocrates

 On 08 Jul 2015, at 11:20, Jim Lemon drjimle...@gmail.com wrote:
 
 Hi Rosa,
 As you are using base graphics, here is an example that might be of
 use. As we don't have access to your data, I have used something
 similar to the toy data in the example for the panes function. This
 could be done better using the split.screen function, so let me know
 if you would like an example using that.
 
 library(plotrix)
 # start a wide plotting device
 x11(width=10,height=4)
 y-runif(100)
 oldpar-panes(matrix(1:6,nrow=2,byrow=TRUE),widths=c(1,1,1.7))
 par(mar=c(0,2,1.8,0))
 boxplot(y,axes=FALSE)
 axis(2)
 box()
 par(mar=c(0,0,1.8,0))
 tab.title(Boxplot of y,tab.col=#88dd88,cex=1)
 y_hist-hist(y,axes=FALSE,breaks=seq(0,1,length.out=5))
 box()
 tab.title(Histogram of y,tab.col=#dd8800,cex=1)
 par(mar=c(0,0,1.8,12))
 pie(y_hist$counts,col=2:9)
 tab.title(Pie chart of y categories,tab.col=#dd,cex=1)
 box()
 par(mar=c(2,2,1.8,0))
 plot(y,xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 axis(2)
 box()
 tab.title(Scatterplot of y,tab.col=#aabbcc,cex=1)
 par(mar=c(2,0,1.8,0))
 plot(sort(y),xaxs=i,xlim=c(0,101),axes=FALSE,col=2:9)
 box()
 tab.title(Scatterplot of y sorted,tab.col=#ddbc44,cex=1)
 # center the title at the middle of the fifth plot
 mtext(Overall title of plot,side=1,line=0.8,cex=1.5)
 par(mar=c(2,0,1.8,12))
 plot(diff(y),xaxs=i,xlim=c(0,100),axes=FALSE,col=2:9)
 axis(4)
 box()
 tab.title(Scatterplot of diff(y),tab.col=#ff33cc,cex=1)
 legend(115,1.8,
  c(Boxplot,Histogram,Pie chart,Scatterplot,Sort,Diff),
  fill=c(#88dd88,#dd8800,#dd,#aabbcc,#ddbc44,#ff33cc),
  xpd=NA)
 
 Jim
 
 
 
 
 On Wed, Jul 8, 2015 at 1:05 PM, David Winsemius dwinsem...@comcast.net 
 wrote:
 
 On Jul 7, 2015, at 2:45 PM, Rosa Oliveira wrote:
 
 Iam trying to plot 6 graphs in one single plot and I was able to, 
 nonetheless I wanted that all graphs had just 1 common legend, as the 
 legend is the same for all the 6 graphs and there is no sense in repeating 
 it 6 times and even more, the legends in each graph sometimes don’t fit the 
 graph.
 
 Is there a way to put just one legend for all the 6 graphs ate the same 
 time?
 
 I was told to use a trellis graph, but after days of trying to do that I 
 wasn’t able to.
 
 Can anyone help me?
 
 
 library(ggplot2)
 library(reshape)
 
 
 library(lattice)
 
 Why did you load those packages above? As far as I can see you did not use 
 any lattice or ggplot2 functions. (Also see no reshape or reshape2 functions 
 in use.)
 
 par(mfrow=c(2,3))
 mse.alpha1 -read.csv(file=graphs_mse_alpha1.csv,head=TRUE,sep=,)
 
 And there you lose us. We are unable to see your data. The `legend` function 
 can put the legend anywhere. You may need to set par(xpd=TRUE) if the 
 location is outside the current plot area. If you wnated just one legend 
 then you mus ask yourself why you are issuing multiple legend calls. I see 
 the token-`legend` a total of 12 times in the code below.
 
 
 attach(mse.alpha1)
 names(mse1000.alpha1)
 mse.alpha2 -read.csv(file=graphs_mse_alpha2.csv,head=TRUE,sep=,)
 attach(mse.alpha2)
 names(mse.alpha2)
 nsample==50
 
 plot(mse.alpha1$lambda[mse.alpha1$nsample==50],
 mse.alpha1$mse.naive[mse.alpha1$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4,
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 )
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.RegCal[mse.alpha1$nsample==50],col=2,lty=2)
 lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.PL[mse.alpha1$nsample==50],col=3,lty=3)
 title ( expression (paste (Mean squared error for , alpha[1])), 
 cex.main=1.5)
 title(\n\n sample size=50)
 legend(.7,1, legend= c(Naive, Regression Calibration, Pseudo 
 Likelihood), bty = n,col=c(4,2,3),lty=c(4,2,3))
 
 plot(mse.alpha1$lambda[mse.alpha1$nsample==250],
 mse.alpha1$mse.naive[mse.alpha1$nsample==250],
 

Re: [R] R-project on App-V 5

2015-07-08 Thread Bert Gunter
http://cran.r-project.org/

and do not post further to this list, please.


Bert Gunter

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
   -- Clifford Stoll


On Wed, Jul 8, 2015 at 2:43 AM, Gilfred Tan
gilfred@aberdeen-asset.com wrote:

 Hi

 Here at Aberdeen Asset Management .  We are in the process of looking to move 
 to a VDI environment (based on Win7) and are wanting to deploy the R-project 
 via Microsoft App-V 5.  Based around this I have a series of technical 
 queries regarding your application.

 Firstly can I ask you to please provide me (or point me towards a download 
 location) the current version of software, including an installation guide, 
 and any updates / patches needed?

 The company that is packaging our applications into the App-V environment 
 have asked us the following questions (feel free to point me to the install 
 guide where applicable on these queries):

   - are there any pre-requisites (such as Java for instance) or dependant 
 applications?
   - is the app 32-bit or 64-bit?
   - is there any 16-bit code in the app?
   - is it compatible with Win7 64 bit?.
   - does is support RDSH (64bit XenApp 7.6)
   - does it support App-V 5?
   -  any other vendor technical support contact.
   - how are updates managed and what is their typical frequency?
   - Are there licensing details regarding the product, and if so please 
 advise on how it is controlled / locked down.

 Please come back to me with any questions you may have on my requests, 
 otherwise thanks in advance for the assistance.

 Regards

 Gilfred Tan
 Discovery Engineer
 Aberdeen Asset Management Asia Limited (Reg. No. 199105448E)
 Tel: +65 6395 2642
 aberdeen-asset.comhttp://www.aberdeen-asset.com/
 Find out how aspects of everyday life embody our philosophy at Aberdeen
 simplyaberdeen.comhttp://www.simplyaberdeen.com


 This email and any attachment are confidential and may contain privileged and 
 copyright information. It is intended solely for the addressee. If you are 
 not the intended recipient, please notify the sender immediately and delete 
 this email. In accordance with good business practice and applicable 
 regulations, all electronic communications with the Aberdeen Asset Management 
 Group of companies may be monitored and retained. Aberdeen Asset Management 
 PLC, Company Number: SC82015, Registered Office: Ten Queen's Terrace, 
 Aberdeen AB10 1YG Scotland.
 For further information please visit our website: 
 http://www.aberdeen-asset.com and www.aberdeen-asset.com/aam.nsf/AAM/privacy.
 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Rosa Oliveira
Dear Jim,

first of all, thank you very much :) 


can you please explain me how to use split.screen?


I attach my previous graphs and my data, so you can see :)









I’m very naive and new in R :(

I really tried:

library(plotrix)
# start a wide plotting device
x11(width=10,height=4)
y-runif(100)
oldpar-panes(matrix(1:6,nrow=2,byrow=TRUE),widths=c(1,1,1.7))
par(mar=c(0,2,1.8,0))

mse - plot(mse.alpha1$lambda[mse.alpha1$nsample==50],
 mse.alpha1$mse.naive[mse.alpha1$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.RegCal[mse.alpha1$nsample==50],col=2,lty=2)
lines(mse.alpha1$lambda[mse.alpha1$nsample==50],mse.alpha1$mse.PL[mse.alpha1$nsample==50],col=3,lty=3)
tab.title(alpha 1 N sample=50,tab.col=#88dd88,cex=1)
# tab.title(\n\n sample size=50)
# problem: when I run: tab.title(Mean squared error for , 
paste(alpha[1])),tab.col=#88dd88,cex=1)
# I get an error message: unexpected string constant in tab.title(Mean 
squared error for , paste(alpha[1])),tab.col=
# I searched but wasn't able to fix this one, neither the other subtitle:
# tab.title(\n\n sample size=50)
box()


par(mar=c(0,0,1.8,0))
plot(mse.alpha1$lambda[mse.alpha1$nsample==250],
 mse.alpha1$mse.naive[mse.alpha1$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.RegCal[mse.alpha1$nsample==250],col=2,lty=2)
lines(mse.alpha1$lambda[mse.alpha1$nsample==250],mse.alpha1$mse.PL[mse.alpha1$nsample==250],col=3,lty=3)
tab.title ( alpha 1 N sample=250,tab.col=#dd8800,cex=1)
box()


plot(mse.alpha1$lambda[mse.alpha1$nsample==1000],
 mse.alpha1$mse.naive[mse.alpha1$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,1), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha1$lambda[mse.alpha1$nsample== 
1000],mse.alpha1$mse.RegCal[mse.alpha1$nsample== 1000],col=2,lty=2)
lines(mse.alpha1$lambda[mse.alpha1$nsample== 
1000],mse.alpha1$mse.PL[mse.alpha1$nsample== 1000],col=3,lty=3)
tab.title(alpha 1 N sample=1000,tab.col=#dd,cex=1)
box()



par(mar=c(2,2,1.8,0))
plot(mse.alpha2$lambda[mse.alpha2$nsample==50],
 mse.alpha2$mse.naive[mse.alpha2$nsample==50],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha2$lambda[mse.alpha2$nsample==50],mse.alpha2$mse.RegCal[mse.alpha2$nsample==50],col=2,lty=2)
lines(mse.alpha2$lambda[mse.alpha2$nsample==50],mse.alpha2$mse.PL[mse.alpha2$nsample==50],col=3,lty=3)
box()
tab.title(alpha 2 N sample=50,tab.col=#aabbcc,cex=1)

par(mar=c(2,0,1.8,0))
plot(mse.alpha2$lambda[mse.alpha2$nsample==250],
 mse.alpha2$mse.naive[mse.alpha2$nsample==250],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha2$lambda[mse.alpha2$nsample==250],mse.alpha2$mse.RegCal[mse.alpha2$nsample==250],col=2,lty=2)
lines(mse.alpha2$lambda[mse.alpha2$nsample==250],mse.alpha2$mse.PL[mse.alpha2$nsample==250],col=3,lty=3)
box()
tab.title(alpha 2 N sample=250,tab.col=#ddbc44,cex=1)


# center the title at the middle of the fifth plot
mtext(Mean Squared Error,side=1,line=0.8,cex=1.5)


par(mar=c(2,0,1.8,12))
plot(mse.alpha2$lambda[mse.alpha2$nsample==1000],
 mse.alpha2$mse.naive[mse.alpha2$nsample== 1000],
 xlab=expression(paste(lambda)),ylab=MSE,type=l,col=4,lty=4, 
 xlim=c(.6,1), ylim=c(0,.17), cex.lab=1.5
 #,main=yaxs default
)
lines(mse.alpha2$lambda[mse.alpha2$nsample== 
1000],mse.alpha2$mse.RegCal[mse.alpha2$nsample==250],col=2,lty=2)
lines(mse.alpha2$lambda[mse.alpha2$nsample== 
1000],mse.alpha2$mse.PL[mse.alpha2$nsample== 1000],col=3,lty=3)
box()
tab.title(alpha 2 N sample=1000,tab.col=#ff33cc,cex=1)

legend(115,1.8,
   c(alpha 1 N sample=50,alpha 1 N sample=250,alpha 1 N sample=1000,
 alpha 2 N sample=50,alpha 2 N sample=250,alpha 2 N sample=1000),
   fill=c(#88dd88,#dd8800,#dd,#aabbcc,#ddbc44,#ff33cc),
   xpd=NA)


legend(115,1.8,
   c(Naive, Regression Calibration, Pseudo Likelihood), 
   bty = n,col=c(4,2,3),lty=c(4,2,3),
   xpd=NA)



and I got:








Thanks again for your help ;)

Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

Many admire, few know
Hippocrates

 On 08 Jul 2015, at 11:35, Dennis Murphy djmu...@gmail.com wrote:
 
 Hi:
 
 The general process for doing this kind of thing in either ggplot2 or
 lattice 

Re: [R] Hypergeometric Function seems to give wrong results

2015-07-08 Thread Ben Bolker
Carlos Nasher via R-help r-help at r-project.org writes:



[snip]

 I need to evaluate the Hypergeometric Function of the 2nd kind (Tricomi
 confluent hypergeometric function). Therefore I'm using the kummerU
 function from the fAsianOptions package. It seems to me that kummerU is
 giving wrong results. Here's an example:
 
 library(fAsianOptions)
 kummerU(a=19, b=19, x = 10)
 
 R gives 1838.298 for the real part.
 
 If I use Mathematica via the wolfram site (
 http://functions.wolfram.com/webMathematica
   /FunctionEvaluation.jsp?name=HypergeometricU)
 the result is 3.52603e-20 which is more reasonable in the context of my
 analysis.
 

 [snip]

  Your best bet is probably to contact the package maintainer
(use maintainer(fAsianOptions) to see who it is, or look on 
the CRAN page for the package).  If this functionality is very
commonly used in finance you might try the r-sig-finance mailing
list (indicating that you've already tried here).

  good luck
Ben Bolker

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] multiple graphs with a single legend and trellis graph

2015-07-08 Thread Rosa Oliveira
Dear Jim,

first of all, thank you very much :) 
when I run the code:

myDF - rbind(mse.alpha1, mse.alpha2)  # assumes both data frames have the same 
variables in the same order


myDF$ID - factor(rep(c(alpha1, alpha2), times =
c(nrow(mse.alpha1), nrow(mse.alpha2))) )   


library(reshape2)
myDF.melt - melt(myDF, id = c(ID, nsample, lambda), measure =
c(mse.naive, mse.RegCal, mse.PL))  #Melt the three columns to be plotted, 
something like

library(ggplot2)
ggplot(myDF.melt, aes(x = lambda, y = value, color = variable)) +
   geom_point() + geom_line() +
   facet_grid(ID ~ nsample) +
   labs(x = expression(paste(lambda)), y = MSE, color = Type”)



 I get the attached graph. I also attach my data, so you can see :)

I’m I able to resize the graphs differently? I.e. for alpha1: ylim=ylim=c(0,.6) 
and for alpha2: ylim=c(0,.17)? 
I reshaped, a new variable in sample was created, NA, Was it me that made 
something wrong?

I’m very naive and new in R :(

Thanks again ;)







Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

Many admire, few know
Hippocrates

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

Re: [R] add a special column to a matrix

2015-07-08 Thread Jim Lemon
Hi Lida,
I think what you want is:

mat1-read.table(text=abc d
fg1:23   dfgv   5
pt10:18 tgtgh  1
wq   15:123oiljk   6
fg 9:1323ass   4
yr 12:123kjjlk   5,header=TRUE)

mat2-read.table(text=b q
 1:23  0
 10:18 1
 14:4552
 15:1232
 9:13232
 12:1231
 5:15480,header=TRUE)

merge(mat1,mat2,by=b)

You don't seem to have a column name for the first column in mat2, so
I have added one. If it is different from mat1, you will have to use a
slightly different b argument.

Jim

On Wed, Jul 8, 2015 at 4:06 PM, PIKAL Petr petr.pi...@precheza.cz wrote:
 Hi

 See answers in line

 From: Lida Zeighami [mailto:lid.z...@gmail.com]
 Sent: Tuesday, July 07, 2015 10:20 PM
 To: PIKAL Petr
 Subject: Re: [R] add a special column to a matrix


 Hi Petr,

 Thanks, I can solve it!
 On Jul 7, 2015 11:05 AM, Lida Zeighami 
 lid.z...@gmail.commailto:lid.z...@gmail.com wrote:
 Hi Petr,

 Thank you so much for replying!
 I have two problems:


 1.  I couldn't understand what you mean No HTML posting , would you 
 please explain more about that?

 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.


 2. still my problem hasn't been solved! I don't want to add the columns and 
 rows of two matrices together!
 just I want  to add the q column from mat2 to mat1  ( column b in mat1 and 
 the rownames in mat1 are the same but not in a same order! )

 I should keep the mat1 and just add the value of rownames of mat2 to the 
 equivalent elements in column b( I should add column q from mat2 to mat1 
 regarding the column b)


 Did you try read help page of merge command?

 Did you even try merge? If yes please describe what you do not like about it.

 merge(mat1, mat2, all.x=TRUE)

 shall take all lines of mat1 and add corresponding columns of mat2 to 
 appropriate rows.

 However we do not know anything about your data. From your posting it seems 
 to me that

 dim(mat1) results in c(n,4) and dim(mat2) results in (n,1) and what do you 
 consider as a column in mat2 are row names. In that case you need to add a 
 column of row names, maybe

 mat2$b - rownames(mat2)

 before calling merge

 Cheers
 Petr



 head(mat1)
 a   b c   d
 fg1:23   dfgv   5
 pt10:18 tgtgh  1
 wq   15:123oiljk   6
 fg 9:1323ass   4
 yr 12:123kjjlk   5

 my second matrix:
 head(mat2)
  q
   1:23 0
10:18   1
   14:455  2
15:123 2
 9:13232
 12:1231
  5:15480

 output should be :
 head(mat)
 a   b c   d q
 fg1:23   dfgv   50
 pt10:18 tgtgh  11
 wq   15:123oiljk   62
 fg 9:1323ass   42
 yr 12:123kjjlk   51

 Thanks again,
 Lida

 On Tue, Jul 7, 2015 at 9:53 AM, PIKAL Petr 
 petr.pi...@precheza.czmailto:petr.pi...@precheza.cz wrote:
 Hi

 No HTML posting please, sometimes the mail is unreadable

 It is a work for merge.

 mat3 - merge(mat1, mat2, all=TRUE)

 shall do the trick (untested)

 Cheers
 Petr


 -Original Message-
 From: R-help 
 [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] 
 On Behalf Of Lida
 Zeighami
 Sent: Tuesday, July 07, 2015 4:43 PM
 To: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: [R] add a special column to a matrix

 Hi there,

 I have a two matrices which they have a common column! I want to add
 the a column of second to matrix to the equivalent column of first
 matrix!
 my first matrix is
 head(mat1)
 a   b c   d
 fg1:23   dfgv   5
 pt10:18 tgtgh  1
 wq   15:123oiljk   6
 fg 9:1323ass   4
 yr 12:123kjjlk   5

 my second matrix:
 head(mat2)
eq
   1:23 0
10:18   1
   14:455  2
15:123 2
 9:13232
 12:1231
  5:15480

 mat1 and mat2 have a common column (b and e) but is not in the same
 order, I want to add the q column from mat2 to be added to mat1 my
 output will be:

 head(mat)
 a   b c   d q
 fg1:23   dfgv   50
 pt10:18 tgtgh  11
 wq   15:123oiljk   62
 fg 9:1323ass   42
 yr 12:123kjjlk   51

 would you please let me know how to do it?

 Thanks

   [[alternative HTML version deleted]]

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

 

Re: [R] R-project on App-V 5

2015-07-08 Thread Thierry Onkelinx
Please do read the posting guide (
http://www.R-project.org/posting-guide.html
http://www.r-project.org/posting-guide.html). It points to the FAQ which
answers much of your questions (http://cran.r-project.org/faqs.html).

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie  Kwaliteitszorg / team Biometrics  Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-07-08 11:43 GMT+02:00 Gilfred Tan gilfred@aberdeen-asset.com:


 Hi

 Here at Aberdeen Asset Management .  We are in the process of looking to
 move to a VDI environment (based on Win7) and are wanting to deploy the
 R-project via Microsoft App-V 5.  Based around this I have a series of
 technical queries regarding your application.

 Firstly can I ask you to please provide me (or point me towards a download
 location) the current version of software, including an installation guide,
 and any updates / patches needed?

 The company that is packaging our applications into the App-V environment
 have asked us the following questions (feel free to point me to the install
 guide where applicable on these queries):

   - are there any pre-requisites (such as Java for instance) or dependant
 applications?
   - is the app 32-bit or 64-bit?
   - is there any 16-bit code in the app?
   - is it compatible with Win7 64 bit?.
   - does is support RDSH (64bit XenApp 7.6)
   - does it support App-V 5?
   -  any other vendor technical support contact.
   - how are updates managed and what is their typical frequency?
   - Are there licensing details regarding the product, and if so please
 advise on how it is controlled / locked down.

 Please come back to me with any questions you may have on my requests,
 otherwise thanks in advance for the assistance.

 Regards

 Gilfred Tan
 Discovery Engineer
 Aberdeen Asset Management Asia Limited (Reg. No. 199105448E)
 Tel: +65 6395 2642
 aberdeen-asset.comhttp://www.aberdeen-asset.com/
 Find out how aspects of everyday life embody our philosophy at Aberdeen
 simplyaberdeen.comhttp://www.simplyaberdeen.com


 This email and any attachment are confidential and may contain privileged
 and copyright information. It is intended solely for the addressee. If you
 are not the intended recipient, please notify the sender immediately and
 delete this email. In accordance with good business practice and applicable
 regulations, all electronic communications with the Aberdeen Asset
 Management Group of companies may be monitored and retained. Aberdeen Asset
 Management PLC, Company Number: SC82015, Registered Office: Ten Queen's
 Terrace, Aberdeen AB10 1YG Scotland.
 For further information please visit our website:
 http://www.aberdeen-asset.com and
 www.aberdeen-asset.com/aam.nsf/AAM/privacy.
 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] lattice::subscripts[?] usage question

2015-07-08 Thread Szumiloski, John
Dear useRs,

I have a question regarding panel functions in the lattice package, in 
particular how to customize the plotting colors in xyplot.

I have longitudinal data from several treatments (TRT) with subjects (SUBJ) 
nested in treatment.  Each subject has several time points; the time points are 
nearly balanced across subjects, although not completely.  At each sample 
(SAMP) at each time point (TIME), two replicates (REP) are taken.   Let's call 
the response Y and the whole data.frame DAT.

My goal is to make a trellis plot with each treatment in its own panel, each 
subject having its own color and lines connecting the REPs within SAMP (after 
adding jitter along the TIME axis to distinguish SUBJs).  Let me switch over to 
an explicit example with artificial data.

   set.seed(695442223)

   DAT - data.frame(TRT=factor(rep(c(Trt1,Trt2), each=12)),  # 
2 treatments
 SUBJ=factor(paste('subj', rep(seq(4), each=6), sep='')), # 
4 subjects, 2 w/in each TRT
 SAMP=factor(rep(seq(12), each=2)),   # 
4x3 = 12 samples
 REP=factor(c(1,2)),  # 
2 replicates
 TIME=rep(c(4,4,8,8,12,12), times=4), # 
3 arbitrary times
 Y=round(rep(rgamma(n=12, shape=47500, scale=1/500), 
each=2) +
  rep(rgamma(n=12, shape=4, scale=1/8), each=2) * 
c(-1,1),
 2)   # arbitrary Y but very easy to view
   )

   DAT - transform(DAT,
   # horizontal jitter
plotX=TIME+ifelse(SUBJ %in% c(subj1,subj3), -1,1)/10,
   # unique plotting color for each subject
COLS=factor(c( green, black, blue, 
red))[as.numeric(SUBJ)]
   )

The canonical example is:

xyplot(Y ~ plotX | TRT, data = DAT, groups = SAMP, type=b)

Of course, this connects the REPs within SAMP, since SAMP is the groups 
variable.  But each SAMP is now independently colored, recycled from (if I 
understand correctly)  trellis.par.get('superpose.symbol/line')$col, instead 
of each SUBJ being independently colored from the COLS variable.

In Section 5.2 in Deepayan Sarkar's Lattice: Multivariate Data Visualization 
with R (Springer 2008), the suggestion in Section 5.2 is to use a panel 
function which gets passed an explicit subscripts argument, to distinguish 
the groups indexing from the color indexing.  Starting with the book's code to 
plot Figure 5.4, I hacked around to get this:

xyplot(Y ~ plotX | TRT, data = DAT, groups = SAMP, type=b,
  # the full vector of colors
  cols = DAT[['COLS']],
  panel = function(x, y, ..., cols, groups, subscripts) {
   colSUBJ - cols[subscripts]
   panel.xyplot(x, y, groups=groups, 
subscripts=subscripts,
..., col.line=colSUBJ, 
col.symbol=colSUBJ)
  }
 )


Now this gets each treatment TRT with its own color, but not each subject SUBJ. 
 I am indeed not exactly sure what this code does specifically, with the 
subscripts argument.  But nearly every other permutation of arguments I could 
think off either gave a totally wrong plot, or an error.

How do I write a panel function to join reps in the same sample with the groups 
argument, but give each subject a unique color? (an alternate chore is to use 
only unique colors within each treatment, or repeating colors in different 
treatments).  And what is a good pointer or two to good resources explaining 
the use of the subscripts argument in panel functions?  Sarkar's book is 
fantastic but its treatment of this issue is quite thin.

Thanks,
John Szumiloski

John Szumiloski, Ph.D.
Principal Scientist, Statistician
Analytical and Bioanalytical Development
NBR105-1-1411

Bristol-Myers Squibb
P.O. Box 191
1 Squibb Drive
New Brunswick, NJ
08903-0191

(732) 227-7167






 This message (including any attachments) may contain co...{{dropped:8}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Crear un GUI para R con tcltk

2015-07-08 Thread Fernando Macedo
No opinaré sobre el código puesto que no lo leí. Pero comentar que en 
particular he tenido problemas copiando datos desde excel, en general me 
resulta mejor copiarlos de excel, pegarlos en un editor de texto 
cualquiera y luego copiarlos a R. Por que? Ni idea, como lo he usado 
puntualmente no me he puesto a profundizar en el tema, pero he tenido 
ese problema.

Saludos

DMTV Fernando Macedo
Ayudante del área Mejoramiento Genético
Facultad de Veterinaria - UdelarR - Uruguay
Tel: 26284291
Cel.: 098596947
ferm...@gmail.com

El 08/07/15 a las 09:54, Jesús Para Fernández escribió:
 BUenas,

 Quiero crear un GUI muy simple, el cual consiste en una ventana, que al 
 abrirse tiene dos botones. El primer boton, copiar, es un boton que ejecutar�a

 datos-read.table(clipboard,header=T,dec=,,sep=\t)

 Y el segundo boton muestra todos los data.frames que hay en R

 Para ello, estoy usando tcltk, por lo que hago lo siguiente:

 require(tcltk)
 tt - tktoplevel()
 tktitle(tt) - Mi primer programa

 # Create a variable to keep track of the state of the dialog window:
 #  If the window is active,done =  0
 #  If the window has been closed using the OK button,  done = 
 1
 #  If the window has been closed using the Cancel button or destroyed, done = 
 2
 done - tclVar(0)   # tclVar() creates a Tcl variable

 # Create two buttons and for each one, set the value of the done variable
 # to an appropriate value
 OK.but - tkbutton(tt, text =   OK  ,
  command = function() tclvalue(done) - 1)
 Cancel.but - tkbutton(tt, text = Cancel,
  command = function() tclvalue(done) - 2)

 # Place the two buttons on the same row in their assigned window (tt)
 tkgrid(OK.but, Cancel.but)

 # Capture the event Destroy (e.g. Alt-F4 in Windows) and when this happens,
 # assign 2 to done
 tkbind(tt, Destroy, function() tclvalue(done) - 2)

 tkfocus(tt) # Place the focus to our tk window

 # Do not proceed with the following code until the variable done is non-zero.
 # (but other processes can still run, i.e., the system is not frozen)
 tkwait.variable(done)

 # The variable done is now non-zero, so we would like to record its value 
 before
 # destroying the window tt.  If we destroy it first, then done will be set to 
 2
 # because of our earlier binding, but we want to determine whether the user
 # pressed OK (i.e., see whether done is equal to 1)

 doneVal - as.integer(tclvalue(done))   # Get and coerce content of a Tcl 
 variable
 tkdestroy(tt)

 # Test the result
 if (doneVal == 1) {
 datos-read.table(clipboard,header=T,dec=,,sep=\t)
 }
 if (doneVal == 2) {
 ls()
 }


 Esto funciona al crearlo en el script de R, pero el poortapapeles no me copia 
 las celdas de excel, sino todo el c�digo anterior.

 Podeis echarme una mano??

 Gracias!!!
   
   [[alternative HTML version deleted]]



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


[[alternative HTML version deleted]]

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


[R] select a subset of a matrix which one of its column meet a condition

2015-07-08 Thread Lida Zeighami
Hi there,

I have a matrix and I want to get a subset from that which one of its
matrix meet a condition,

my matrix is
met
 Row.names Name
maf   caf
1 10:13915  10:139  0.0003782148
0.0003782148
2 10:18738  10:18738   0.0003759398
 0.0003759398
3 10:100011321  10:100011321   0.0003762227
 0.0003762227
4 10:100012219  10:100012219   0.0007518797
0.0007518797
5 10:100013325  10:100013325  0.00
 0.00
6 10:100015404  10:100015404  0.00
0.00

I want to choose a subset from met which maf values are between 0 and
0.05 (0,0.05)

I wrote this code, but seem doesn't work properly:

 maf- met[which(c(met[,5]) %in% c(0,0.05)),]

the dim(maf)  is 0 so seems my code didn't work!
would please let me know how to correct it?

Thanks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] select a subset of a matrix which one of its column meet a condition

2015-07-08 Thread Rui Barradas

Hello,

Your matrix has only 4 columns but you refer to met[,5]. I'll assume 
you're refering to the last column, met[,4]. Try reading the help page 
for ?%in%, it doesn't do what you seem to think it does. And try using =.


maf - met[0 = met[, 4]  met[, 4] = 0.05, ]

Hope this helps,

Rui Barradas

Em 08-07-2015 16:37, Lida Zeighami escreveu:

Hi there,

I have a matrix and I want to get a subset from that which one of its
matrix meet a condition,

my matrix is
met
  Row.names Name
maf   caf
1 10:13915  10:139  0.0003782148
0.0003782148
2 10:18738  10:18738   0.0003759398
  0.0003759398
3 10:100011321  10:100011321   0.0003762227
  0.0003762227
4 10:100012219  10:100012219   0.0007518797
0.0007518797
5 10:100013325  10:100013325  0.00
  0.00
6 10:100015404  10:100015404  0.00
0.00

I want to choose a subset from met which maf values are between 0 and
0.05 (0,0.05)

I wrote this code, but seem doesn't work properly:


maf- met[which(c(met[,5]) %in% c(0,0.05)),]


the dim(maf)  is 0 so seems my code didn't work!
would please let me know how to correct it?

Thanks

[[alternative HTML version deleted]]

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


Re: [R] How to assign value to a variable dynamically constructed

2015-07-08 Thread William Dunlap
You can use an environment instead of a list using the same [[ syntax.  It
is like 'get0(..., inherit=FALSE)' on the left side of the - and like
'assign(...)' on the right side.   E.g.,
   myData - new.env()
   varName - v1
   myData[[varName]] - 1:10
   myData[[varName]][4] - myData[[varName]][4] * 100
   myData[[varName]]
   #  [1]   1   2   3 400   5   6   7   8   9  10
   names(myData)
   # [1] v1
(Before R-3.2.0 or so, you had to use objects(myData,all=TRUE) if
myData was an environment and names(myData) if it was a list.  Now
names() works for environments.)

It is better to use a dedicated environment (or list) for each set of
related
variables so that name collisions do not cause problems.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jul 8, 2015 at 10:06 AM, Greg Snow 538...@gmail.com wrote:

 This is FAQ 7.21.

 The most important part of the answer in FAQ 7.21 is the last section
 where it states that it is often easier to use a list rather than
 messing around with trying to dynamically name global variables.

 If you tell us what you are trying to accomplish then we may have
 better advice.  The route you are headed down now usually leads to
 inefficient code and hard to find bugs.

 On Tue, Jul 7, 2015 at 2:53 PM, Jun Shen jun.shen...@gmail.com wrote:
  Dear list,
 
  Let's say we have a variable (id), whose name is dynamically constructed.
  This variable represents a vector or data frame with many elements. Now I
  want to specifically assign a value to one of the elements. I couldn't
 get
  it right.
 
  test - 'id' # id is dynamically constructed through paste()
 
  id - 1:4
 
  # I can get the element by doing
 
  get(test)[2]
 
  # Now I want to assign a value to the second element of this dynamical
  variable.
 
  get(test)[2] - 5  # doesn't work.
 
  Thanks a lot.
 
  Jun Shen
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.



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

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


Re: [R] How to assign value to a variable dynamically constructed

2015-07-08 Thread Greg Snow
This is FAQ 7.21.

The most important part of the answer in FAQ 7.21 is the last section
where it states that it is often easier to use a list rather than
messing around with trying to dynamically name global variables.

If you tell us what you are trying to accomplish then we may have
better advice.  The route you are headed down now usually leads to
inefficient code and hard to find bugs.

On Tue, Jul 7, 2015 at 2:53 PM, Jun Shen jun.shen...@gmail.com wrote:
 Dear list,

 Let's say we have a variable (id), whose name is dynamically constructed.
 This variable represents a vector or data frame with many elements. Now I
 want to specifically assign a value to one of the elements. I couldn't get
 it right.

 test - 'id' # id is dynamically constructed through paste()

 id - 1:4

 # I can get the element by doing

 get(test)[2]

 # Now I want to assign a value to the second element of this dynamical
 variable.

 get(test)[2] - 5  # doesn't work.

 Thanks a lot.

 Jun Shen

 [[alternative HTML version deleted]]

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



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

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Maxent Jarfile

2015-07-08 Thread Annemarie Fischer
Hi,
I have been trying to solve the below problem for 2 days with no success. 
Hopefully you can help as i can find no assistance online.
I am attempting to run the niche.equivalency.test and the bg.similarity.test 
using RStudio and Maxent. I keep getting the error:
Error: Unable to access jarfile C:/ProgramError in file(fname, r) : cannot 
open the connectionIn addition: Warning messages:1: running command 'java -jar 
C:/Program Files/R/R-3.1.3/library/dismo/java/maxent.jar -e  
R.phyloclim.temp/background.csv -s  R.phyloclim.temp/samples.csv -j  
R.phyloclim.temp/proj/ -o  R.phyloclim.temp/out/  -r removeduplicates 
nopictures autorun' had status 1 2: In file(fname, r) :  cannot open file 
'R.phyloclim.temp/out/Rhinolophus blasii_proj.asc': No such file or directory
I suspect the issue is that the file directory doesnt have , but i have no 
idea how to add these in, as in RStudio values, the  does appear.
My code is:
# load required 
packageslibrary(raster)library(mgcv)library(dismo)library(rgdal)library(ellipse)library(sp)library(proj4)library(rgeos)
library(rJava)library(maptools)library(rasterVis)library(phyloclim)
# path to MAXENT# --maxent.exe - 
paste(system.file(package=dismo), /java/maxent.jar, sep 
= )
# a data frame of coordinates where two species # have been detected ('presence 
points') and# a raster stack of environmental covariables# 
--
###Change to correct species usedfile - paste(system.file(package=dismo), 
/ex/Rhinolophus_species.csv, sep=)# this is the file we will use:file
#save(file, file=Molossidae_rarefied_points.rda)
#data()#data(package = .packages(all.available = TRUE))
#myData - read.csv(file, header=TRUE, nrows=1)
Rhinolophus_species - read.table(file, header=TRUE, sep=',')
species - c(Rhinolophus blasii, Rhinolophus clivosus)#data(sites)samples 
- Rhinolophus_species[grep(paste(species, collapse = |), 
Rhinolophus_species$Spp), ]data.path - system.file(extdata, package = 
phyloclim)preds - list.files(path = data.path, pattern = [.]asc)preds - 
paste(data.path, preds, sep = /)preds - stack(lapply(X = preds, FUN = 
raster))
# testing against 9 permutations of the data# 
---reps - 1000
# run hypothesis tests# if (file.exists(maxent.exe)){  net 
- niche.equivalency.test(samples, preds, reps, maxent.exe)  net; plot(net)  
bst - bg.similarity.test(samples, preds, reps, app = maxent.exe)  bst; 
plot(bst)} else {  message(get a copy of MAXENT (see Details))}   
  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] norm's book

2015-07-08 Thread Mark Leeds
Hi All: In case anyone is interested,  Norm's new book, parallel computing
for data science is out on amazon.  It already got raving reviews from
Dave Giles  who runs a popular econometrics blog.


Mark

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Lectura de ficheros externos

2015-07-08 Thread Gloria Perez Fuentes
Tengo un fichero Excel con datos numericos con comas (Ej:6,4523). Tengo que
trabajar con dichos datos en R. Como puedo hacerlo?

[[alternative HTML version deleted]]

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


Re: [R] Maxent Jarfile

2015-07-08 Thread John Kane
Hi Annemarie,
You have sent the email in HTML and it is very close to  unreadable. Could you 
please resubmit the message in plain text.  R-help does not accept HTML and, as 
happened here, the text gets seriously mangled.



John Kane
Kingston ON Canada


 -Original Message-
 From: annemarie...@hotmail.com
 Sent: Wed, 8 Jul 2015 20:22:57 +
 To: r-help@r-project.org
 Subject: [R] Maxent Jarfile
 
 Hi,
 I have been trying to solve the below problem for 2 days with no success.
 Hopefully you can help as i can find no assistance online.
 I am attempting to run the niche.equivalency.test and the
 bg.similarity.test using RStudio and Maxent. I keep getting the error:
 Error: Unable to access jarfile C:/ProgramError in file(fname, r) :
 cannot open the connectionIn addition: Warning messages:1: running
 command 'java -jar C:/Program
 Files/R/R-3.1.3/library/dismo/java/maxent.jar -e
 R.phyloclim.temp/background.csv -s  R.phyloclim.temp/samples.csv -j
 R.phyloclim.temp/proj/ -o  R.phyloclim.temp/out/  -r removeduplicates
 nopictures autorun' had status 1 2: In file(fname, r) :  cannot open
 file 'R.phyloclim.temp/out/Rhinolophus blasii_proj.asc': No such file or
 directory
 I suspect the issue is that the file directory doesnt have , but i have
 no idea how to add these in, as in RStudio values, the  does appear.
 My code is:
 # load required
packageslibrary(raster)library(mgcv)library(dismo)library(rgdal)library(ellipse)library(sp)library(proj4)library(rgeos)
 library(rJava)library(maptools)library(rasterVis)library(phyloclim)
 # path to MAXENT# --maxent.exe -
 paste(system.file(package=dismo),
 /java/maxent.jar, sep = )
 # a data frame of coordinates where two species # have been detected
 ('presence points') and# a raster stack of environmental covariables#
 --
 ###Change to correct species usedfile -
 paste(system.file(package=dismo), /ex/Rhinolophus_species.csv,
 sep=)# this is the file we will use:file
 #save(file, file=Molossidae_rarefied_points.rda)
 #data()#data(package = .packages(all.available = TRUE))
 #myData - read.csv(file, header=TRUE, nrows=1)
 Rhinolophus_species - read.table(file, header=TRUE, sep=',')
 species - c(Rhinolophus blasii, Rhinolophus
 clivosus)#data(sites)samples - Rhinolophus_species[grep(paste(species,
 collapse = |), Rhinolophus_species$Spp), ]data.path -
 system.file(extdata, package = phyloclim)preds - list.files(path =
 data.path, pattern = [.]asc)preds - paste(data.path, preds, sep =
 /)preds - stack(lapply(X = preds, FUN = raster))
 # testing against 9 permutations of the data#
 ---reps - 1000
 # run hypothesis tests# if (file.exists(maxent.exe)){
 net - niche.equivalency.test(samples, preds, reps, maxent.exe)  net;
 plot(net)  bst - bg.similarity.test(samples, preds, reps, app =
 maxent.exe)  bst; plot(bst)} else {  message(get a copy of MAXENT (see
 Details))}
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] multiple graphs with a single legend and trellis graph

2015-07-08 Thread John Kane
Hi Rosa,
Neither the graph nor the data arrived.  R-help can be very fussy about what 
attached files it will accept. Usually pdf, txt and png, I think, will come 
through.

In any case it is much better to supply data using the dput() function See 
?dput or have a look at 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
 and http://adv-r.had.co.nz/Reproducibility.html for how to do this.

It is best to use dput() rather than supplying a data file because dput() 
ensures that we get an exact copy of the data as it exists on your computer.  
There is no real guarantee that I will read in a data file the same way as you 
have.



John Kane
Kingston ON Canada


 -Original Message-
 From: rosit...@gmail.com
 Sent: Wed, 8 Jul 2015 13:11:34 +0100
 To: djmu...@gmail.com, drjimle...@gmail.com, r-help@r-project.org
 Subject: Re: [R] multiple graphs with a single legend and trellis graph
 
 Dear Jim,
 
 first of all, thank you very much :)
 when I run the code:
 
 myDF - rbind(mse.alpha1, mse.alpha2)  # assumes both data frames have
 the same variables in the same order
 
 
 myDF$ID - factor(rep(c(alpha1, alpha2), times =
 c(nrow(mse.alpha1), nrow(mse.alpha2))) )
 
 
 library(reshape2)
 myDF.melt - melt(myDF, id = c(ID, nsample, lambda), measure =
 c(mse.naive, mse.RegCal, mse.PL))  #Melt the three columns to be
 plotted, something like
 
 library(ggplot2)
 ggplot(myDF.melt, aes(x = lambda, y = value, color = variable)) +
geom_point() + geom_line() +
facet_grid(ID ~ nsample) +
labs(x = expression(paste(lambda)), y = MSE, color = Type”)
 
 
 
  I get the attached graph. I also attach my data, so you can see :)
 
 I’m I able to resize the graphs differently? I.e. for alpha1:
 ylim=ylim=c(0,.6) and for alpha2: ylim=c(0,.17)?
 I reshaped, a new variable in sample was created, NA, Was it me that made
 something wrong?
 
 I’m very naive and new in R :(
 
 Thanks again ;)
 
 
 
 
 
 
 
 Atenciosamente,
 Rosa Oliveira
 
 --
 
 
 
 Rosa Celeste dos Santos Oliveira,
 
 E-mail: rosit...@gmail.com
 Tlm: +351 939355143
 Linkedin: https://pt.linkedin.com/in/rosacsoliveira
 
 Many admire, few know
 Hippocrates
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

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

Re: [R] add a special column to a matrix

2015-07-08 Thread PIKAL Petr
Hi

See answers in line

From: Lida Zeighami [mailto:lid.z...@gmail.com]
Sent: Tuesday, July 07, 2015 10:20 PM
To: PIKAL Petr
Subject: Re: [R] add a special column to a matrix


Hi Petr,

Thanks, I can solve it!
On Jul 7, 2015 11:05 AM, Lida Zeighami 
lid.z...@gmail.commailto:lid.z...@gmail.com wrote:
Hi Petr,

Thank you so much for replying!
I have two problems:


1.  I couldn't understand what you mean No HTML posting , would you 
please explain more about that?

 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.


2. still my problem hasn't been solved! I don't want to add the columns and 
rows of two matrices together!
just I want  to add the q column from mat2 to mat1  ( column b in mat1 and the 
rownames in mat1 are the same but not in a same order! )

I should keep the mat1 and just add the value of rownames of mat2 to the 
equivalent elements in column b( I should add column q from mat2 to mat1 
regarding the column b)


Did you try read help page of merge command?

Did you even try merge? If yes please describe what you do not like about it.

merge(mat1, mat2, all.x=TRUE)

shall take all lines of mat1 and add corresponding columns of mat2 to 
appropriate rows.

However we do not know anything about your data. From your posting it seems to 
me that

dim(mat1) results in c(n,4) and dim(mat2) results in (n,1) and what do you 
consider as a column in mat2 are row names. In that case you need to add a 
column of row names, maybe

mat2$b - rownames(mat2)

before calling merge

Cheers
Petr



head(mat1)
a   b c   d
fg1:23   dfgv   5
pt10:18 tgtgh  1
wq   15:123oiljk   6
fg 9:1323ass   4
yr 12:123kjjlk   5

my second matrix:
head(mat2)
 q
  1:23 0
   10:18   1
  14:455  2
   15:123 2
9:13232
12:1231
 5:15480

output should be :
head(mat)
a   b c   d q
fg1:23   dfgv   50
pt10:18 tgtgh  11
wq   15:123oiljk   62
fg 9:1323ass   42
yr 12:123kjjlk   51

Thanks again,
Lida

On Tue, Jul 7, 2015 at 9:53 AM, PIKAL Petr 
petr.pi...@precheza.czmailto:petr.pi...@precheza.cz wrote:
Hi

No HTML posting please, sometimes the mail is unreadable

It is a work for merge.

mat3 - merge(mat1, mat2, all=TRUE)

shall do the trick (untested)

Cheers
Petr


 -Original Message-
 From: R-help 
 [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] On 
 Behalf Of Lida
 Zeighami
 Sent: Tuesday, July 07, 2015 4:43 PM
 To: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: [R] add a special column to a matrix

 Hi there,

 I have a two matrices which they have a common column! I want to add
 the a column of second to matrix to the equivalent column of first
 matrix!
 my first matrix is
 head(mat1)
 a   b c   d
 fg1:23   dfgv   5
 pt10:18 tgtgh  1
 wq   15:123oiljk   6
 fg 9:1323ass   4
 yr 12:123kjjlk   5

 my second matrix:
 head(mat2)
eq
   1:23 0
10:18   1
   14:455  2
15:123 2
 9:13232
 12:1231
  5:15480

 mat1 and mat2 have a common column (b and e) but is not in the same
 order, I want to add the q column from mat2 to be added to mat1 my
 output will be:

 head(mat)
 a   b c   d q
 fg1:23   dfgv   50
 pt10:18 tgtgh  11
 wq   15:123oiljk   62
 fg 9:1323ass   42
 yr 12:123kjjlk   51

 would you please let me know how to do it?

 Thanks

   [[alternative HTML version deleted]]

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


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení 

Re: [R] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Henrik Bengtsson
Thanks for insisting; I was wrong and I'm happy to see that there is
indeed code intended for named 'colClasses', which even goes back to
2004.   But as you report, then names only work when
length(colClasses)  cols (which also explains why I though it was not
supported).  I'm not sure if that _strictly less than_  test is
intentional or a mistake, but I would propose the following patch:

[HB-X201]{hb}: svn diff src\library\utils\R\readtable.R
Index: src/library/utils/R/readtable.R
===
--- src/library/utils/R/readtable.R (revision 68642)
+++ src/library/utils/R/readtable.R (working copy)
@@ -139,7 +139,7 @@
 if (rlabp) col.names - c(row.names, col.names)

 nmColClasses - names(colClasses)
-if(length(colClasses)  cols)
+if(length(colClasses) = cols)
 if(is.null(nmColClasses)) {
 colClasses - rep_len(colClasses, cols)
 } else {


Your example works with this patch.  I've made it source():able so you
can try it out (if you cannot source() https://, then download the
file an source it locally):

source(https://gist.githubusercontent.com/HenrikBengtsson/ed1eeb41a1b4d6c43b47/raw/ebe58f76e518dd014423bea466a5c93d2efd3c99/readtable-fix.R;)

kkk - c(a\tb,
 3.14\tx)

colClasses - c(a=numeric, b=character)
data - read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses = colClasses)
str(data)
### 'data.frame':   1 obs. of  2 variables:
### $ a: num 3.14
### $ b: chr x

## Does not work with utils::read.table(), but with patch
data - read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses = rev(colClasses))
str(data)
### 'data.frame':   1 obs. of  2 variables:
### $ a: num 3.14
### $ b: chr x

Let's hope that the above is a (10-year old) typo, and changing a  to
a = adds support for named 'colClasses', which is a really useful
functionality.

/Henrik

On Wed, Jul 8, 2015 at 6:42 PM, Andreas Leha
andreas.l...@med.uni-goettingen.de wrote:
 Hi Henrik,

 Thanks for your reply.

 I am not (yet) convinced, though.  The help page for read.table
 mentions named colClasses and if I specify colClasses for not all
 columns, the names are taken into account:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 str(read.table(textConnection(kkk),
sep=\t,
header = TRUE))

 str(read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses=c(b=character)))
 --8---cut here---end---8---

 What am I missing?

 Best,
 Andreas



 On 09/07/2015 02:21, Henrik Bengtsson wrote:
 read.table() does not make use of names(colClasses) - only its values.
 Because of this, ordering is critical, as you noted. It shouldn't be
 too hard to add support for a named `colClasses` argument of
 utils::read.table(), but someone needs to convince the R core team
 that this is a good idea.

 As an alternative, see R.filesets::readDataFrame() for a
 read.table()-like function that matches names(colClasses) to column
 names, if they exists.

 /Henrik
 (author of R.filesets)

 On Wed, Jul 8, 2015 at 5:41 PM, Andreas Leha
 andreas.l...@med.uni-goettingen.de wrote:
 Hi all,

 Apparently, the colClasses argument to read.table needs to be in the
 order of the columns *even when it is named*.  Why is that?  And where
 would I find it in the documentation?

 Here is a MWE:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 read.table(textConnection(kkk),
sep=\t,
header = TRUE)

 cclasses=c(b=character,
a=numeric)

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses)  ## --- error

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses[order(names(cclasses))])
 --8---cut here---end---8---


 Thanks,
 Andreas

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] tcltk2 entry box

2015-07-08 Thread Matthew
Is anyone familiar enough with the tcltk2 package to know if it is 
possible to have an entry box where a user can enter information (such 
as a path to a file or a number) and then be able to use the entered 
information downstream in a R script ?


The idea is for someone unfamiliar with R to just start an R script that 
would take care of all the commands for them so all they have to do is 
get the script started. However, there is always a couple of pieces of 
information that will change each time the script is used (for example, 
a different file will be processed by the script). So, I would like a 
way for the user to input that information as the script ran.


Matthew McCormack

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] tcltk2 entry box

2015-07-08 Thread John Fox
Dear Matthew,

For file selection, see ?tcltk::tk_choose.files or ?tcltk::tkgetOpenFile . 

You could enter a number in a tk entry widget, but, depending upon the
nature of the number, a slider or other widget might be a better choice. 

For a variety of helpful tcltk examples see
http://www.sciviews.org/_rgui/tcltk/, originally by James Wettenhall but
now maintained by Philippe Grosjean (the author of the tcltk2 package). (You
probably don't need tcltk2 for the simple operations that you mention, but
see ?tk2spinbox for an alternative to a slider.)

Best,
 John

---
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
http://socserv.socsci.mcmaster.ca/jfox/




 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Matthew
 Sent: July-08-15 8:01 PM
 To: r-help
 Subject: [R] tcltk2 entry box
 
 Is anyone familiar enough with the tcltk2 package to know if it is
 possible to have an entry box where a user can enter information (such
 as a path to a file or a number) and then be able to use the entered
 information downstream in a R script ?
 
 The idea is for someone unfamiliar with R to just start an R script that
 would take care of all the commands for them so all they have to do is
 get the script started. However, there is always a couple of pieces of
 information that will change each time the script is used (for example,
 a different file will be processed by the script). So, I would like a
 way for the user to input that information as the script ran.
 
 Matthew McCormack
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Andreas Leha
Hi Henrik,

Thanks for your reply.

I am not (yet) convinced, though.  The help page for read.table
mentions named colClasses and if I specify colClasses for not all
columns, the names are taken into account:

--8---cut here---start-8---
kkk - c(a\tb,
 3.14\tx)
str(read.table(textConnection(kkk),
   sep=\t,
   header = TRUE))

str(read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses=c(b=character)))
--8---cut here---end---8---

What am I missing?

Best,
Andreas



On 09/07/2015 02:21, Henrik Bengtsson wrote:
 read.table() does not make use of names(colClasses) - only its values.
 Because of this, ordering is critical, as you noted. It shouldn't be
 too hard to add support for a named `colClasses` argument of
 utils::read.table(), but someone needs to convince the R core team
 that this is a good idea.
 
 As an alternative, see R.filesets::readDataFrame() for a
 read.table()-like function that matches names(colClasses) to column
 names, if they exists.
 
 /Henrik
 (author of R.filesets)
 
 On Wed, Jul 8, 2015 at 5:41 PM, Andreas Leha
 andreas.l...@med.uni-goettingen.de wrote:
 Hi all,

 Apparently, the colClasses argument to read.table needs to be in the
 order of the columns *even when it is named*.  Why is that?  And where
 would I find it in the documentation?

 Here is a MWE:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 read.table(textConnection(kkk),
sep=\t,
header = TRUE)

 cclasses=c(b=character,
a=numeric)

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses)  ## --- error

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses[order(names(cclasses))])
 --8---cut here---end---8---


 Thanks,
 Andreas

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


Re: [R] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-08 Thread Duncan Mackay
Hi Luigi

str(my.data)
'data.frame':   540 obs. of  4 variables:
 $ Line  : chr  1 2 3 4 ...
 $ Well  : chr  1 1 1 1 ...
 $ Target: chr  alpha alpha alpha alpha ...
 $ Rn: chr  0.728 0.735 0.749 0.758 ...

You didnot create the data.frame properly

mydata -
data.frame(Line=Line, Well=Well, Target=Target, Rn=Rn,Cycle= Cycle)
str(mydata)
'data.frame':   540 obs. of  4 variables:
 $ Line  : num  1 2 3 4 5 6 7 8 9 10 ...
 $ Well  : num  1 1 1 1 1 1 1 1 1 1 ...
 $ Target: chr  alpha alpha alpha alpha ...
 $ Rn: num  0.728 0.735 0.749 0.758 0.77 0.778 0.78 0.784 0.786 0.785 ...

I was having problems with your script so I started with the basics (before I 
found the problem with the df)

xyplot(Rn ~ Cycle | sprintf(%2d,Well), data = mydata,
   as.table = TRUE,
   layout = c(6,2),
   groups = Well)

You are not splitting up the data with groups being the same as the 
conditioning.
It can be necessary to use this setup in some cases but not this.

latticeExtra is on Cran so you can use install.packages(latticeExtra) or use 
the menu
I have never heard of lattice_Extra


mydata$rown - ifelse(mydata$Well6,2,1)
mydata$welln - rep(1:6, 2)[sapply(mydata$Well, pmatch, 1:12)]


useOuterStrips(strip  = strip.custom(factor.levels = paste(column,1:6),
 par.strip.text = list(cex = 0.75)),
   strip.left = strip.custom(factor.levels = paste(row, 1:2),
 horizontal = FALSE,
 par.strip.text = list(cex = 0.75)),

xyplot(Rn ~ Cycle | welln*rown, data = mydata,
   as.table = TRUE,
   layout = c(6,2)
  )

) ## useOuterStrips

  ps.Colours -
  c(#00,#FF,#00FF00,#FF,#FFA54F,
#00,#FF00FF,#C0,#00B414,#FFD18F,
#00B2EE,#ffe5cc,#6A5ACD,#C0C0C0,#CC,
#6495ED,#FFFAFA)



useOuterStrips(strip  = strip.custom(factor.levels = paste(column,1:6),
 par.strip.text = list(cex = 0.75)),
   strip.left = strip.custom(factor.levels = paste(row, 1:2),
 horizontal = FALSE,
 par.strip.text = list(cex = 0.75)),

xyplot(Rn ~ Cycle | welln*rown, data = mydata,
   as.table = TRUE,
   groups = Well,
   col = ps.Colours,
   layout = c(6,2)
  )

) ## useOuterStrips

Duncan

-Original Message-
From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] 
Sent: Thursday, 9 July 2015 09:22
To: Duncan Mackay; Dennis Murphy; r-help
Subject: Re: [R] add outer strip for levels in lattice plot (useOuterStrips 
alternative for Lattice)

In relation to this question I have prepared a workable example. First
I prepare a dataframe with three variables (Cycle, Target, Rn), then I
plot the results with lattice's xyplot(). I won't use the scales but
only the labels and the panels are NOT indicated by the variable Well.
What I would need to use are instead the vectors row.name and col.name
that can identify each column and row of the plot.
Secondly I create replicates of the row.name and col.name in order to
fit the data and create a second dataframe, then I plot using lattice
extra's useOuterStrips().
However (a) I think the call is wrong anyway, (b) I obtain Error:
length(dimx) == 2 is not TRUE (c) I need a package on top of lattice
(d) I might introduce errors during the creation of the second
dataframe.
The requirements remains to create a strip on the top and left side of
the plot to allocate the elements of row.name and col.name possibly
using lattice only.
Thank you for your help.
Luigi


Line-c(1,2,3,4,5,6,7,8,9,10,
  11,12,13,14,15,16,17,18,19,20,
 21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,
61,62,63,64,65,66,67,68,69,70,
71,72,73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,89,90,
91,92,93,94,95,96,97,98,99,100,
101,102,103,104,105,106,107,108,109,
 110,111,112,113,114,115,116,117,118,
  119,120,121,122,123,124,125,126,127,
   128,129,130,131,132,133,134,135,
136,137,138,139,140,141,142,143,144,
 145,146,147,148,149,150,151,152,153,
  154,155,156,157,158,159,160,161,162,
   163,164,165,166,167,168,169,170,
171,172,173,174,175,176,177,178,

Re: [R] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Andreas Leha
Hi Henrik,

Thank you very much for looking into this.  And thanks for the patch!

Yes, let's hope this is a typo that gets fixed.

Regards,
Andreas

Henrik Bengtsson henrik.bengts...@ucsf.edu writes:
 Thanks for insisting; I was wrong and I'm happy to see that there is
 indeed code intended for named 'colClasses', which even goes back to
 2004.   But as you report, then names only work when
 length(colClasses)  cols (which also explains why I though it was not
 supported).  I'm not sure if that _strictly less than_  test is
 intentional or a mistake, but I would propose the following patch:

 [HB-X201]{hb}: svn diff src\library\utils\R\readtable.R
 Index: src/library/utils/R/readtable.R
 ===
 --- src/library/utils/R/readtable.R (revision 68642)
 +++ src/library/utils/R/readtable.R (working copy)
 @@ -139,7 +139,7 @@
  if (rlabp) col.names - c(row.names, col.names)

  nmColClasses - names(colClasses)
 -if(length(colClasses)  cols)
 +if(length(colClasses) = cols)
  if(is.null(nmColClasses)) {
  colClasses - rep_len(colClasses, cols)
  } else {


 Your example works with this patch.  I've made it source():able so you
 can try it out (if you cannot source() https://, then download the
 file an source it locally):

 source(https://gist.githubusercontent.com/HenrikBengtsson/ed1eeb41a1b4d6c43b47/raw/ebe58f76e518dd014423bea466a5c93d2efd3c99/readtable-fix.R;)

 kkk - c(a\tb,
  3.14\tx)

 colClasses - c(a=numeric, b=character)
 data - read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = colClasses)
 str(data)
 ### 'data.frame':   1 obs. of  2 variables:
 ### $ a: num 3.14
 ### $ b: chr x

 ## Does not work with utils::read.table(), but with patch
 data - read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = rev(colClasses))
 str(data)
 ### 'data.frame':   1 obs. of  2 variables:
 ### $ a: num 3.14
 ### $ b: chr x

 Let's hope that the above is a (10-year old) typo, and changing a  to
 a = adds support for named 'colClasses', which is a really useful
 functionality.

 /Henrik

 On Wed, Jul 8, 2015 at 6:42 PM, Andreas Leha
 andreas.l...@med.uni-goettingen.de wrote:
 Hi Henrik,

 Thanks for your reply.

 I am not (yet) convinced, though.  The help page for read.table
 mentions named colClasses and if I specify colClasses for not all
 columns, the names are taken into account:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 str(read.table(textConnection(kkk),
sep=\t,
header = TRUE))

 str(read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses=c(b=character)))
 --8---cut here---end---8---

 What am I missing?

 Best,
 Andreas



 On 09/07/2015 02:21, Henrik Bengtsson wrote:
 read.table() does not make use of names(colClasses) - only its values.
 Because of this, ordering is critical, as you noted. It shouldn't be
 too hard to add support for a named `colClasses` argument of
 utils::read.table(), but someone needs to convince the R core team
 that this is a good idea.

 As an alternative, see R.filesets::readDataFrame() for a
 read.table()-like function that matches names(colClasses) to column
 names, if they exists.

 /Henrik
 (author of R.filesets)

 On Wed, Jul 8, 2015 at 5:41 PM, Andreas Leha
 andreas.l...@med.uni-goettingen.de wrote:
 Hi all,

 Apparently, the colClasses argument to read.table needs to be in the
 order of the columns *even when it is named*.  Why is that?  And where
 would I find it in the documentation?

 Here is a MWE:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 read.table(textConnection(kkk),
sep=\t,
header = TRUE)

 cclasses=c(b=character,
a=numeric)

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses)  ## --- error

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses[order(names(cclasses))])
 --8---cut here---end---8---


 Thanks,
 Andreas

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide 

[R] Para r-help

2015-07-08 Thread Mariana Ferrari
Tudo bem?
Sou a Josie, achei voc� na internet e queria aproveitar para fazer o marketing 
do site onde estou trabalhando ;)
Pra mim � o melhor lugar para fazer amigos, achar um relacionamento e at� um 
encontro assim... mais �ntimo.

O link � este: http://goo.gl/DWtKBg
(N�o se preocupe, n�o � v�rus! Juro!)

Estou cadastrada l� como josymel. Cadastre-se tamb�m para conversamos por 
l�.

Desculpa te mandar um email assim sem permiss�o ok?
Te encontro l�!

Bjs!!!
Josie



[[alternative HTML version deleted]]

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

Re: [R] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-08 Thread Luigi Marongiu
In relation to this question I have prepared a workable example. First
I prepare a dataframe with three variables (Cycle, Target, Rn), then I
plot the results with lattice's xyplot(). I won't use the scales but
only the labels and the panels are NOT indicated by the variable Well.
What I would need to use are instead the vectors row.name and col.name
that can identify each column and row of the plot.
Secondly I create replicates of the row.name and col.name in order to
fit the data and create a second dataframe, then I plot using lattice
extra's useOuterStrips().
However (a) I think the call is wrong anyway, (b) I obtain Error:
length(dimx) == 2 is not TRUE (c) I need a package on top of lattice
(d) I might introduce errors during the creation of the second
dataframe.
The requirements remains to create a strip on the top and left side of
the plot to allocate the elements of row.name and col.name possibly
using lattice only.
Thank you for your help.
Luigi


Line-c(1,2,3,4,5,6,7,8,9,10,
  11,12,13,14,15,16,17,18,19,20,
 21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,
61,62,63,64,65,66,67,68,69,70,
71,72,73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,89,90,
91,92,93,94,95,96,97,98,99,100,
101,102,103,104,105,106,107,108,109,
 110,111,112,113,114,115,116,117,118,
  119,120,121,122,123,124,125,126,127,
   128,129,130,131,132,133,134,135,
136,137,138,139,140,141,142,143,144,
 145,146,147,148,149,150,151,152,153,
  154,155,156,157,158,159,160,161,162,
   163,164,165,166,167,168,169,170,
171,172,173,174,175,176,177,178,179,
 180,181,182,183,184,185,186,187,188,
  189,190,191,192,193,194,195,196,197,
   198,199,200,201,202,203,204,205,
206,207,208,209,210,211,212,213,214,
 215,216,217,218,219,220,221,222,223,
  224,225,226,227,228,229,230,231,232,
   233,234,235,236,237,238,239,240,
241,242,243,244,245,246,247,248,249,
 250,251,252,253,254,255,256,257,258,
  259,260,261,262,263,264,265,266,267,
   268,269,270,271,272,273,274,275,
276,277,278,279,280,281,282,283,284,
 285,286,287,288,289,290,291,292,293,
  294,295,296,297,298,299,300,301,302,
   303,304,305,306,307,308,309,310,
311,312,313,314,315,316,317,318,319,
 320,321,322,323,324,325,326,327,328,
  329,330,331,332,333,334,335,336,337,
   338,339,340,341,342,343,344,345,
346,347,348,349,350,351,352,353,354,
 355,356,357,358,359,360,361,362,363,
  364,365,366,367,368,369,370,371,372,
   373,374,375,376,377,378,379,380,
381,382,383,384,385,386,387,388,389,
 390,391,392,393,394,395,396,397,398,
  399,400,401,402,403,404,405,406,407,
   408,409,410,411,412,413,414,415,
416,417,418,419,420,421,422,423,424,
 425,426,427,428,429,430,431,432,433,
  434,435,436,437,438,439,440,441,442,
   443,444,445,446,447,448,449,450,
451,452,453,454,455,456,457,458,459,
 460,461,462,463,464,465,466,467,468,
  469,470,471,472,473,474,475,476,477,
   478,479,480,481,482,483,484,485,
486,487,488,489,490,491,492,493,494,
 495,496,497,498,499,500,501,502,503,
  504,505,506,507,508,509,510,511,512,
   513,514,515,516,517,518,519,520,
521,522,523,524,525,526,527,528,

[R] clm funtion and CI

2015-07-08 Thread Luciane Maria Pilotto
Hi,

I'm working with ordinal logistic regression and fitting the model with the 
clm funtion of the ordinal package and would like to get the CI. According to 
the Tutorial on fitting Cumulative Link Models with the ordinal Package, Rune 
Haubo B Christensen (21 January 2015) you can run the OR, but not CI. The same 
happens with the clm2 for partial proportional odds.

I appreciate any help !!


Luciane

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Andreas Leha
Hi all,

Apparently, the colClasses argument to read.table needs to be in the
order of the columns *even when it is named*.  Why is that?  And where
would I find it in the documentation?

Here is a MWE:

--8---cut here---start-8---
kkk - c(a\tb,
 3.14\tx)
read.table(textConnection(kkk),
   sep=\t,
   header = TRUE)

cclasses=c(b=character,
   a=numeric)

read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses = cclasses)  ## --- error

read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses = cclasses[order(names(cclasses))])
--8---cut here---end---8---


Thanks,
Andreas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] tcltk2 entry box

2015-07-08 Thread Matthew McCormack
Wow !  Very nice.  Thank you very much, John.  This is very helpful and 
just what I need.
Yes, I can see that I should have paid attention to tcltk before going 
to tcltk2.


Matthew

On 7/8/2015 8:37 PM, John Fox wrote:

Dear Matthew,

For file selection, see ?tcltk::tk_choose.files or ?tcltk::tkgetOpenFile .

You could enter a number in a tk entry widget, but, depending upon the
nature of the number, a slider or other widget might be a better choice.

For a variety of helpful tcltk examples see
http://www.sciviews.org/_rgui/tcltk/, originally by James Wettenhall but
now maintained by Philippe Grosjean (the author of the tcltk2 package). (You
probably don't need tcltk2 for the simple operations that you mention, but
see ?tk2spinbox for an alternative to a slider.)

Best,
  John

---
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
http://socserv.socsci.mcmaster.ca/jfox/





-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Matthew
Sent: July-08-15 8:01 PM
To: r-help
Subject: [R] tcltk2 entry box

Is anyone familiar enough with the tcltk2 package to know if it is
possible to have an entry box where a user can enter information (such
as a path to a file or a number) and then be able to use the entered
information downstream in a R script ?

The idea is for someone unfamiliar with R to just start an R script that
would take care of all the commands for them so all they have to do is
get the script started. However, there is always a couple of pieces of
information that will change each time the script is used (for example,
a different file will be processed by the script). So, I would like a
way for the user to input that information as the script ran.

Matthew McCormack

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


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



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


[R] problem understanding grid coordinate systems

2015-07-08 Thread Johannes Huesing

According to R Graphics by Paul Murrell, the coordinates that were used for 
the
most recent lattics plot can be retrieved with native units.

I have difficulties to access these coordinates. The following code 
renders the following results:



library(grid)
library(lattice)
pl - xyplot(1:10 ~ 10:1)
print(pl)
convertX(unit(.9, npc), native)

[1] 605.7native

R.version
   _   
platform   i686-pc-linux-gnu   
arch   i686
os linux-gnu   
system i686, linux-gnu 
status 
major  3   
minor  0.2
year   2013
month  09
day25  
svn rev63987
language   R   
version.string R version 3.0.2 (2013-09-25)

nickname   Frisbee Sailing

I had expected something around 9.5 in native coordinates. Which coordinate
system do I have to address instead?

--
Johannes Hüsing

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