Re: [R] Unable to use `eval(parse(text))' in nlme::lme

2015-02-09 Thread Ravi Varadhan
Thanks to Rolf, Duncan, and Ben.

Ben, your suggestion worked (with a minor correction of concatenating the 
termlabels into a vector).

Here is the solution to those interested.

ff - reformulate(termlabels=c(time,as.factor(gvhd)), response=yname, 
intercept=TRUE)
dd - subset(labdata2, Transplant_type!=0  time 0)
lme(ff, random=~1|Patient, data=dd, correlation=corAR1(), na.action=na.omit)

Best,
Ravi

Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
Associate Professor
Department of Oncology
Division of Biostatistics  Bionformatics
Johns Hopkins University
550 N. Broadway
Baltimore, MD 21205
40-502-2619


[[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] transpose a data frame according to a specific variable

2015-02-09 Thread jeff6868
Dear R-users,

I would like to transpose a large data.frame according to a specific column.
Here's a reproductible example, it will be more understandable.

At the moment, my data.frame looks like this example:

DF - data.frame(id=c(A,A,A,B,B,B,C,C,C),
Year=c(2001,2002,2003,2002,2003,2004,2000,2001,2002),
Day=c(120,90,54,18,217,68,164,99,48))

I would like it being transformed to this (fake example again, still just
for being understandable):

finalDF -
data.frame(id=c(A,B,C),2000=c(NA,NA,164),2001=c(120,NA,99),
2002=c(90,18,48),2003=c(54,217,NA),2004=c(NA,68,NA))

Any ideas for doing this easily? I haven't found any good answer on the web.

Thanks for the help!




--
View this message in context: 
http://r.789695.n4.nabble.com/transpose-a-data-frame-according-to-a-specific-variable-tp4702971.html
Sent from the R help mailing list archive at Nabble.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] NA when trying to calculate AIC value for DLNM

2015-02-09 Thread Malgosia Lubczynska
Dear all,
 
I am trying to run a sensitivity analysis for a DLNM combined with a case 
crossover design and select the best parameters based on AIC values for 
different model set-ups.
 
model - glm(mortality ~ cb.temp + ns(soo, 7*7) + dow, family=quasipoisson(), 
my.data)
 
where cb.temp is the crossbasis matrix for the exposure (temperature)
 
However, the output for the AIC calculations equals NA.
Does anyone know how to obtain a correct AIC for a DLNM model?
 
Thank you,
Gosia
 
 
  
[[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] Coordinate or top left corner + offset

2015-02-09 Thread Pascal A. Niklaus

Dear all,

I am struggling to add annotations to panels of a series of plots 
arranged on a page.


Basically, I'd like to add letters enumerating the panels 
(a,b,c,...), at a fixed distance from the top left corner of the 
plot's box.


I succeeded partly with mtext (see below), but the at option is in 
user coordinates, which makes is difficult to specify a given offset 
from the corner (e.g. 1cm from top and left).


I tried grid's npc but these coordinates refer to the entire plot 
instead of the current inner plotting region.


Phrased differently, I'd like to place text (and ideally also be able to 
plot, e.g. a white disc to cover background items) at position 
(top-1cm,left+1cm)


Here is a minimum working example illustrating what I try to achieve:


pdf(example.pdf,width=15,height=15)

m - rbind( c(0.1,0.9,0.1,0.6),
c(0.1,0.9,0.6,0.9)
 );

split.screen(m)

screen(1);
par(mar=c(0,0,0,0));
plot(rnorm(10),rnorm(10),xlim=c(-5,5),xaxt=n,yaxt=n);
mtext(quote(bold(a)),side=3,line=-2.5,at=-5,cex=2.5)

screen(2);
par(mar=c(0,0,0,0));
plot(rnorm(10),rnorm(10),xlim=c(-3,3),xaxt=n,yaxt=n);
mtext(quote(bold(a)),side=3,line=-2.5,at=-3,cex=2.5)


close.screen(all.screens=TRUE)

dev.off()


Thanks for your help

Pascal Niklaus

__
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] SAS equivalent for R's signif function?

2015-02-09 Thread Allen Bingham
Probably posting this to the wrong list ... but I'm in the process of
learning R, after many years of using SAS --- so I thought I'd ask this
question here:

 Is there with a function (or macro) in SAS that performs the same
action as R's signif function, if so please provide?

Tried to find via a Google search to no success. Doesn't seem to be in the
R for SAS and SPSS Users by Robert A. Munchen (first edition is what I
have), or in SAS and R by Ken Kleinman and Nicholas J. Horton (2nd edition)
[although in the latter they do list the R signif function on page 61 ...
but don't list a SAS equivalent.

If you have a suggestion for a different list that I might ask this question
(assuming I don't get the answer here), provide that as well.

Thanks-Allen

__
Allen Bingham
Bingham Statistical Consulting
aebingh...@gmail.com
LinkedIn Profile: www.linkedin.com/pub/allen-bingham/3b/556/325

__
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] SAS equivalent for R's signif function?

2015-02-09 Thread Daniel Nordlund

On 2/9/2015 7:02 PM, Allen Bingham wrote:

Probably posting this to the wrong list ... but I'm in the process of
learning R, after many years of using SAS --- so I thought I'd ask this
question here:

  Is there with a function (or macro) in SAS that performs the same
action as R's signif function, if so please provide?

Tried to find via a Google search to no success. Doesn't seem to be in the
R for SAS and SPSS Users by Robert A. Munchen (first edition is what I
have), or in SAS and R by Ken Kleinman and Nicholas J. Horton (2nd edition)
[although in the latter they do list the R signif function on page 61 ...
but don't list a SAS equivalent.

If you have a suggestion for a different list that I might ask this question
(assuming I don't get the answer here), provide that as well.

Thanks-Allen

__
Allen Bingham
Bingham Statistical Consulting
aebingh...@gmail.com
LinkedIn Profile: www.linkedin.com/pub/allen-bingham/3b/556/325

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



Yes, this is the wrong list.  Your question is about SAS (that is what 
SAS-L or SAScommunity is about) and this list is about R, and you 
already know what function to use in R.  That said, I searched for SAS 
round to fixed number of significant digits and found this link


http://support.sas.com/kb/24/728.html

You could turn this into a function style macro (but it will be ugly). 
If you have a recent enough version of SAS you could use PROC FCMP to 
turn this into a function.


If you are interested contact me offline and I will send you a PROC FCMP 
implementation.



Dan

--
Daniel Nordlund
Bothell, WA USA

__
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] 16. Database connection query (Lalitha Kristipati)

2015-02-09 Thread Manel Amado Martí
Hi,

You can read the R Data Import / Export Manual, that comes within the help 
files for the R Standard. I recommend specially the chapter 4, where you'll 
found the generical guidelines to connect to databases. At 4.3, RODBC Package, 
or DBI packages should be right to you.

Regards,

Manel Amado i Martí
Cap d'Assessoria de Comerç Interior
am...@cambrasabadell.org
Tel. 93 745 12 63 · Fax 93 745 12 64 
    
Av. Francesc Macià, 35 · 08206 Sabadell
Apt. corr. 119 · www.cambrasabadell.org



-Missatge original-
De: R-help [mailto:r-help-boun...@r-project.org] En nom de 
r-help-requ...@r-project.org
Enviat: dilluns, 9 / febrer / 2015 12:00
Per a: r-help@r-project.org
Tema: R-help Digest, Vol 144, Issue 9

Send R-help mailing list submissions to
r-help@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-help
or, via email, send a message with subject or body 'help' to
r-help-requ...@r-project.org

You can reach the person managing the list at
r-help-ow...@r-project.org

When replying, please edit your Subject line so it is more specific than Re: 
Contents of R-help digest...


Today's Topics:

   1. Re: how to draw paired mosaic plot? (Michael Friendly)
   2. Re: how to draw paired mosaic plot? (Michael Friendly)
   3. Re: how to draw paired mosaic plot? (meng)
   4. Unable to use `eval(parse(text))' in  nlme::lme (Ravi Varadhan)
   5. Re: Unable to use `eval(parse(text))' in  nlme::lme (Rolf Turner)
   6. Re: Unable to use `eval(parse(text))' in  nlme::lme
  (Duncan Murdoch)
   7. Package build help (Glenn Schultz)
   8. Re: Package build help (Duncan Murdoch)
   9. Re: Superscript in legend without using expression function
  (Gabor Grothendieck)
  10. confidence interval for wilcox_test (RomanGelzhaeuser)
  11. Re: Unable to use `eval(parse(text))' in  nlme::lme (Ben Bolker)
  12. specifying dimensions of a graphic (not the window...)
  (Evan Cooch)
  13. Re: specifying dimensions of a graphic (not the window...)
  (Evan Cooch)
  14. Zero length data block in hexView? (Jeff Newmiller)
  15. ASA John M. Chambers Statistical Software Award - 2015
  (Munjal, Aarti)
  16. Database connection query (Lalitha Kristipati)


--

Message: 1
Date: Sun, 8 Feb 2015 10:01:09 -0500
From: Michael Friendly frien...@yorku.ca
To: r-h...@stat.math.ethz.ch
Cc: R help r-help@r-project.org
Subject: Re: [R] how to draw paired mosaic plot?
Message-ID: 54d77a35.1030...@yorku.ca
Content-Type: text/plain; charset=windows-1252; format=flowed

You are looking for the pairs plot for table and other objects in the vcd 
package:

  ?vcd::pairs.table

It allows you to use various panel functions for the diagonal and off-diagonal 
plots

On 2/7/2015 9:50 AM, meng wrote:
 If there are many character variables,and I want to get the mosaic plot of 
 every pair of each variable,how to do then?


 If the variables are numeric, I can use pairs to get paired scatter plot.
 But as to the character variables, how to get the paired mosaic plot?


 Many thanks.





 --
 QQ: 1733768559





 At 2015-02-07 17:04:26,Jim Lemon drjimle...@gmail.com wrote:
 Hi meng,
 It's not too hard to get a mosaic plot of two character variables:

 x-sample(LETTERS[1:3],20,TRUE)
 y-sample(LETTERS[24:26],20,TRUE)
 mosaicplot(table(x,y))

 If you could tell us how the above is not what you want, perhaps a 
 better suggestion will appear.

 Jim


 On Sat, Feb 7, 2015 at 6:29 PM, meng laomen...@163.com wrote:
 If both x and y are all character, paired scatter plot is a little bit 
 strange I think.






 --
 QQ: 1733768559





 At 2015-02-06 23:52:34,Duncan Murdoch murdoch.dun...@gmail.com wrote:
 On 06/02/2015 6:46 AM, meng wrote:
 Hi all:
 If there are two numeric variable:x,y, and I can get paired scatter plot 
 by function pairs.But if x and y are character, and I want to get 
 paired mosaic plot,which function should be used then?

 Why not pairs, with a custom panel function?  There are examples on 
 the help page, though I don't think a mosaic plot is there.

 Duncan Murdoch


 Many thanks!
 My best.






 --
 QQ: 1733768559


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

   [[alternative HTML version deleted]]



-- 

Re: [R] transpose a data frame according to a specific variable

2015-02-09 Thread Dennis Murphy
One way is to use the reshape2 package:

library(reshape2)
dcast(DF, id ~ Year, value.var = Day)


Dennis

On Mon, Feb 9, 2015 at 7:47 AM, jeff6868
geoffrey_kl...@etu.u-bourgogne.fr wrote:
 Dear R-users,

 I would like to transpose a large data.frame according to a specific column.
 Here's a reproductible example, it will be more understandable.

 At the moment, my data.frame looks like this example:

 DF - data.frame(id=c(A,A,A,B,B,B,C,C,C),
 Year=c(2001,2002,2003,2002,2003,2004,2000,2001,2002),
 Day=c(120,90,54,18,217,68,164,99,48))

 I would like it being transformed to this (fake example again, still just
 for being understandable):

 finalDF -
 data.frame(id=c(A,B,C),2000=c(NA,NA,164),2001=c(120,NA,99),
 2002=c(90,18,48),2003=c(54,217,NA),2004=c(NA,68,NA))

 Any ideas for doing this easily? I haven't found any good answer on the web.

 Thanks for the help!




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/transpose-a-data-frame-according-to-a-specific-variable-tp4702971.html
 Sent from the R help mailing list archive at Nabble.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-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] NA when trying to calculate AIC value for DLNM

2015-02-09 Thread Prof Brian Ripley

On 09/02/2015 14:28, Malgosia Lubczynska wrote:

Dear all,

I am trying to run a sensitivity analysis for a DLNM combined with a case 
crossover design and select the best parameters based on AIC values for 
different model set-ups.

model - glm(mortality ~ cb.temp + ns(soo, 7*7) + dow, family=quasipoisson(), 
my.data)

where cb.temp is the crossbasis matrix for the exposure (temperature)

However, the output for the AIC calculations equals NA.
Does anyone know how to obtain a correct AIC for a DLNM model?


To have an AIC you need to do maximum-likelihood fitting (and have a 
likelihood ...), something a quasi-Poisson fit does not give you.




Thank you,
Gosia



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




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

__
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] Revolutions blog: January 2015 roundup

2015-02-09 Thread David Smith
For more than 6 years, Revolution Analytics staff and guests have
written about R every weekday at the Revolutions blog:
 http://blog.revolutionanalytics.com
and every month I post a summary of articles from the previous month
of particular interest to readers of r-help.

In case you missed them, here are some articles related to R from the
month of January:

Slides on reproducible data analysis with Revolution R Open and the
checkpoint package: http://bit.ly/16GIEiM

A review of a recent Bay Area R User Group meetup, featuring Hadley
Wickham, Ryan Hafen and Nick Elprin: http://bit.ly/16GICrh

In an article at opensource.com, I explain why now is a great time to
learn R and provide some resources to get started:
http://bit.ly/16GIEiL

Norm Matloff reviews the state of the art in parallel programming with
GPUs in R: http://bit.ly/16GICrg

A tongue-in-cheek R script provides excuses for when your P-values
aren't *quite* significant enough: http://bit.ly/16GIEiK

Microsoft will acquire Revolution Analytics. I explain what this means
for Revolution R users and the R community generally
(http://bit.ly/16GICHu), and review the media coverage
(http://bit.ly/16GICrg).

Joe Rickert reviews the state of R integration with Spark: http://bit.ly/16GICHx

Tufte's classic weather data visualization recreated in R for Dayton,
Chicago and New York City: http://bit.ly/16GIEiP

A new R-based course, Statistical Computing for Biomedical Data
Analytics: http://bit.ly/16GICHy

An introductory tutorial for R, aimed at budding econometricians:
http://bit.ly/16GICHz

Harvard offers a free 5-week online course on R: http://bit.ly/16GICHA

A look at, and some resources for using, R's base graphics
capabilities: http://bit.ly/16GIEiQ

An update to the R is Hot whitepaper with new applications and
statistics on R usage: http://bit.ly/16GIEiR

Interactive R notebooks with Domino Data Lab: http://bit.ly/16GIEiS

The dplyr package has been updated with new data manipulation commands
for filters, joins and set operations: http://bit.ly/16GICHC

Kudos to the rapidly-growing BioConductor project, recently featured
in Nature: http://bit.ly/16GIEiT

An online R-based application evaluates your risk of flooding:
http://bit.ly/16GICHB

Twitter releases an R package for anomaly detection in time series:
http://bit.ly/16GICHD

A Revolution Analytics consultant describes how he used R to visualize
soil attributes using the ggmap package: http://bit.ly/16GIEz8

Yihui Xie created a voice-controlled R graphics application:
http://bit.ly/16GICHE

Video of talks by Trevor Hastie (on machine learning) and John
Chambers (reminiscing on his time at Bell Labs): http://bit.ly/16GICHF

The top 10 posts on the Revolutions blog from 2014: http://bit.ly/16GICHG

General interest stories (not related to R) in the past month
included: a comeback for real and virtual pinball
(http://bit.ly/16GIEza), a geometry construction game
(http://bit.ly/16GICHH), a typography game (http://bit.ly/16GICHI),
and a musical 'tribute' to Shia LeBoeuf (http://bit.ly/16GIEzc).

Meeting times for local R user groups (http://bit.ly/eC5YQe) can be
found on the updated R Community Calendar at: http://bit.ly/bb3naW

If you're looking for more articles about R, you can find summaries
from previous months at http://blog.revolutionanalytics.com/roundups/.
You can receive daily blog posts via email using services like
blogtrottr.com, or join the Revolution Analytics mailing list at
http://revolutionanalytics.com/newsletter to be alerted to new
articles on a monthly basis.

As always, thanks for the comments and please keep sending suggestions
to me at da...@revolutionanalytics.com or via Twitter (I'm
@revodavid).

Cheers,
# David

-- 
David M Smith da...@revolutionanalytics.com
Chief Community Officer, Revolution Analytics
http://blog.revolutionanalytics.com
Tel: +1 (650) 646-9523 (Chicago IL, USA)
Twitter: @revodavid

__
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] transpose a data frame according to a specific variable

2015-02-09 Thread Erich Neuwirth

library(tidyr)
spread(DF,Year,Day)




 On 09 Feb 2015, at 16:47, jeff6868 geoffrey_kl...@etu.u-bourgogne.fr wrote:
 
 finalDF -
 data.frame(id=c(A,B,C),2000=c(NA,NA,164),2001=c(120,NA,99),
 2002=c(90,18,48),2003=c(54,217,NA),2004=c(NA,68,NA))



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
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] Coordinate or top left corner + offset

2015-02-09 Thread David L Carlson
This is more complicated, but it could be rolled up into a function. Replace 
your mtext() call with the following:

# Set character expansion size
cx - 2.5
# Get the plot coordinates and the character size
ur - par(usr)[c(1, 4)]
chr - par(cxy)
rect(ur[1]+chr[1]/10, ur[2]-chr[2]*cx, ur[1]+chr[1]*cx, ur[2]-chr[1]/10, 
 border=NA, col=white)
text(ur[1]+chr[1]*cx/2, ur[2]-chr[2]*cx/2, a, font=2, cex=2.5, col=red)

1) Assign to cx the cex= value that you are using in text().
2) Then get the upper right corner of the plot window and the size of the 
default character width in user coordinate units.
3) Draw a white rectangle the size of the character you are plotting (in this 
case cex=2.5). Shrink the left and top edge so that the box around the plot 
area is not obscured.
4) Plot your character in the center of the box.

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



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Pascal A. 
Niklaus
Sent: Monday, February 9, 2015 10:27 AM
To: r-help@r-project.org
Subject: [R] Coordinate or top left corner + offset

Dear all,

I am struggling to add annotations to panels of a series of plots 
arranged on a page.

Basically, I'd like to add letters enumerating the panels 
(a,b,c,...), at a fixed distance from the top left corner of the 
plot's box.

I succeeded partly with mtext (see below), but the at option is in 
user coordinates, which makes is difficult to specify a given offset 
from the corner (e.g. 1cm from top and left).

I tried grid's npc but these coordinates refer to the entire plot 
instead of the current inner plotting region.

Phrased differently, I'd like to place text (and ideally also be able to 
plot, e.g. a white disc to cover background items) at position 
(top-1cm,left+1cm)

Here is a minimum working example illustrating what I try to achieve:


pdf(example.pdf,width=15,height=15)

m - rbind( c(0.1,0.9,0.1,0.6),
 c(0.1,0.9,0.6,0.9)
  );

split.screen(m)

screen(1);
par(mar=c(0,0,0,0));
plot(rnorm(10),rnorm(10),xlim=c(-5,5),xaxt=n,yaxt=n);
mtext(quote(bold(a)),side=3,line=-2.5,at=-5,cex=2.5)

screen(2);
par(mar=c(0,0,0,0));
plot(rnorm(10),rnorm(10),xlim=c(-3,3),xaxt=n,yaxt=n);
mtext(quote(bold(a)),side=3,line=-2.5,at=-3,cex=2.5)


close.screen(all.screens=TRUE)

dev.off()


Thanks for your help

Pascal Niklaus

__
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] suggestion for optimal plotting to show significant differences

2015-02-09 Thread PIKAL Petr
Hallo Richard.

I tried your suggestion but it seems to be no better than simple ggplot. Let me 
extend the example a bit to 8 items which is more realistic.

item-rep(letters[1:8], each=18)
day-rep((0:5)*100, 24)
set-rep(rep(1:3, each=6), 8)
test-data.frame(item, day, set)
set.seed(111)
test$value-(test$day/100+1)+rnorm(144)
test$value-test$value+(as.numeric(test$item)*1.3)

Value is increasing during time (day) for each tested subject (item), each item 
is measured 3 times (set) each day.

Here is some graph
p-ggplot(test, aes(x=day, y=value, colour=item))
p+geom_point()+stat_smooth(method=lm, formula= y~poly(x,2))

I can do lm or aov, however I am not sure about proper formula.

fit-lm(value~day, data=test)
summary(fit)
# this shows that value is increasing with day

fit-lm(value~day/item, data=test)
summary(fit)
# this suggests that value is decreasing with day (which is wrong)

fit-lm(value~day*item, data=test)
summary(fit)
# and this tells me that value is increasing with day and items have different 
intercepts but the same rate of growth (I hope I got it right).

I do not have your book available but I went through help pages.

Your interaction graph is not much better than ggplot.
I can do

interaction2wt(value ~ item * day, data=test)

which probably is closer to actual problem.

The basic problem is that increase of value with days is in fact not linear and 
actually it can increase in the beginning and then stagnate or it can stagnate 
in beginning and then increase. I am not aware of any way how to compare time 
behaviour of different items in such situations if I cannot state some common 
formula in which case I would use probably nlme.

Thank for your insight, I try to go through it more deeply.

Best regards
Petr


 -Original Message-
 From: Richard M. Heiberger [mailto:r...@temple.edu]
 Sent: Friday, February 06, 2015 6:14 PM
 To: PIKAL Petr
 Cc: r-help@r-project.org
 Subject: Re: [R] suggestion for optimal plotting to show significant
 differences

 I would try one of these illustrations for starts.
 interaction2wt (two-way tables) is designed to be used with aov() for
 testing.
 interaction2wt shows all main effects and all two-way interactions for
 many factors.



 test -
 structure(list(item = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(A, B), class =
 factor), day = c(0L, 100L, 200L, 300L, 400L, 500L, 0L, 100L, 200L,
 300L, 400L, 500L, 0L, 100L, 200L, 300L, 400L, 500L, 0L, 100L, 200L,
 300L, 400L, 500L, 0L, 100L, 200L, 300L, 400L, 500L, 0L, 100L, 200L,
 300L, 400L, 500L), set = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
 2L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
 2L, 3L, 3L, 3L, 3L, 3L, 3L), value = c(1.08163365169503,
 2.61998412608805, 3.07820466606394, 4.44993419381934, 5.29163171545805,
 6.29155990999293, -0.123163011367676, 2.07767236834003,
 2.32537052874901, 3.09372794501084, 6.65273721166635, 5.92304962329131,
 1.50504697705548, 2.66253728086866, 2.63420157418685, 2.78195098580416,
 6.47578642973288, 5.89587443775143, 0.848864231485078,
 1.27549677119713, 2.19573089053609, 2.45659926134292, 5.15424403414103,
 5.4813151140983, 1.25731482647214, 2.09662105167973, 1.75954023316977,
 4.81624002288939, 4.65029189325307, 6.39946904227214,
 0.944996929887344, 1.74667265331284, 2.42956264345558,
 5.17852980415141, 3.5453435965834, 6.9011238437191)), .Names =
 c(item, day, set, value), row.names = c(NA, -36L), class =
 data.frame)



 library(HH)

 test$set - factor(test$set)
 test$day - factor(test$day)
 test$item - factor(test$item)

 interaction2wt(value ~ item * day * set, data=test)

 test$item.day - interaction(test$item, test$day)
 position(test$item.day) - outer(c(-10,10),
 as.numeric(levels(test$day)), `+`)

 xyplot(value ~ as.position(item.day) | set, groups=item,
 data=test, horizontal=FALSE, pch=c(17,16),
 xlab=day,
 scales=list(
   x=list(
 alternating=1,
 at=levels(test$day), ## placement of tick labels and marks
 tck=1)),
 key=list(
   text=list(c(A,B), col=c(blue,red)),
   points=list(pch=c(17, 16), col=c(blue,red)),
space=top, columns=2, border=TRUE),
layout=c(3,1))


 ## see also the examples in
 demo(package=HH, bwplot.examples)

 On Fri, Feb 6, 2015 at 6:09 AM, PIKAL Petr petr.pi...@precheza.cz
 wrote:
  Dear all
 
  I would like to ask for your opinion about possible graphical
 representation of such data.
 
  dput(test)
  structure(list(item = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(A, B), class
 =
  factor), day = c(0L, 100L, 200L, 300L, 400L, 500L, 0L, 100L, 200L,
  300L, 400L, 500L, 0L, 100L, 200L, 300L, 400L, 500L, 0L, 100L, 200L,
  300L, 400L, 500L, 0L, 

[R] ASA John M. Chambers Statistical Software Award - 2015

2015-02-09 Thread Munjal, Aarti
John M. Chambers Statistical Software Award - 2015

Statistical Computing Section

American Statistical Association


The Statistical Computing Section of the American Statistical Association 
announces the competition for the John M. Chambers Statistical Software Award. 
In 1998 the Association for Computing Machinery presented its Software System 
Award to John Chambers for the design and development of S. Dr. Chambers 
generously donated his award to the Statistical Computing Section to endow an 
annual prize for statistical software written by, or in collaboration with, an 
undergraduate or graduate student. The prize carries with it a cash award of 
$1000, plus a substantial allowance for travel to the annual Joint Statistical 
Meetings (JSM) where the award will be presented.


Teams of up to 3 people can participate in the competition, with the cash award 
being split among team members. The travel allowance will be given to just one 
individual in the team, who will be presented the award at JSM. To be eligible, 
the team must have designed and implemented a piece of statistical software. 
The individual within the team indicated to receive the travel allowance must 
have begun the development while a student, and must either currently be a 
student, or have completed all requirements for her/his last degree after 
January 1, 2014. To apply for the award, teams must provide the following 
materials:


Current CV's of all team members.


A letter from a faculty mentor at the academic institution of the individual 
indicated to receive the travel award. The letter should confirm that the 
individual had substantial participation in the development of the software, 
certify her/his student status when the software began to be developed (and 
either the current student status or the date of degree completion), and 
briefly discuss the importance of the software to statistical practice.


A brief, one to two page description of the software, summarizing what it does, 
how it does it, and why it is an important contribution. If the team member 
competing for the travel allowance has continued developing the software after 
finishing her/his studies, the description should indicate what was developed 
when the individual was a student and what has been added since.


An installable software package with its source code for use by the award 
committee. It should be accompanied by enough information to allow the judges 
to effectively use and evaluate the software (including its design 
considerations.) This information can be provided in a variety of ways, 
including but not limited to a user manual (paper or electronic), a paper, a 
URL, and online help to the system.


All materials must be in English. We prefer that electronic text be submitted 
in Postscript or PDF. The entries will be judged on a variety of dimensions, 
including the importance and relevance for statistical practice of the tasks 
performed by the software, ease of use, clarity of description, elegance and 
availability for use by the statistical community. Preference will be given to 
those entries that are grounded in software design rather than calculation. The 
decision of the award committee is final.


All application materials must be received by 5:00pm EST, Tuesday, February 17, 
2015 at the address below. The winner will be announced in May and the award 
will be given at the 2015 Joint Statistical Meetings.


Chambers Statistical Software Award

c/o Aarti Munjal

Colorado School of Public Health

University of Colorado Denver

aarti.mun...@ucdenver.edumailto:aarti.mun...@ucdenver.edu


[[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] Database connection query

2015-02-09 Thread Lalitha Kristipati
Hi,

I would like to know when to use drivers and when to use packages to connect to 
databases in R

Regards,
Lalitha Kristipati
Associate Software Engineer




Disclaimer:  This message and the information contained herein is proprietary 
and confidential and subject to the Tech Mahindra policy statement, you may 
review the policy at http://www.techmahindra.com/Disclaimer.html externally 
http://tim.techmahindra.com/tim/disclaimer.html internally within TechMahindra.



[[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] Variance is different in R vs. Excel?

2015-02-09 Thread Karl Fetter
Hello everyone, I have a simple question. when I use the var() function in
R to find a variance, it differs greatly from the variance found in excel
using the =VAR.S function. Any explanations on what those two functions are
actually doing?

Here is the data and the results:

dat-matrix(c(402,908,553,522,627,1040,756,679,806,711,713,734,683,790,597,872,476,1026,423,476,419,591,376,640,550,601,588,499,646,693,351,730,632,707,779,838,814,771,533,818),
nrow=20, ncol=2, byrow=T)

var(dat[,1])
#21290.8

var(dat[,2])
#24748.75

#in Excel, the variance of dat[,1] = 44763.91; for dat[,2] = 52034.2

Thanks,

Karl

[[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] neural network, random forest with survey data

2015-02-09 Thread ying_chen wang
Hi, everyone:

Does anyone know if any statistical packages (such as R) can accommodate
neural network or random forest with survey data?

With survey data, we have to incorporate weight with sampling issue or even
with design effect.

Would appreciate if anyone can help.

Grace

[[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] Variance is different in R vs. Excel?

2015-02-09 Thread David L Carlson
Time for a new version of Excel? I cannot duplicate your results in Excel 2013.

R:
 apply(dat, 2, var)
[1] 21290.80 24748.75

Excel 2013:
=VAR.S(A2:A21)   =VAR.S(B2:B21)
21290.8  24748.74737

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


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Karl Fetter
Sent: Monday, February 9, 2015 3:33 PM
To: r-help@r-project.org
Subject: [R] Variance is different in R vs. Excel?

Hello everyone, I have a simple question. when I use the var() function in
R to find a variance, it differs greatly from the variance found in excel
using the =VAR.S function. Any explanations on what those two functions are
actually doing?

Here is the data and the results:

dat-matrix(c(402,908,553,522,627,1040,756,679,806,711,713,734,683,790,597,872,476,1026,423,476,419,591,376,640,550,601,588,499,646,693,351,730,632,707,779,838,814,771,533,818),
nrow=20, ncol=2, byrow=T)

var(dat[,1])
#21290.8

var(dat[,2])
#24748.75

#in Excel, the variance of dat[,1] = 44763.91; for dat[,2] = 52034.2

Thanks,

Karl

[[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] Variance is different in R vs. Excel?

2015-02-09 Thread Ted Harding
[See at end]

On 09-Feb-2015 21:45:11 David L Carlson wrote:
 Time for a new version of Excel? I cannot duplicate your results in Excel
 2013.
 
 R:
 apply(dat, 2, var)
 [1] 21290.80 24748.75
 
 Excel 2013:
 =VAR.S(A2:A21)   =VAR.S(B2:B21)
 21290.8  24748.74737
 
 -
 David L Carlson
 Department of Anthropology
 Texas AM University
 College Station, TX 77840-4352
 
 
 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Karl Fetter
 Sent: Monday, February 9, 2015 3:33 PM
 To: r-help@r-project.org
 Subject: [R] Variance is different in R vs. Excel?
 
 Hello everyone, I have a simple question. when I use the var() function in
 R to find a variance, it differs greatly from the variance found in excel
 using the =VAR.S function. Any explanations on what those two functions are
 actually doing?
 
 Here is the data and the results:
 
 dat-matrix(c(402,908,553,522,627,1040,756,679,806,711,713,734,683,790,597,872
 ,476,1026,423,476,419,591,376,640,550,601,588,499,646,693,351,730,632,707,779,
 838,814,771,533,818),
 nrow=20, ncol=2, byrow=T)
 
 var(dat[,1])
#21290.8
 
 var(dat[,2])
#24748.75
 
#in Excel, the variance of dat[,1] = 44763.91; for dat[,2] = 52034.2
 
 Thanks,
 Karl

I suspect that something has happened to the reading-in of the
data into Excel. (I don't know much about Excel, and that's because
I don't want to ... ).

The ratio of the variances of the two datasets in R is:

  var(dat[,2])/var(dat[,1])
  # [1] 1.162415

while the ratio of th results from Excel is:

  52034.2/44763.91
  # [1] 1.162414

so they are almost identical. 

So it is as if Excel was evaluating the variances for data which
are

  sqrt(44763.91/var(dat[,1]))
  # [1] 1.45
  sqrt(52034.2/var(dat[,2]))
  # [1] 1.44

times the data used by R. So maybe there's a nasty lurking somewhere
in the spreadsheet? (Excel is notorious for planting things invisibly
in its spreadsheets which lead to messed-up results for no apparent
reasion ... ).

Hoping this helps,
Ted.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 09-Feb-2015  Time: 22:15:44
This message was sent by XFMail

__
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] Donwload youtube videos

2015-02-09 Thread Raoni Rodrigues
Hello R-helpers,

It is possible donwload youtube videos with R? I made a google search and
find no options to do that.

Thanks in advanced,

Raoni

[[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] Database connection query

2015-02-09 Thread Marc Schwartz

 On Feb 9, 2015, at 4:33 AM, Lalitha Kristipati 
 lalitha.kristip...@techmahindra.com wrote:
 
 Hi,
 
 I would like to know when to use drivers and when to use packages to connect 
 to databases in R
 
 Regards,
 Lalitha Kristipati
 Associate Software Engineer


In general, you will need both.

There is more information in the R Data Import/Export manual:

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

and there is a SIG list for R and DB specific subject matter:

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

Regards,

Marc Schwartz

__
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] Save a plot with a name given as an argument in a function

2015-02-09 Thread Jorge I Velez
Hi Evgenia,

Try

test2 - function(data, TitleGraph){
pdf(paste0(TitleGraph, .pdf), width = 7, height = 5)
plot(data)
dev.off()
}

instead.  Take a look at ?paste0 for more information.

HTH,
Jorge.-


On Tue, Feb 10, 2015 at 12:14 AM, Evgenia ev...@aueb.gr wrote:

 test-function(data, TitleGraph){


 pdf(TitleGraph.pdf,width=7,height=5)
 plot(data)
 dev.off()
 }

 test(cars - c(1, 3, 6, 4, 9),TitleGraph=etc)

 My problem is that I  want graph pdf being saved as etc and not as
 Titlegraph.pdf




 --
 View this message in context:
 http://r.789695.n4.nabble.com/Save-a-plot-with-a-name-given-as-an-argument-in-a-function-tp4702965.html
 Sent from the R help mailing list archive at Nabble.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] Save a plot with a name given as an argument in a function

2015-02-09 Thread Evgenia
Thanks alot




--
View this message in context: 
http://r.789695.n4.nabble.com/Save-a-plot-with-a-name-given-as-an-argument-in-a-function-tp4702965p4702969.html
Sent from the R help mailing list archive at Nabble.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] Coordinate or top left corner + offset

2015-02-09 Thread Ben Bolker
David L Carlson dcarlson at tamu.edu writes:

 
 This is more complicated, but it could be rolled up into a function.
Replace your mtext() call with the following:
 
 # Set character expansion size
 cx - 2.5
 # Get the plot coordinates and the character size
 ur - par(usr)[c(1, 4)]
 chr - par(cxy)
 rect(ur[1]+chr[1]/10, ur[2]-chr[2]*cx, ur[1]+chr[1]*cx, ur[2]-chr[1]/10, 
  border=NA, col=white)
 text(ur[1]+chr[1]*cx/2, ur[2]-chr[2]*cx/2, a, font=2, cex=2.5, col=red)
 
 1) Assign to cx the cex= value that you are using in text().
 2) Then get the upper right corner of the plot window and the size of the
default character width in user
 coordinate units.
 3) Draw a white rectangle the size of the character you are plotting (in
this case cex=2.5). Shrink the left
 and top edge so that the box around the plot area is not obscured.
 4) Plot your character in the center of the box.
 

  There are two more tricks you can use here:

  (1) cheat by using legend()

plot(0:10,0:10)
legend(topleft,legend=NA,title=hello,bty=n)

  (2) use plotrix::corner.label

__
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] Trabajar en un único formato de codificación

2015-02-09 Thread javier.ruben.marcuzzi
Estimado Javier Villacampa González






Su problema es conocido, por lo menos por mi, no por inteligente sino por lo 
que sufrí cuando vendí mi mac y muchas cosas no funcionaban. 


Aunque abras el archivo y lo puedas leer (con tus ojos, no de forma 
informática) aparecen problemas. Un asesor me dio la solución, y esta consistía 
en abrir y guardar el archivo con un programa de textos (que no recuerdo) pero 
que permitía cambiar el formato entre los sistemas operativos, porque la 
finalización de línea es diferente.


Javier Rubén Marcuzzi





De: Javier Villacampa González
Enviado el: ‎viernes‎, ‎06‎ de ‎febrero‎ de ‎2015 ‎12‎:‎36‎ ‎p.m.
Para: R-help-es@r-project.org





Hola buenas,

quería preguntaros si alguno me podría ayudar con lo siguiente.

Estoy ayudando a unos colegas de japón con un estudio de palabras. Y nos
ocurre lo siguiente.
Yo hago los scripts y guardo los RDatao csv, pero estamos teniendo
problemas de compatibilidad entre sistemas.

Me gustaría que se pudiese guardar todos ficheros de R en el mismo formato
de codificación de datos. Los ficheros R, los ficheros csv y sobretodo los
RData y así evitar problemas de codificación.

Muchas gracias por adelantado
#-
PD: Momento frustración...

1)Ya que si yo leo el fichero csv como UTF-16 pero luego guarda el csv como
otra cosa es un pequeño infierno para hacer los scripts compatibles.

2)Porque si leo el csv en mac y me guarda los RData en una codificación,
luego en windows lo hace de otra... al final no hay maldita manera de
pasarles un modelo. Malditamente frustrante...


--

 [[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] Save a plot with a name given as an argument in a function

2015-02-09 Thread Evgenia
test-function(data, TitleGraph){


pdf(TitleGraph.pdf,width=7,height=5)
plot(data)
dev.off()
}

test(cars - c(1, 3, 6, 4, 9),TitleGraph=etc)

My problem is that I  want graph pdf being saved as etc and not as
Titlegraph.pdf




--
View this message in context: 
http://r.789695.n4.nabble.com/Save-a-plot-with-a-name-given-as-an-argument-in-a-function-tp4702965.html
Sent from the R help mailing list archive at Nabble.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] Variance is different in R vs. Excel?

2015-02-09 Thread Ranjan Maitra
I suspect that this is the long-documented issue with indeed an entire industry 
-- and publications -- devoted to finding such errors in Excel. Till the 2013 
version, it used to be a favorite HW problem of mine. Basically, Excel uses the 
short formula to calculate the variance and the sd. This short formula has 
numerical issues with larger numbers (though I am surprised at the OP's data 
because these numbers were not that large). Anyway, the long formula which 
removes the mean from each datapoint, squares and sums is preferred with large 
numbers. 

Btw, my HW problem for incoming students in my R class would be this:

Consider the following numbers:
101, 102, 101, 102, 
101,
102, 101, 102, 101, 
102.

Calculate the variance in Excel (gives pure garbage) and in R.

I got this (or may have adapted it) from the book: Numerical Issues in 
Statistical Computing for the Social Scientist by M. Altman, J. Gill and M. P. 
McDonald.

After over 10 years, Excel finally appears to have fixed the issue. gnumeric 
never had this problem.

Best wishes,
Ranjan


On Mon, 9 Feb 2015 22:15:48 + Ted Harding ted.hard...@wlandres.net wrote:

 [See at end]
 
 On 09-Feb-2015 21:45:11 David L Carlson wrote:
  Time for a new version of Excel? I cannot duplicate your results in Excel
  2013.
  
  R:
  apply(dat, 2, var)
  [1] 21290.80 24748.75
  
  Excel 2013:
  =VAR.S(A2:A21)   =VAR.S(B2:B21)
  21290.8  24748.74737
  
  -
  David L Carlson
  Department of Anthropology
  Texas AM University
  College Station, TX 77840-4352
  
  
  -Original Message-
  From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Karl Fetter
  Sent: Monday, February 9, 2015 3:33 PM
  To: r-help@r-project.org
  Subject: [R] Variance is different in R vs. Excel?
  
  Hello everyone, I have a simple question. when I use the var() function in
  R to find a variance, it differs greatly from the variance found in excel
  using the =VAR.S function. Any explanations on what those two functions are
  actually doing?
  
  Here is the data and the results:
  
  dat-matrix(c(402,908,553,522,627,1040,756,679,806,711,713,734,683,790,597,872
  ,476,1026,423,476,419,591,376,640,550,601,588,499,646,693,351,730,632,707,779,
  838,814,771,533,818),
  nrow=20, ncol=2, byrow=T)
  
  var(dat[,1])
 #21290.8
  
  var(dat[,2])
 #24748.75
  
 #in Excel, the variance of dat[,1] = 44763.91; for dat[,2] = 52034.2
  
  Thanks,
  Karl
 
 I suspect that something has happened to the reading-in of the
 data into Excel. (I don't know much about Excel, and that's because
 I don't want to ... ).
 
 The ratio of the variances of the two datasets in R is:
 
   var(dat[,2])/var(dat[,1])
   # [1] 1.162415
 
 while the ratio of th results from Excel is:
 
   52034.2/44763.91
   # [1] 1.162414
 
 so they are almost identical. 
 
 So it is as if Excel was evaluating the variances for data which
 are
 
   sqrt(44763.91/var(dat[,1]))
   # [1] 1.45
   sqrt(52034.2/var(dat[,2]))
   # [1] 1.44
 
 times the data used by R. So maybe there's a nasty lurking somewhere
 in the spreadsheet? (Excel is notorious for planting things invisibly
 in its spreadsheets which lead to messed-up results for no apparent
 reasion ... ).
 
 Hoping this helps,
 Ted.
 
 -
 E-Mail: (Ted Harding) ted.hard...@wlandres.net
 Date: 09-Feb-2015  Time: 22:15:44
 This message was sent by XFMail
 
 __
 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.
 


-- 
Important Notice: This mailbox is ignored: e-mails are set to be deleted on 
receipt. Please respond to the mailing list if appropriate. For those needing 
to send personal or professional e-mail, please use appropriate addresses.


Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords  protects your account.

__
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

2015-02-09 Thread Andrés Felipe Flórez Rivera
Hi everyone,

I am trying to automate (on a Win7 system) an R script to read data from a
DB2 data base and write it to file, for processing by another system. My
code runs in the R gui perfectly. So I wrote a batch file to call this .r
file and output results to script.out as shown below. When I double click
the batch file everything runs successfully. When I schedule a task to run
the batch file, the R code runs, collects data from DB2 data base, but the
write to file fails every time, only save the header from sql query.

R Code:

library(RJDBC)
library(rJava)
jcc = JDBC(com.ibm.db2.jcc.DB2Driver,.../db2jcc4.jar)
conn = dbConnect(jcc,xxx,user=,password=)
bd1 = dbSendUpdate(conn, set current schema PRODUCCION)
bd1 = dbSendQuery(conn,
paste(SELECT *
FROM VW_tabla_1))
dat4- fetch(bd1, n = -1)
write.csv2(dat4,file = .../bd1.csv,row.names = F)
dbDisconnect(conn)


batch file code:

\Program Files\R\R-3.0.1\bin\x64\R.exe CMD BATCH --vanilla --slave
C:\Users\abg\SkyDrive\Documents\dat.R


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] How to solve this complex equation

2015-02-09 Thread Ssuhanchen
Hi!

I want to use R to calculate the variable x which is in a complex equation
in below:

 2
 Σ[exp(-x/2)*(x^k)/(2^k*k!)]=0.05
k=0

how to solve this equation to get the exact x in R? 

Thank you very much.




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-solve-this-complex-equation-tp4702997.html
Sent from the R help mailing list archive at Nabble.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] Ezoic and r-project.org

2015-02-09 Thread Piper Lofrano
Hi there,

Firstly, congrats; r-project.org is an awesome site.  Do you work on it full 
time or is it a hobby? 

Ezoic is the first Google AdSense certified partner headquartered in the US 
that helps sites increase AdSense earnings through layout improvement. Have you 
ever considered testing your site's layout and ad placements? I know it sounds 
implausible, but testing new layouts of the exact same content can increase 
your ad income 50-250% and significantly enhance the user experience, which is 
one of the most important ranking factors! 

Ezoic can help you do this; would it be alright if I sent you some info? 

Cheers,

Piper
www.ezoic.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] Latest version of Rtools is incompatible with latest version of R !!

2015-02-09 Thread SirChill88
This solved my problem too. Thank you!



--
View this message in context: 
http://r.789695.n4.nabble.com/Latest-version-of-Rtools-is-incompatible-with-latest-version-of-R-tp4701853p4703000.html
Sent from the R help mailing list archive at Nabble.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.