[R] Issues with fa() function in psych

2014-04-08 Thread sagnik chakravarty
Hi Team,

I was using your psych package for factor analysis and was also comparing
the results with SAS results. I have some suggestions and/or confusions
regarding the fa() function in the package:

   - The fa() function *doesn't account for Heywood cases* (communality
   greater than 1) and never ever throws out any error related to that which
   other softwares do. This is a serious and common issue in iterative factor
   analysis and hence should have been accounted for.


   - The fa() function doesn't provide equamax rotation in its rotation
   list and still if you specify *rotation=equamax*, it will run without
   throwing out any error and even mentioning in the result that equamax has
   been applied. But I have thoroughly compared results from 
   *rotation=none* and *rotation=equamax* options and they are exactly
   same. *That means fa() is not doing the rotation at all and yet telling
   that it is doing that!!* I have even mentioned *rotation=crap* option
   just to check and surprisingly it ran(without any error) with the result
   showing:

   *Factor Analysis using method =  gls*
*   Call: fa(r = cor_mat, nfactors = 4, n.obs = 69576, rotate =
crap, fm = gls)*

I hope you understand the severity of this bug and hence
request you to correct this.

   - To my sense, there might be some problem with fm=ml and fm=pa
   options since the convergence issue should be with MLE method and not PA
   method but while running factor analysis with PA, I am getting the
   following warning:

*maximum iteration exceeded*
*The estimated weights for the factor scores are probably
incorrect.  Try a different factor extraction method.*

 If I compare the results of R and SAS,* I am getting
convergence error for MLE in SAS whereas I am getting the same error for PA
in R *!! I am not being able to understand this mismatch.

   - If I call the *loading matrix like efa_pa$loadings, the matrix shown
   has many blank cells whereas the final result showing the loadings doesn't
   have so* !!

*Loadings:*
* PA1PA2PA3PA4   *
*Var10.401   -0.243*
*Var20.336 -0.1040.710*
*Var30.624  0.123 0.170  *


   - Could you please explain* what the com column means* in the output:?


*   PA1   PA3   PA2   PA4 h2  u2  com*
*Var1  0.44  0.14 -0.03  -0.10 0.22665  0.773  1.3*
*Var2  0.08  0.11  0.02   0.78  0.62951  0.370  1.1*
*Var3  0.62  0.12  0.15   0.14  0.43578  0.564  1.3*

   - Request you to add option for *equamax rotation* also if possible.


I have come across the above issues until now. Please do correct me if I am
wrong.

Awaiting your revert which would clear out my confusions,

Thanks for your valuable time,

Sagnik

-- 
Regards,

*SAGNIK CHAKRAVARTY*

*Mob:*  +919972865435
*Email:* sagnik.st...@gmail.com
   sagnik@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Issues with fa() function in psych

2014-04-08 Thread Pascal Oettli
Hello,

And what about submitting your suggestions directly to the package
author/maintainer?

And please don't post in HTML.

Regards,
Pascal

On Tue, Apr 8, 2014 at 3:13 PM, sagnik chakravarty
sagnik.st...@gmail.com wrote:
 Hi Team,

 I was using your psych package for factor analysis and was also comparing
 the results with SAS results. I have some suggestions and/or confusions
 regarding the fa() function in the package:

- The fa() function *doesn't account for Heywood cases* (communality
greater than 1) and never ever throws out any error related to that which
other softwares do. This is a serious and common issue in iterative factor
analysis and hence should have been accounted for.


- The fa() function doesn't provide equamax rotation in its rotation
list and still if you specify *rotation=equamax*, it will run without
throwing out any error and even mentioning in the result that equamax has
been applied. But I have thoroughly compared results from 
*rotation=none* and *rotation=equamax* options and they are exactly
same. *That means fa() is not doing the rotation at all and yet telling
that it is doing that!!* I have even mentioned *rotation=crap* option
just to check and surprisingly it ran(without any error) with the result
showing:

*Factor Analysis using method =  gls*
 *   Call: fa(r = cor_mat, nfactors = 4, n.obs = 69576, rotate =
 crap, fm = gls)*

 I hope you understand the severity of this bug and hence
 request you to correct this.

- To my sense, there might be some problem with fm=ml and fm=pa
options since the convergence issue should be with MLE method and not PA
method but while running factor analysis with PA, I am getting the
following warning:

 *maximum iteration exceeded*
 *The estimated weights for the factor scores are probably
 incorrect.  Try a different factor extraction method.*

  If I compare the results of R and SAS,* I am getting
 convergence error for MLE in SAS whereas I am getting the same error for PA
 in R *!! I am not being able to understand this mismatch.

- If I call the *loading matrix like efa_pa$loadings, the matrix shown
has many blank cells whereas the final result showing the loadings doesn't
have so* !!

 *Loadings:*
 * PA1PA2PA3PA4   *
 *Var10.401   -0.243*
 *Var20.336 -0.1040.710*
 *Var30.624  0.123 0.170  *


- Could you please explain* what the com column means* in the output:?


 *   PA1   PA3   PA2   PA4 h2  u2  com*
 *Var1  0.44  0.14 -0.03  -0.10 0.22665  0.773  1.3*
 *Var2  0.08  0.11  0.02   0.78  0.62951  0.370  1.1*
 *Var3  0.62  0.12  0.15   0.14  0.43578  0.564  1.3*

- Request you to add option for *equamax rotation* also if possible.


 I have come across the above issues until now. Please do correct me if I am
 wrong.

 Awaiting your revert which would clear out my confusions,

 Thanks for your valuable time,

 Sagnik

 --
 Regards,

 *SAGNIK CHAKRAVARTY*

 *Mob:*  +919972865435
 *Email:* sagnik.st...@gmail.com
sagnik@gmail.com

 [[alternative HTML version deleted]]

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



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] {metafor} variance explaination for paired pre-test/posttest

2014-04-08 Thread Viechtbauer Wolfgang (STAT)
The standardized mean change using 'change score standardization' is described 
in this article:

Gibbons, R. D., Hedeker, D. R.,  Davis, J. M. (1993). Estimation of effect 
size from a series of experiments involving paired comparisons. Journal of 
Educational Statistics, 18(3), 271-279.

For a comparison of the standardized mean change using change versus raw score 
standardization, see:

Morris, S. B.,  DeShon, R. P. (2002). Combining effect size estimates in 
meta-analysis with repeated measures and independent-groups designs. 
Psychological Methods, 7(1), 105-125.

Viechtbauer, W. (2007). Approximate confidence intervals for standardized 
effect sizes in the two-independent and two-dependent samples design. Journal 
of Educational and Behavioral Statistics, 32(1), 39-60.

These articles also provide equations for the sampling variance of the 
standardized mean change. The equation 1/ni + yi^2/(2*ni) is the estimate based 
on the asymptotic variance of the standardized mean change using change score 
standardization. 

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of John Williams
 Sent: Tuesday, April 08, 2014 02:30
 To: r-help@r-project.org
 Subject: [R] {metafor} variance explaination for paired pre-test/posttest
 
 In a previous post
 https://stat.ethz.ch/pipermail/r-help/2012-April/308946.html
 https://stat.ethz.ch/pipermail/r-help/2012-April/308946.html  , the
 following calculation was given for imputing the variance of change
 scores
 for paired studies:
 
 // begin quote
 
 2) Often, the dependent variable is not the same in each study. Then you
 will have to resort to a standardized outcome measure. There are two
 options:
 
 a) standardization based on the change score standard deviation
 
 Then yi = (m1i - m2i) / sdi with sampling variance vi = 1/ni + yi^2 /
 (2*ni).
 
 // end quote
 
 I used the sampling variance equation above in a paper that is being
 reviewed by a coauthor, who is a biostatistician.
 
 He commented that he has never seen this equation for variance before,
 and
 it looks strange to him. To put my knowledge into perspective, I am an
 undergraduate taking my first statistics course. I imputed the t-
 statistic
 from two-sided p-values reported in the paper, and used that to get the
 sdi
 (as in the previous post).
 
 I consulted the Cochrane Handbook and The Handbook of Research Syntheses
 and
 Meta-analysis 2nd Ed (Cooper, Hedges, Valentine 2009) and couldn't find
 that
 equation anywhere.
 
 Would Prof. Viechtbauer, or anyone else knowledgeable, mind explaining
 the
 sample variance above? I need to be able to defend my choice of equation.
 Since it's the only method that I found that doesn't rely on a
 correlation
 coefficient (which are not included in the papers), I'd like to be able
 to
 justify it and not redo calculations for 23 studies if possible.
 
 Thank you very much,
 
 John
 
 
 John Williams
 ALB Candidate, Harvard University (Expected May 2014)
 johnwilli...@fas.harvard.edu
 jawilliam...@gmail.com

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


Re: [R] {metafor} variance explaination for paired pre-test/posttest

2014-04-08 Thread John Williams
Prof. Viechtbauer, thanks for the articles. I appreciate your help.

Yours,

John 
 
 
John Williams 
ALB Candidate, Harvard University (Expected May 2014) 
johnwilli...@fas.harvard.edu
jawilliam...@gmail.com



--
View this message in context: 
http://r.789695.n4.nabble.com/metafor-variance-explaination-for-paired-pre-test-posttest-tp4688365p4688382.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] rpart and randomforest results

2014-04-08 Thread John Maindonald
The function rpart may well overfit if the value of the CP statistic
is left at its default.  Use the functions printcp() and plotcP() to
check how the cross-validation estimate of relative ‘error’ (xerror)
changes with the number of splits (NB that the CP that leads to a
further split changes monotonically with the number of splits).
The ‘rel error’ column from printcp() can be hopelessly optimistic.


John Maindonald email: 
john.maindon...@anu.edu.aumailto:john.maindon...@anu.edu.au

phone : +61 2 (6125)3473fax  : +61 2(6125)5549

Centre for Mathematics  Its Applications, Room 1194,

John Dedman Mathematical Sciences Building (Building 27)

Australian National University, Canberra ACT 0200.


On 8/04/2014, at 8:00 pm, 
r-help-requ...@r-project.orgmailto:r-help-requ...@r-project.org wrote:

From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of Schillo, Sonja
Sent: Thursday, April 03, 2014 3:58 PM
To: Mitchell Maltenfort
Cc: r-help@r-project.orgmailto:r-help@r-project.org
Subject: Re: [R] rpart and randomforest results

Hi,

the random forest should do that, you're totally right. As far as I know it 
does so by randomly selecting the variables considered for a split (but here we 
set the option for how many variables to consider at each split to the number 
of variables available so that I thought that the random forest does not have 
the chance to randomly select the variables). The next thing that randomforest 
does is bootstrapping. But here again we set the option to the number of cases 
we have in the data set so that no bootstrapping should be done.
We tried to take all the randomness from the randomforest away.

Is that plausible and does anyone have another idea?

Thanks
Sonja


[[alternative HTML version deleted]]

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


Re: [R] Time interactions for coxph object

2014-04-08 Thread Therneau, Terry M., Ph.D.
 The very first step is to understand the possible nature of proportional hazards.  This 
is parallel to the usual advice in linear models to graph the data before you start 
fitting complicated non-linear models.

 zp - cox.zph(CSHR.shore.fly, transform=identity)
 plot(zp)# or plot(zp[3]) for the third variable of a model, but you have 
only 1
 print(zp)

This looks at the working model hazard = exp( beta(t) * x); a time dependent 
coefficient.
Propoprtional hazards corresponds to a horizontal line, i.e., beta(t) = 
constant.

The steps are
  1. Visualize
  2. THINK
  3. Act appropriately

The tt addition to coxph allows complex time-dependent coefficients and is explained in a 
vignette. (See ?vignette). I've seen scores of data sets with non-proportional hazards, 
and used the tt functionality perhaps 3 times.  Don't jump too quickly into complexity.


Terry Therneau

-  begin included message -




Hi All,

I am working in the 'survival' library and need to know how to code a
variable time interaction for left truncated data (not all subjects
followed from the start of the study). I therefor add in the entry time and
exit time variables into the formula.

Here is my basic formula

CSHR.shore.fly - coxph(Surv(entry, exit, to == 1) ~ shore.cat, data
  glba.mod)

My variable shore.cat is violating the proportional hazards assumption so I
am trying to add in an interaction with time. Do I interact exit? entry? or
the range of the two?

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


Re: [R] What Directs R to Executable Directory? [RESOLVED]

2014-04-08 Thread Rich Shepard

On Mon, 7 Apr 2014, Rich Shepard wrote:


However, when I try to start R as either a user or as root it aborts because
it cannot find /usr/local/bin/R.


  When I stepped back from the problem, but shutting down the laptop for the
evening, it occurred to me that the system needed to be rebooted to see the
new installation and forget about the older one. Sure enough, when I booted
the laptop this morning, R worked as expected.

Thanks very much, Bill,

Rich

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


[R] locating a data value in 3-dimensional data set

2014-04-08 Thread mamuash bukana
I have a 3-dimentional data set with dimensions longitude,
latitude, and time. Unfortunately, when I look at the range of
values in the data set, I noticed some very extremely large(positive
and negative) values which are unexpected to be there. So I wanted to
point-out the location (lon, lat and time) which these extreme values
correspond to in order to see what is happening there. But I could not
point-out these grid points and time.

I tried:
which(3ddata==x) # 3ddata is name of data set, x is the observed extreme value
But this couldn't help me.

Any suggestion please?

Thanks

B

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


Re: [R] locating a data value in 3-dimensional data set

2014-04-08 Thread S Ellison
 I tried:
 which(3ddata==x) # 3ddata is name of data set, x is the observed extreme
 value But this couldn't help me.

You'll need which(3ddata$long==x) if 3ddata is a data frame* with columns long, 
lat, time, or something like 3ddata[ ,'long'] if it's a matrix with dimnames or 
[,1] if just a matrix.

But you'll be better off with =x if the values are floating point; see R FAQ 
7.31

*clearly, '3ddata' cannot be a data frame name - it's not legal R. I assume you 
have some legal name for it.




***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] locating a data value in 3-dimensional data set

2014-04-08 Thread Kehl Dániel
Dear Mamuash Bukana,

is this a data frame with variable names you indicated?

you will need something like which(dataframename$variablename == x) 
but if you have more you might use 

HTH
kd

Feladó: r-help-boun...@r-project.org [r-help-boun...@r-project.org] ; 
meghatalmaz#243;: mamuash bukana [mamushbuk...@gmail.com]
Küldve: 2014. április 8. 15:50
To: r-help@r-project.org
Tárgy: [R] locating a data value in 3-dimensional data set

I have a 3-dimentional data set with dimensions longitude,
latitude, and time. Unfortunately, when I look at the range of
values in the data set, I noticed some very extremely large(positive
and negative) values which are unexpected to be there. So I wanted to
point-out the location (lon, lat and time) which these extreme values
correspond to in order to see what is happening there. But I could not
point-out these grid points and time.

I tried:
which(3ddata==x) # 3ddata is name of data set, x is the observed extreme value
But this couldn't help me.

Any suggestion please?

Thanks

B

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

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


Re: [R] locating a data value in 3-dimensional data set

2014-04-08 Thread Frede Aakmann Tøgersen
Hi

I know there is a arr.index (or something like that,  I'm not near my R right 
now) argument to which (). I have used it for 2-dim arrays and never for higher 
dimensions. But try it out by setting the argument to TRUE.

Br. Frede


Sendt fra Samsung mobil


 Oprindelig meddelelse 
Fra: mamuash bukana
Dato:08/04/2014 15.51 (GMT+01:00)
Til: r-help@r-project.org
Emne: [R] locating a data value in 3-dimensional data set

I have a 3-dimentional data set with dimensions longitude,
latitude, and time. Unfortunately, when I look at the range of
values in the data set, I noticed some very extremely large(positive
and negative) values which are unexpected to be there. So I wanted to
point-out the location (lon, lat and time) which these extreme values
correspond to in order to see what is happening there. But I could not
point-out these grid points and time.

I tried:
which(3ddata==x) # 3ddata is name of data set, x is the observed extreme value
But this couldn't help me.

Any suggestion please?

Thanks

B

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

[[alternative HTML version deleted]]

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


Re: [R] locating a data value in 3-dimensional data set

2014-04-08 Thread Frede Aakmann Tøgersen
Sorry forgot to mention that you probably are better of using = and = instead 
of ==

Br. Frede


Sendt fra Samsung mobil


 Oprindelig meddelelse 
Fra: mamuash bukana
Dato:08/04/2014 15.51 (GMT+01:00)
Til: r-help@r-project.org
Emne: [R] locating a data value in 3-dimensional data set

I have a 3-dimentional data set with dimensions longitude,
latitude, and time. Unfortunately, when I look at the range of
values in the data set, I noticed some very extremely large(positive
and negative) values which are unexpected to be there. So I wanted to
point-out the location (lon, lat and time) which these extreme values
correspond to in order to see what is happening there. But I could not
point-out these grid points and time.

I tried:
which(3ddata==x) # 3ddata is name of data set, x is the observed extreme value
But this couldn't help me.

Any suggestion please?

Thanks

B

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

[[alternative HTML version deleted]]

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


[R] Ignore escape characters in a string...

2014-04-08 Thread Jonathan Greenberg
R-helpers:

One of the minor irritations I have is copying paths from Windows
explorer, which look like:

C:\Program Files\R\R-3.0.3

and using them in a setwd() statement, since the \ is, of course,
interpreted as an escape character.  I have to, at present, manually
add in the double slashes or reverse them.

So, I'd like to write a quick function that takes this path:

winpath - C:\Program Files\R\R-3.0.3

and converts it to a ready-to-go R path -- is there a way to have R
IGNORE escape characters in a character vector?

Alternatively, is there some trick to using a copy/paste from Windows
explorer I'm not aware of?

--j



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

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


Re: [R] Ignore escape characters in a string...

2014-04-08 Thread Barry Rowlingson
On Tue, Apr 8, 2014 at 4:00 PM, Jonathan Greenberg j...@illinois.eduwrote:

 C:\Program Files\R\R-3.0.3


Does R on windows have clipboard support? I can do this on Linux:

  readLines(file(clipboard))
[1] C:\\Program Files\\R\\R-3.0.3

- that's from a copy of a path with only single slashes in. But
help(connections) on my linux system doesn't mention the Windows
clipboard

Some ppl on SO have assorted solutions involving Windows scripting tools
that tweak the clipboard so you can Ctrl-V a modified value:

http://stackoverflow.com/questions/1407238/relief-from-backslash-irritation-in-r-for-windows

Barry

[[alternative HTML version deleted]]

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


Re: [R] Ignore escape characters in a string...

2014-04-08 Thread Frede Aakmann Tøgersen
Yes R on Windows have something like that you mentioned. I have only tried it 
in conjunction with read.table.

I'm a bit surprised about the \\ on a linux OS. I'm also surprised that in a 
file manager on Windows you can paste e.g. C:/users/frtog/Desktop and it can 
find its way to the folder. Weird.

Br. Frede


Sendt fra Samsung mobil


 Oprindelig meddelelse 
Fra: Barry Rowlingson
Dato:08/04/2014 17.20 (GMT+01:00)
Til: Jonathan Greenberg
Cc: r-help
Emne: Re: [R] Ignore escape characters in a string...

On Tue, Apr 8, 2014 at 4:00 PM, Jonathan Greenberg j...@illinois.eduwrote:

 C:\Program Files\R\R-3.0.3


Does R on windows have clipboard support? I can do this on Linux:

  readLines(file(clipboard))
[1] C:\\Program Files\\R\\R-3.0.3

- that's from a copy of a path with only single slashes in. But
help(connections) on my linux system doesn't mention the Windows
clipboard

Some ppl on SO have assorted solutions involving Windows scripting tools
that tweak the clipboard so you can Ctrl-V a modified value:

http://stackoverflow.com/questions/1407238/relief-from-backslash-irritation-in-r-for-windows

Barry

[[alternative HTML version deleted]]

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

[[alternative HTML version deleted]]

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


Re: [R] Ignore escape characters in a string...

2014-04-08 Thread Rui Barradas

Hello,

There is support for the clipboard on Windows 7.
Also, note that on Windows your solution leaves a connection open so 
maybe the following is better.


# copy the next line
C:\Program Files\R\R-3.0.3

clipb - file(clipboard)
winpath - readLines(clipb)
close(clipb)


And, just to avoid backslashes altogether,

fun - function(x) gsub(, /, x)
fun(winpath)

Hope this helps,

Rui Barradas

Em 08-04-2014 16:17, Barry Rowlingson escreveu:

On Tue, Apr 8, 2014 at 4:00 PM, Jonathan Greenberg j...@illinois.eduwrote:


C:\Program Files\R\R-3.0.3



Does R on windows have clipboard support? I can do this on Linux:

   readLines(file(clipboard))
[1] C:\\Program Files\\R\\R-3.0.3

- that's from a copy of a path with only single slashes in. But
help(connections) on my linux system doesn't mention the Windows
clipboard

Some ppl on SO have assorted solutions involving Windows scripting tools
that tweak the clipboard so you can Ctrl-V a modified value:

http://stackoverflow.com/questions/1407238/relief-from-backslash-irritation-in-r-for-windows

Barry

[[alternative HTML version deleted]]

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



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


Re: [R] Ignore escape characters in a string...

2014-04-08 Thread Barry Rowlingson
On Tue, Apr 8, 2014 at 4:30 PM, Frede Aakmann Tøgersen fr...@vestas.comwrote:


 I'm a bit surprised about the \\ on a linux OS. I'm also surprised that in
 a file manager on Windows you can paste e.g. C:/users/frtog/Desktop and it
 can find its way to the folder. Weird.


 Well, the clipboard contained a path separated by single backslashes. R
read that (via the file(clipboard)) and correctly read single
backslashes. Its only when printed out that R 'escapes' them as
double-backslashes - there's really only one character there.

 What R seems to lack is 'raw string'  functionality. In python you do this
with a string quote prefix, for example 'r':

  len(\t)
 1

 In that case the \t is interpreted as a single character, \t, or tab. Add
the r modifier:

 len(r\t)
2

and now you get two characters, backslash and t.

You'll often see regular expressions in Python using raw strings since they
tend to contain slashes and backslashes which you really want in there.

Barry

[[alternative HTML version deleted]]

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


Re: [R] Label axis tick marks with a simple function of axis value

2014-04-08 Thread Hurr
Don suggested something like this:
h=c(1,2,3,4,5,6,7,8,9)
v=c(9,8,7,6,5,4,3,2,1)
plot(h,v,xaxt='n')
xat=pretty(h)
axis(1,at=xat,labels=1/xat)
But it puts the tick marks at the data-x-locations.
If the tick locations are not automatic or
automatically separate from the data locations, then
I want to tell it where to put them using 
a separate indicator. I am not familiar enough with
R to find the answer.
But if it would work, it would be valuable.




--
View this message in context: 
http://r.789695.n4.nabble.com/Label-axis-tick-marks-with-a-simple-function-of-axis-value-tp4687917p4688399.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Ignore escape characters in a string...

2014-04-08 Thread Frede Aakmann Tøgersen
Thank you Barry, this explains some of the things going on on the different 
platforms. One of my colleague told me some time ago that in C#/.NET they have 
this raw string functionality as you call it. However there they use @ and 
not r. That could be a nice thing to have in R.

Yours sincerely / Med venlig hilsen


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

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

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

From: b.rowling...@gmail.com [mailto:b.rowling...@gmail.com] On Behalf Of Barry 
Rowlingson
Sent: 8. april 2014 17:40
To: Frede Aakmann Tøgersen
Cc: Jonathan Greenberg; r-help
Subject: Re: [R] Ignore escape characters in a string...



On Tue, Apr 8, 2014 at 4:30 PM, Frede Aakmann Tøgersen 
fr...@vestas.commailto:fr...@vestas.com wrote:

I'm a bit surprised about the \\ on a linux OS. I'm also surprised that in a 
file manager on Windows you can paste e.g. C:/users/frtog/Desktop and it can 
find its way to the folder. Weird.


 Well, the clipboard contained a path separated by single backslashes. R read 
that (via the file(clipboard)) and correctly read single backslashes. Its 
only when printed out that R 'escapes' them as double-backslashes - there's 
really only one character there.
 What R seems to lack is 'raw string'  functionality. In python you do this 
with a string quote prefix, for example 'r':

  len(\t)
 1
 In that case the \t is interpreted as a single character, \t, or tab. Add the 
r modifier:

 len(r\t)
2
and now you get two characters, backslash and t.
You'll often see regular expressions in Python using raw strings since they 
tend to contain slashes and backslashes which you really want in there.
Barry


[[alternative HTML version deleted]]

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


Re: [R] Plotting does odd line thing

2014-04-08 Thread David Doyle
THANK you for the help!!

One more question.  Being I  need to compare 4 different wells, I like to
have them all at the same scale which I can do with the  ylim=c(min,max).
 But so the low concentrations don't get washed out, I like to plot the y
axis in log format.  ie 0.001, 0.010, 0.100.  Below is the code I have so
far.

Thanks in advance.

setwd(c:/R)

mydata -read.csv(http://doylesdartden.com/R/2014_02_data.csv;, sep=,)

attach(mydata)

plot(Arsenic~Year,data=mydata, subset = Well.ID %in% c(MW-1,
D_Arsenic), col=ifelse(D_Arsenic, black, red),
ylab = mg/L,xlab = , pch=ifelse(D_Arsenic, 19, 17), cex = 1.5,
ylim=c(0, 0.1))


subset-Well.ID %in% c(MW-1, D_Arsenic)
lines(Arsenic[subset]~Year[subset])

#Add title
title(main=MW-1)



On Tue, Apr 8, 2014 at 12:52 AM, Frede Aakmann Tøgersen fr...@vestas.comwrote:

 Well the lines() function has a subset argument as does plot() so why not
 do this?

 lines(EMD ~ Year, data = mydata, subset = Well.ID %in% c(MW-1, D_EMD))

 And yes lines() also have a data argument so why do you not use that (as
 you do with plot()) instead of attaching.

 Attaching dataframes may be a potential danger when some time in the
 future you have forgot that you attached the dataframe and you have forgot
 the warnings you get when attaching (making debugging difficult).

 Try this:

  ## Define an object named Year
  ## in which case call to lines do not what you think it will do
  Year - 1:nrow(mydata)
 
  ## or Year - 'foo' in which case one gets an error later
 
  ## attach the dataframe
   attach(mydata)

 The following object is masked _by_ .GlobalEnv:

 Year

 Now what will happen if you do lines(EMD ~ Year)?

 Here is the search path in my session:

  search()
  [1] .GlobalEnvmydatapackage:lattice
  [4] package:RODBC package:stats package:graphics
  [7] package:grDevices ESSR  package:utils
 [10] package:datasets  package:methods   Autoloads
 [13] package:base


 Yours sincerely / Med venlig hilsen


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

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

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


  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
  On Behalf Of Jim Lemon
  Sent: 8. april 2014 04:53
  To: David Doyle
  Cc: r-help@r-project.org
  Subject: Re: [R] Plotting does odd line thing
 
  On 04/08/2014 12:20 PM, David Doyle wrote:
   Hello folks,
  
   When I use the lines function below it connects all my points but then
   draws a line back to the start point.  Any suggestions on what is
 going on??
  
   mydata-read.csv(http://doylesdartden.com/R/test_data.csv;, sep=,)
  
   attach(mydata)
  
   plot(EMD~Year,data=mydata, subset = Well.ID %in% c(MW-1, D_EMD),
   col=ifelse(D_EMD, black, red), pch=ifelse(D_EDM, 19, 17), cex =
 1.5)
  
   lines(EMD~Year)
  
  Hi David,
  While you will get what you expect with:
 
  lines(EMD[1:39]~Year[1:39])
 
  I would be unnecessarily obscure in suggesting it. Try this:
 
  subset-Well.ID %in% c(MW-1, D_EMD)
  lines(EMD[subset]~Year[subset])
 
  You haven't selected the same points for the lines function as you have
  for the plot function.
 
  Jim
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
  guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] locating a data value in 3-dimensional data set

2014-04-08 Thread mamuash bukana
Many thanks to you all; specially to Frede.
which(3ddata$variablename=x,arr.ind=TRUE) answers my question
perfectly.

Cheers!

Bukana

On Tue, Apr 8, 2014 at 11:33 AM, Frede Aakmann Tøgersen
fr...@vestas.com wrote:
 Hi

 I know there is a arr.index (or something like that,  I'm not near my R
 right now) argument to which (). I have used it for 2-dim arrays and never
 for higher dimensions. But try it out by setting the argument to TRUE.

 Br. Frede


 Sendt fra Samsung mobil


  Oprindelig meddelelse 
 Fra: mamuash bukana
 Dato:08/04/2014 15.51 (GMT+01:00)
 Til: r-help@r-project.org
 Emne: [R] locating a data value in 3-dimensional data set

 I have a 3-dimentional data set with dimensions longitude,
 latitude, and time. Unfortunately, when I look at the range of
 values in the data set, I noticed some very extremely large(positive
 and negative) values which are unexpected to be there. So I wanted to
 point-out the location (lon, lat and time) which these extreme values
 correspond to in order to see what is happening there. But I could not
 point-out these grid points and time.

 I tried:
 which(3ddata==x) # 3ddata is name of data set, x is the observed extreme
 value
 But this couldn't help me.

 Any suggestion please?

 Thanks

 B

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

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


[R] Meta-analysis of prevalence at the country level with mgcv/gamm4

2014-04-08 Thread Julien Riou
Dear R community,

I'm working on a meta-analysis of prevalence data. The aim is to get
estimates of prevalence at the country level. The main issue is that the
disease is highly correlated with age, and the sample ages of included
studies are highly heterogeneous. Only median age is available for most
studies, so I can't use SMR-like tricks. I figured I could use
meta-regression to solve this, including age as a fixed-effect and
introducing study-level and country-level random-effects.

The idea (that I took from Fowkes et
alhttp://www.thelancet.com/journals/lancet/article/PIIS0140-6736%2813%2961249-0/abstract)
was to use this model to make country-specific predictions of prevalence
for each 5-year age group from 15 to 60 (using the median age of the
group), and to apply these predictions to the actual population size of
each of those groups in the selected country, in order to obtain total
infected population and to calculate age-adjusted prevalence in the 15-60
population from that.

I tried several ways to do this using R with packages meta and mgcv. I got
some satisfying results, but I'm not that confident with my results and
would appreciate some feedback.

First is some simulated data, then the description of my different
approaches:

data-data.frame(id_study=c(UK1,UK2,UK3,FRA1,FRA2,BEL1,GER1,GER2,GER3),

country=c(UK,UK,UK,FRANCE,FRANCE,BELGIUM,GERMANY,GERMANY,GERMANY),
 n_events=c(91,49,18,10,50,6,9,10,22),
 n_total=c(3041,580,252,480,887,256,400,206,300),
 study_median_age=c(25,50,58,30,42,26,27,28,36))

*Standard random-effect meta-analysis* with package meta.

I used metaprop() to get a first estimate of the prevalence in each country
without taking age into account, and to obtain weights. As expected,
heterogeneity was very high, so I used weights from the random-effects
model.

 meta - 
metaprop(event=n_events,n=n_total,byvar=country,sm=PLOGIT,method.tau=REML,data=data)
 summary(meta)
 data$weight-meta$w.random

I used meta to get a first estimate of the prevalence without taking age
into account, and to obtain weights. As expected, heterogeneity was very
high, so I used weights from the random-effects model.

*Generalized additive model* to include age with package mgcv.

The gam() model parameters (k and sp) were chosen using BIC and GCV number
(not shown here).

 model - gam( cbind(n_events,n_total-n_events) ~
s(study_median_age,bs=cr,k=4,sp=2) + s(country,bs=re),
weights=weight, data=data, family=binomial(link=logit),
method=REML)
 plot(model,pages=1,residuals=T, all.terms=T, shade=T)

Predictions for each age group were obtained from this model as explained
earlier. CI were obtained directly using predict.gam(), that uses the
Bayesian posterior covariance matrix of the parameters. For exemple
considering UK:

 newdat-data.frame(country=UK,study_median_age=seq(17,57,5))
 link-predict(model,newdat,type=link,se.fit=T)$fit
 linkse-predict(model,newdat,type=link,se.fit=T)$se
 newdat$prev-model$family$linkinv(link)
 newdat$CIinf-model$family$linkinv(link-1.96*linkse)
 newdat$CIsup-model$family$linkinv(link+1.96*linkse)
 plot(newdat$prev~newdat$study_median_age, type=l,ylim=c(0,.12))
 lines(newdat$CIinf~newdat$study_median_age, lty=2)
 lines(newdat$CIsup~newdat$study_median_age, lty=2)

The results were satisfying, representing the augmentation of the
prevalence with advanced age, with coherent confidence intervals. I
obtained a total prevalence for the country using the country population
structure (not shown, I hope it is clear enough).

However, I figured I needed to include study-level random-effects since
there was a high heterogeneity (even though I did not calculate
heterogeneity after the meta-regression).

*Introducing study-level random-effect* with package gamm4.

Since mgcv models can't handle that much random-effect parameters, I had to
switch to gamm4.

 model2 - gamm4(cbind(n_events,n_total-n_events) ~
s(study_median_age,bs=cr,k=4) + s(country,bs=re),
random=~(1|id_study), data=data, weights=weight,
family=binomial(link=logit))
 plot(model2$gam,pages=1,residuals=T, all.terms=T, shade=T)

 link-predict(model2$gam,newdat,type=link,se.fit=T)$fit
 linkse-predict(model2$gam,newdat,type=link,se.fit=T)$se
 newdat$prev2-model$family$linkinv(link)
 newdat$CIinf2-model$family$linkinv(link-1.96*linkse)
 newdat$CIsup2-model$family$linkinv(link+1.96*linkse)
 plot(newdat$prev2~newdat$study_median_age, type=l,col=red,ylim=c(0,0.11))
 lines(newdat$CIinf2~newdat$study_median_age, lty=2,col=red)
 lines(newdat$CIsup2~newdat$study_median_age, lty=2,col=red)
 lines(newdat$prev~newdat$study_median_age, type=l,ylim=c(0,.12))
 lines(newdat$CIinf~newdat$study_median_age, lty=2)
 lines(newdat$CIsup~newdat$study_median_age, lty=2)

Since the study-level random effect was in the mer part of the fit, I
didn't have to handle it.

As you can see, I obtain rather different results, with a much smoother
relation between age and prevalence, and quite different 

Re: [R] Splitting columns and forming new data files in R

2014-04-08 Thread arun
Hi,
Try:
#Tmin,Tmax,Tmean,Precip 

#Tmean -999.9 in all files
#working directory is sample 

#created folder final
list.files()
#[1] coordinates.csv final   Precip  Tmax
   
#[5] Tmin
Coord - read.csv(list.files(pattern=.csv),header=TRUE,stringsAsFactors=FALSE)
lfile - list.files()[!grepl(.csv|final,list.files())]
files -  paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)
lst1 - split(files,gsub(.*\\/(.*)\\.csv,\\1,files)) 

names1 - gsub(.*\\/(.*)\\/.*\\.csv,\\1,lst1[[1]])
lst1New -   lapply(lst1,function(x) {lst2 - setNames(lapply(x,function(y) 
{dat - read.table(y,sep= ,header=TRUE, stringsAsFactors=FALSE); dat[,1:104]} 
), names1); dat2 - do.call(cbind,lst2); indx - grepl(Sim,names(dat2)); dat3 
- dat2[indx];dat4 - dat2[!indx][,1:4]; names(dat4) - 
gsub(.*\\.,,names(dat4)); 
lapply(split(names(dat3),gsub(.*\\.,,names(dat3))),function(x)  {dat5 - 
cbind(dat4,dat3[,x]); dat5$Tmean - -999.9; dat6 - 
dat5[,c(1:4,7:6,8,5)];colnames(dat6)[2:3] - Coord[match(unique(dat6$Site), 
Coord$Site),3:2];dat7 - dat6[,-4]; dat7; colnames(dat7)[-(2:3)] - NA; dat7})})

sapply(lst1New,length) 

#G100 G101 G102 G103 

# 100  100  100  100
lapply(names(lst1New),function(x) {nm1 - paste(x, 
names(lst1New[[x]]),sep=_); nm2 - 
paste0(paste(paste0(getwd(),/final),nm1,sep=/),.csv);lapply(seq_along(lst1New[[x]]),function(i)
 {x1 - lst1New[[x]][i]; write.table(x1, nm2[i],quote=FALSE,row.names=FALSE)})})

length(list.files(paste0(getwd(),/final)))
#[1] 400 


A.K.

On Tuesday, April 8, 2014 1:17 AM, Zilefac Elvis zilefacel...@yahoo.com wrote:

Hi AK,
Please I need your help. I finally solved the previous task I sent to you.
I have Precip,Tmin and Tmax in three different folders (attached).
Each folder has 4 files with identical names in all folders (we can match case).

Within each file are [,YYY MM DD sim001...sim100] (some files may have more 
than 100 simulations. Use only the first 100).

Q1) Open all three folders, go to file 1 (e.g G100), copy column 1 (sim001, do 
not copy date) and paste it in a new folder called final. Do so for column 2 
(sim002),...,column 100 (sim100). So from file 1 alone with 100 sims, you will 
have 100 files in final. The files in final should be labelled for example 
as G100_sim001, G100_sim002,...,G100_sim100; G101_sim001,G101_sim002 etc.

The format of all files in final is similar to:

50-110.7
196111-999.9-999.9-999.90
196112-999.9-999.9-999.92.38
196113-999.9-999.9-999.90
196114-999.9-999.9-999.90
196115-999.9-999.9-999.90
196116-999.9-999.9-999.90
196117-999.9-999.9-999.90
196118-999.9-999.9-999.90
196119-999.9-999.9-999.95.19
1961110-999.9-999.9-999.90
196-999.9-999.9-999.90
1961112-999.9-999.9-999.90
1961113-999.9-999.9-999.90
1961114-999.9-999.9-999.90
1961115-999.9-999.9-999.90


The columns after the date should be [Tmin,Tmax,Tmean,Precip]. Please do not 
include column names in output. Output files are .csv.

*Fill column Tmean with -999.9 in all files.

Therefore, using the sample I have provided, you will have 4sites*100 sims = 
400 files in folder final.



Q2) From the attached coordinates file, please copy Lat andLong corresponding 
to the Site and past it in the first row of every file starting with that site 
code.

For example, all files beginning with G100_sim... will have their first row 
similar to:

       49.53-96.7
196111-999.9-999.9-999.90


This looks very cumbersome for me to handle. 

Thanks very much.
Atem.

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


[R] Error logistic analysis

2014-04-08 Thread lghansse
I'm trying to conduct a single level logistic analysis (as a beginning step
for a more advanced Multi-level analysis). However, when I try to run it, I
get following error:

Warning messages:
1: In model.response(mf, numeric) :
  using type = numeric with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : - not meaningful for factors

I haven't got a clue why I'm getting this because I used the exact same
syntax (same data preparation etc...) for a similar analysis (same
datastructure, different country). 

Syntax: 
Single_model1 - lm(openhrs1 ~ genhealt1 + age + sexpat1 + hhincome1 +
edupat1 
+ etniciteit1, data=Slovakije)

My Missing data are coded as such, I already tried to run the analysis in a
data frame without the missing cases, but that didn't work either. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Error-logistic-analysis-tp4688385.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Error logistic analysis

2014-04-08 Thread Marc Schwartz

On Apr 8, 2014, at 7:20 AM, lghansse lise.hanss...@ugent.be wrote:

 I'm trying to conduct a single level logistic analysis (as a beginning step
 for a more advanced Multi-level analysis). However, when I try to run it, I
 get following error:
 
 Warning messages:
 1: In model.response(mf, numeric) :
  using type = numeric with a factor response will be ignored
 2: In Ops.factor(y, z$residuals) : - not meaningful for factors
 
 I haven't got a clue why I'm getting this because I used the exact same
 syntax (same data preparation etc...) for a similar analysis (same
 datastructure, different country). 
 
 Syntax: 
 Single_model1 - lm(openhrs1 ~ genhealt1 + age + sexpat1 + hhincome1 +
 edupat1 
 + etniciteit1, data=Slovakije)
 
 My Missing data are coded as such, I already tried to run the analysis in a
 data frame without the missing cases, but that didn't work either. 


You are using the lm() function above, which is a regular least squares linear 
regression for a continuous response variable.

If you want to run a logistic regression, you need to use glm() with 'family = 
binomial':

Single_model1 - glm(openhrs1 ~ genhealt1 + age + sexpat1 + hhincome1 +
 edupat1 + etniciteit1, family = binomial, data = Slovakije)


Regards,

Marc Schwartz

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


[R] moses extreme reaction test

2014-04-08 Thread José Trujillo Carmona

Is there a package that contains moses extreme reaction test?

Thank's

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


Re: [R] moses extreme reaction test

2014-04-08 Thread Marc Schwartz

On Apr 8, 2014, at 12:37 PM, José Trujillo Carmona truji...@unex.es wrote:

 Is there a package that contains moses extreme reaction test?
 
 Thank's


A search using rseek.org indicates that the DescTools package on CRAN contains 
a function called  
MosesTest() that appears to implement it.

  http://cran.r-project.org/web/packages/DescTools/

Regards,

Marc Schwartz

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


Re: [R] moses extreme reaction test

2014-04-08 Thread David Winsemius

On Apr 8, 2014, at 10:37 AM, José Trujillo Carmona wrote:

 Is there a package that contains moses extreme reaction test?

Learn to search.

install.packages(sos)
library(sos)
findFn(moses extreme)


found 5 matches;  retrieving 1 page

Downloaded 3 links in 1 packages

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] Ignore escape characters in a string...

2014-04-08 Thread Jeff Newmiller
What is wrong with

winpath - readLines(clipboard )

?

If you want to show that as a literal in your code, then don't bother assigning 
it to a variable, but let it echo to output and copy THAT and put it in your 
source code.

There is also file.choose()...

---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On April 8, 2014 8:00:03 AM PDT, Jonathan Greenberg j...@illinois.edu wrote:
R-helpers:

One of the minor irritations I have is copying paths from Windows
explorer, which look like:

C:\Program Files\R\R-3.0.3

and using them in a setwd() statement, since the \ is, of course,
interpreted as an escape character.  I have to, at present, manually
add in the double slashes or reverse them.

So, I'd like to write a quick function that takes this path:

winpath - C:\Program Files\R\R-3.0.3

and converts it to a ready-to-go R path -- is there a way to have R
IGNORE escape characters in a character vector?

Alternatively, is there some trick to using a copy/paste from Windows
explorer I'm not aware of?

--j

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


[R] Pull Stock Symbol Out of String

2014-04-08 Thread Sparks, John James
Dear R Helpers,

My regex skills are beginner to intermediate and banging around the web
has not resulted in a solution to the problem below so I hope that one of
you who has mad skills can help me out.

I want to extract the stock ticker--AMT-- out of the string

American Tower Corporation (REIT) (AMT)

The presence of the other parenthetical text (REIT) makes this difficult. 
Please note that the string may or may not have a interfering set of
characters such as the (REIT) so the solution needs to be generalizable to
the last set of characters that are contained in parentheses in the larger
string.  So an example of a string without the interfering (REIT) would be

Aetna Inc. (AET)


Your assistance would be very much appreciated.

--John Sparks

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


[R] ggplot2 and geom_tile

2014-04-08 Thread Øystein Godøy
Dear community,

I have been using ggplot2 for visualisation and I am really impressed by this. 
I do however have a problem that returns when plotting various types of 
spatial datasets as raster images. This is probably due to me not fully 
understanding the package.

When I am plotting images using geom_tile, I sometimes only have small dots in 
the image and at other times I have apparently blank images. On other 
occasions it works nicely without me being able to spot the differences 
between these plot requests nor the underlying data. I am usually plotting 
geophysical information either on a geographical grid (latitude/longitude) or 
on a map projection (normally using proj4 for the projection of data). 

I have tried to play with the position attribute, but without success so far, 
but believe that I suffer from some form of effect from this. I have tried to 
google for information and I have read the manual pages but so far without 
success. Do you have some suggested reading for problems like this? Is the 
problem likely to be related to position?

I apologise for the vague description of the problem.

All the best
Øystein
-- 
Dr. Oystein Godoy
Norwegian Meteorological Institute 
P.O.BOX 43, Blindern, N-0313 OSLO, Norway
Ph: (+47) 2296 3000 (switchb) 2296 3334 (direct line)
Fax:(+47) 2296 3050 Institute home page: http://met.no/

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


Re: [R] Pull Stock Symbol Out of String

2014-04-08 Thread William Dunlap
The following gets the last parenthesized sequence of non-parentheses
   sub(.*(\\([^()]+\\))([^()]*)$, \\1, 
  c(Aetna(AET),
 American Tower Corp(REIT)(ATC),
 No Parens,
 Qwerty Corp (ASD)(ZXC)(123) extra stuff))
  [1] (AET) (ATC) No Parens (123)

Bill Dunlap
TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Sparks, John James
 Sent: Tuesday, April 08, 2014 11:29 AM
 To: r-help@r-project.org
 Subject: [R] Pull Stock Symbol Out of String
 
 Dear R Helpers,
 
 My regex skills are beginner to intermediate and banging around the web
 has not resulted in a solution to the problem below so I hope that one of
 you who has mad skills can help me out.
 
 I want to extract the stock ticker--AMT-- out of the string
 
 American Tower Corporation (REIT) (AMT)
 
 The presence of the other parenthetical text (REIT) makes this difficult.
 Please note that the string may or may not have a interfering set of
 characters such as the (REIT) so the solution needs to be generalizable to
 the last set of characters that are contained in parentheses in the larger
 string.  So an example of a string without the interfering (REIT) would be
 
 Aetna Inc. (AET)
 
 
 Your assistance would be very much appreciated.
 
 --John Sparks
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] moses extreme reaction test

2014-04-08 Thread José Trujillo

Very useful.

Very Thanks.

El 08/04/14 19:43, David Winsemius escribió:

On Apr 8, 2014, at 10:37 AM, José Trujillo Carmona wrote:


Is there a package that contains moses extreme reaction test?

Learn to search.

install.packages(sos)
library(sos)
findFn(moses extreme)


found 5 matches;  retrieving 1 page

Downloaded 3 links in 1 packages



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


Re: [R] moses extreme reaction test

2014-04-08 Thread José Trujillo

What's the problem with this:?

package ‘DscTools’ is not available (for R version 3.1.0 beta)



El 08/04/14 19:42, Marc Schwartz escribió:

On Apr 8, 2014, at 12:37 PM, José Trujillo Carmona truji...@unex.es wrote:


Is there a package that contains moses extreme reaction test?

Thank's


A search using rseek.org indicates that the DescTools package on CRAN contains 
a function called
MosesTest() that appears to implement it.

   http://cran.r-project.org/web/packages/DescTools/

Regards,

Marc Schwartz


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


[R] xts Annual series

2014-04-08 Thread Erin Hodgess
Hello!

If I have the following:

x - as.yearqtr(2000 + seq(0,7)/4)
x
[1] 2000 Q1 2000 Q2 ...

which is as it should be.
Then if I set up time as
time - xts(1:8,x)
time
2000 Q1   1
2000 Q2   2
2000 Q3  3
.
.

Also fine
Now suppose I want to have an annual xts object.  How do I go about setting
that up, please?

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] moses extreme reaction test

2014-04-08 Thread Boris Steipe
Typo: DescTools ?


On 2014-04-08, at 3:13 PM, José Trujillo wrote:

 What's the problem with this:?
 
 package ‘DscTools’ is not available (for R version 3.1.0 beta)
 
 
 
 El 08/04/14 19:42, Marc Schwartz escribió:
 On Apr 8, 2014, at 12:37 PM, José Trujillo Carmona truji...@unex.es wrote:
 
 Is there a package that contains moses extreme reaction test?
 
 Thank's
 
 A search using rseek.org indicates that the DescTools package on CRAN 
 contains a function called
 MosesTest() that appears to implement it.
 
   http://cran.r-project.org/web/packages/DescTools/
 
 Regards,
 
 Marc Schwartz
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Need to download this data... can someone help?

2014-04-08 Thread Christofer Bogaso
Hi again,

I am looking some way to download this data:

http://www.cmegroup.com/trading/interest-rates/stir/eurodollar_quotes_openOutcry.html

So far I have tried following code:

library(XML)
data - xmlParse(
http://www.cmegroup.com/trading/interest-rates/stir/eurodollar_quotes_openOutcry.html
)

However not be able to get in right way.

Really appreciate if someone point me on right approach.

Thanks for your time.

[[alternative HTML version deleted]]

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


[R] browser always enters debug mode

2014-04-08 Thread Paul Murtaugh
This is something peculiar about the environment on one particular linux 
box, because it doesn't happen on other computers.  Whenever I invoke 
browser() inside a function, it automatically enters debugging mode, 
with line-by-line execution of code:

  dum - function() { browser(); x - rnorm(10); print(x) }
  dum()
Called from: dum()
Browse[1]
debug at #1: x - rnorm(10)
Browse[2]
debug at #1: print(x)
Browse[2]
  [1] -0.41466890  0.02276493  1.01332894 -2.72784447  0.73471652 0.41360718
  [7]  1.67942142 -1.47384724  1.12129541 -1.13447881
  isdebugged(dum)
[1] FALSE

Thanks in advance for any tips on how to revert to the normal browser() 
behavior.
-Paul


[[alternative HTML version deleted]]

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


Re: [R] Need to download this data... can someone help?

2014-04-08 Thread Rui Barradas

Hello,

Try the following.

library(XML)
URL - 
http://www.cmegroup.com/trading/interest-rates/stir/eurodollar_quotes_openOutcry.html;


dat - readHTMLTable(readLines(URL), which=1, header=TRUE, na.strings = -)

str(dat)
dat[4:10] - lapply(dat[4:10], function(x) as.numeric(as.character(x)))
head(dat)


Hope this helps,

Rui Barradas

Em 08-04-2014 20:40, Christofer Bogaso escreveu:

Hi again,

I am looking some way to download this data:

http://www.cmegroup.com/trading/interest-rates/stir/eurodollar_quotes_openOutcry.html

So far I have tried following code:

library(XML)
data - xmlParse(
http://www.cmegroup.com/trading/interest-rates/stir/eurodollar_quotes_openOutcry.html
)

However not be able to get in right way.

Really appreciate if someone point me on right approach.

Thanks for your time.

[[alternative HTML version deleted]]

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



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


Re: [R] browser always enters debug mode

2014-04-08 Thread Duncan Murdoch

On 08/04/2014 3:34 PM, Paul Murtaugh wrote:

This is something peculiar about the environment on one particular linux
box, because it doesn't happen on other computers.  Whenever I invoke
browser() inside a function, it automatically enters debugging mode,
with line-by-line execution of code:

   dum - function() { browser(); x - rnorm(10); print(x) }
   dum()
Called from: dum()
Browse[1]
debug at #1: x - rnorm(10)
Browse[2]
debug at #1: print(x)
Browse[2]
   [1] -0.41466890  0.02276493  1.01332894 -2.72784447  0.73471652 0.41360718
   [7]  1.67942142 -1.47384724  1.12129541 -1.13447881
   isdebugged(dum)
[1] FALSE

Thanks in advance for any tips on how to revert to the normal browser()
behavior.
-Paul


That looks like the normal browser() behaviour to me.  What do you see 
elsewhere?


Duncan Murdoch

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


Re: [R] xts Annual series

2014-04-08 Thread Michael Weylandt


On Apr 8, 2014, at 15:15, Erin Hodgess erinm.hodg...@gmail.com wrote:

 Hello!
 
 If I have the following:
 
 x - as.yearqtr(2000 + seq(0,7)/4)
 x
 [1] 2000 Q1 2000 Q2 ...
 
 which is as it should be.
 Then if I set up time as
 time - xts(1:8,x)
 time
 2000 Q1   1
 2000 Q2   2
 2000 Q3  3
 .
 .
 
 Also fine
 Now suppose I want to have an annual xts object.  How do I go about setting
 that up, please?

Not quite as transparently. R does not (to my knowledge) have a commonly used 
'year' class. 

You can of course use yearqtr objects and skip 3/4 per year. 

 
 Thanks,
 Erin
 
 
 -- 
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] xts Annual series

2014-04-08 Thread John Laing
At first pass it would seem that 'integer' would make a perfectly fine year
class. But for some reason it's disallowed:

 xts(rnorm(8), 2000L:2007)
Error in xts(rnorm(8), 2000L:2007) :
  order.by requires an appropriate time-based object

Which is a bit unexpected, since xts descends from zoo and this works fine:

 zoo(rnorm(8), 2000L:2007)


  2000   2001   2002   2003   2004   2005
2006   2007
 0.2963980 -1.7928750  1.9253476 -0.6851739  0.3223047  0.7776734
-0.3255266 -1.0980489

That doesn't feel very eXtensible to me.

-John


On Tue, Apr 8, 2014 at 4:27 PM, Michael Weylandt michael.weyla...@gmail.com
 wrote:



 On Apr 8, 2014, at 15:15, Erin Hodgess erinm.hodg...@gmail.com wrote:

  Hello!
 
  If I have the following:
 
  x - as.yearqtr(2000 + seq(0,7)/4)
  x
  [1] 2000 Q1 2000 Q2 ...
 
  which is as it should be.
  Then if I set up time as
  time - xts(1:8,x)
  time
  2000 Q1   1
  2000 Q2   2
  2000 Q3  3
  .
  .
 
  Also fine
  Now suppose I want to have an annual xts object.  How do I go about
 setting
  that up, please?

 Not quite as transparently. R does not (to my knowledge) have a commonly
 used 'year' class.

 You can of course use yearqtr objects and skip 3/4 per year.

 
  Thanks,
  Erin
 
 
  --
  Erin Hodgess
  Associate Professor
  Department of Computer and Mathematical Sciences
  University of Houston - Downtown
  mailto: erinm.hodg...@gmail.com
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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


[[alternative HTML version deleted]]

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


Re: [R] moses extreme reaction test

2014-04-08 Thread Bert Gunter
Just for the fun of it, I searched for R package moses extreme
reaction test  on google. The 8th hit was the package DescTools, but
that included the 3 earlier hits and responses from r-help.

So I guess the point is that Learn to Search may even be a bit over
the top -- is there anyone on the internet who does not use standard
search engines like google, bing, and yahoo?

Best,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Tue, Apr 8, 2014 at 10:43 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Apr 8, 2014, at 10:37 AM, José Trujillo Carmona wrote:

 Is there a package that contains moses extreme reaction test?

 Learn to search.

 install.packages(sos)
 library(sos)
 findFn(moses extreme)


 found 5 matches;  retrieving 1 page

 Downloaded 3 links in 1 packages

 --

 David Winsemius
 Alameda, CA, USA

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

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


Re: [R] Pull Stock Symbol Out of String

2014-04-08 Thread Boris Steipe
You could try:

# Use ?regexec and ?regmatches to return a list of grouped matches.
# Use \\(  and \\) to match literal parentheses.
# Use ... to match three characters.
# Use $ to match at end of string.

s1 - American Tower Corporation (REIT)Â (AMT)
s2 - Aetna Inc. (AET)
getSym - function(s) {regmatches(s, regexec(\\((...)\\)$, s))[[1]][2]}

getSym(s1) # [1] AMT
getSym(s2) # [1] AET

Cheers,
B.




On 2014-04-08, at 2:29 PM, Sparks, John James wrote:

 Dear R Helpers,
 
 My regex skills are beginner to intermediate and banging around the web
 has not resulted in a solution to the problem below so I hope that one of
 you who has mad skills can help me out.
 
 I want to extract the stock ticker--AMT-- out of the string
 
 American Tower Corporation (REIT)Â (AMT)
 
 The presence of the other parenthetical text (REIT) makes this difficult. 
 Please note that the string may or may not have a interfering set of
 characters such as the (REIT) so the solution needs to be generalizable to
 the last set of characters that are contained in parentheses in the larger
 string.  So an example of a string without the interfering (REIT) would be
 
 Aetna Inc. (AET)
 
 
 Your assistance would be very much appreciated.
 
 --John Sparks
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] xts Annual series

2014-04-08 Thread Michael Weylandt


On Apr 8, 2014, at 17:32, John Laing john.la...@gmail.com wrote:

 
 That doesn't feel very eXtensible to me.
 

xts is quite obviously past tense. ;-)

The list of allowable index classes is found in is.timeBased IIRC and the 
exclusion of integers is because there's no obvious way to have them play nice 
with other index classes. 

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


Re: [R] Label axis tick marks with a simple function of axis value

2014-04-08 Thread Jim Lemon

On 04/09/2014 02:06 AM, Hurr wrote:

Don suggested something like this:
h=c(1,2,3,4,5,6,7,8,9)
v=c(9,8,7,6,5,4,3,2,1)
plot(h,v,xaxt='n')
xat=pretty(h)
axis(1,at=xat,labels=1/xat)
But it puts the tick marks at the data-x-locations.
If the tick locations are not automatic or
automatically separate from the data locations, then
I want to tell it where to put them using
a separate indicator. I am not familiar enough with
R to find the answer.
But if it would work, it would be valuable.



Hi Hurr,
If you want to use pretty:

pretty(1:9)
[1]  0  2  4  6  8 10

you don't necessarily get axis ticks at the same locations as the data 
points. Maybe you want to specify your own axis ticks and use those:


axis_ticks-c(1,4,7,10)
axis(1,at=axis_ticks,labels=1/axis_ticks)

but that seems too obvious. Could you supply an example of what you want 
to do?


Jim

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


[R] rJava not loading on Windows

2014-04-08 Thread Kishan Lachhani
I also have this problem, did you find a solution?

[[alternative HTML version deleted]]

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


Re: [R] browser always enters debug mode

2014-04-08 Thread Paul Murtaugh
It appears to be a difference between versions 2.* and 3.* in the way 
that a newline ('enter') is handled at the browser prompt. Formerly, it 
would continue execution of the function; now it kicks you into 
debugging mode.  To get the old behavior, you need to enter 'c' at the 
browser prompt.


On 04/08/2014 12:34 PM, I wrote:

This is something peculiar about the environment on one particular linux
box, because it doesn't happen on other computers.  Whenever I invoke
browser() inside a function, it automatically enters debugging mode,
with line-by-line execution of code:

   dum - function() { browser(); x - rnorm(10); print(x) }
   dum()
Called from: dum()
Browse[1]
debug at #1: x - rnorm(10)
Browse[2]
debug at #1: print(x)
Browse[2]
   [1] -0.41466890  0.02276493  1.01332894 -2.72784447  0.73471652 0.41360718
   [7]  1.67942142 -1.47384724  1.12129541 -1.13447881
   isdebugged(dum)
[1] FALSE

Thanks in advance for any tips on how to revert to the normal browser()
behavior.
-Paul



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


Re: [R] moses extreme reaction test

2014-04-08 Thread David Winsemius

On Apr 8, 2014, at 2:41 PM, Bert Gunter wrote:

 Just for the fun of it, I searched for R package moses extreme
 reaction test  on google. The 8th hit was the package DescTools, but
 that included the 3 earlier hits and responses from r-help.
 
 So I guess the point is that Learn to Search may even be a bit over
 the top -- is there anyone on the internet who does not use standard
 search engines like google, bing, and yahoo?

I don't think I'm the only one. Using Spencer Graves' excellent package is very 
convenient and has delivered many answers to questions posed on R help. It pops 
up a browser window directly from an R console command. I like the fact that I 
get an R help page with `findFn`. I suspect it has prevented many more 
questions that we never see. 

The other search tool I have used in preference to Google is Markmail. I find 
Google to be sometimes non-specific and possesses an very annoying tendency to 
give priority to Nabble citations. None of the first page Google citations 
actually answered the question when I tried. Rseek was much better, but I have 
found it to be less focused than sos::findFn.  De gustibus non disputandem, I 
suppose.

I suppose I should crack open Spencer's code and learn how to call Markmail and 
Rseek from my console session, that is unless he accepts this feature request 
and beats me to it.  

-- 
David.

 
 Best,
 Bert
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374
 
 Data is not information. Information is not knowledge. And knowledge
 is certainly not wisdom.
 H. Gilbert Welch
 
 
 
 
 On Tue, Apr 8, 2014 at 10:43 AM, David Winsemius dwinsem...@comcast.net 
 wrote:
 
 On Apr 8, 2014, at 10:37 AM, José Trujillo Carmona wrote:
 
 Is there a package that contains moses extreme reaction test?
 
 Learn to search.
 
 install.packages(sos)
 library(sos)
 findFn(moses extreme)
 
 
 found 5 matches;  retrieving 1 page
 
 Downloaded 3 links in 1 packages
 
 --
 
 David Winsemius
 Alameda, CA, USA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] browser always enters debug mode

2014-04-08 Thread Duncan Murdoch

On 08/04/2014, 6:05 PM, Paul Murtaugh wrote:

It appears to be a difference between versions 2.* and 3.* in the way
that a newline ('enter') is handled at the browser prompt. Formerly, it
would continue execution of the function; now it kicks you into
debugging mode.  To get the old behavior, you need to enter 'c' at the
browser prompt.


Right, I didn't realize you were using old versions on those other 
machines. Things are more consistent now (though I imagine there are 
still inconsistencies, depending on how you enter the debugging system).


Duncan Murdoch



On 04/08/2014 12:34 PM, I wrote:

This is something peculiar about the environment on one particular linux
box, because it doesn't happen on other computers.  Whenever I invoke
browser() inside a function, it automatically enters debugging mode,
with line-by-line execution of code:

dum - function() { browser(); x - rnorm(10); print(x) }
dum()
Called from: dum()
Browse[1]
debug at #1: x - rnorm(10)
Browse[2]
debug at #1: print(x)
Browse[2]
[1] -0.41466890  0.02276493  1.01332894 -2.72784447  0.73471652 0.41360718
[7]  1.67942142 -1.47384724  1.12129541 -1.13447881
isdebugged(dum)
[1] FALSE

Thanks in advance for any tips on how to revert to the normal browser()
behavior.
-Paul



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



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


Re: [R] getting arg names in function calls?

2014-04-08 Thread Spencer Graves

Hi, Bill:


  Thanks for the reply.  Unfortunately, I don't see how that solves 
the example I gave of extracting plot(x=0, y=1) from tstFn - 
function()plot(0, 1).



  As I noted, body(tstFn) returns plot(0, 1) as an language 
object of class call.  My challenge is to convert that into something 
similar, with explicit names for the arguments.



  Any thoughts?
  Spencer


On 4/7/2014 3:18 PM, William Dunlap wrote:

Look at match.call().  E.g.,
f - function(x, y = log2(x), ...) match.call()
f()
   f()
f(1, x=2, anotherArg=3, 4)
   f(x = 2, y = 1, anotherArg = 3, 4)
or, using its 'definition' and 'call' arguments directly
match.call(function(x, y, ...)NULL, quote(foo(1, x=2, extraArg=3, 4)))
   foo(x = 2, y = 1, extraArg = 3, 4)
match.call(function(x, y, ...)NULL, quote(foo(1, x=2, extraArg=3, 4)), 
expand.dots=FALSE)
   foo(x = 2, y = 1, ... = list(extraArg = 3, 4))

Bill Dunlap
TIBCO Software
wdunlap tibco.com



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf
Of Spencer Graves
Sent: Monday, April 07, 2014 3:05 PM
To: R list
Subject: [R] getting arg names in function calls?

How can I convert plot(0, 1) into plot(x=0, y=1)?


More generally, how can I get argument names assigned to function
calls in language objects?


Example:


tstFn - function()plot(0, 1)
bo - body(tstFn)


tstFnxy - function()plot(x=0, y=1)
boxy - body(tstFnxy)


Is there a function that will modify bo to match boxy?


My current solution requires me to know the names of the
arguments for plot (in this example).  I'd prefer a more general
solution.


Thanks,
Spencer


p.s.  I'm trying to create an animation by repeatedly calling a function
that contains something like text(0, 1, abc).  By computing on the
language object 'text(0, 1, abc)', I can call text(0, 1, 'a') the
first time, text(0, 1, 'ab') the second, and text(0, 1, 'abc') the
third.  The function will be more general if I can get the names of the
arguments as just described.

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



--
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.com

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


Re: [R] moses extreme reaction test

2014-04-08 Thread Spencer Graves

On 4/8/2014 3:56 PM, David Winsemius wrote:

On Apr 8, 2014, at 2:41 PM, Bert Gunter wrote:


Just for the fun of it, I searched for R package moses extreme
reaction test  on google. The 8th hit was the package DescTools, but
that included the 3 earlier hits and responses from r-help.

So I guess the point is that Learn to Search may even be a bit over
the top -- is there anyone on the internet who does not use standard
search engines like google, bing, and yahoo?

I don't think I'm the only one. Using Spencer Graves' excellent package is very 
convenient and has delivered many answers to questions posed on R help. It pops 
up a browser window directly from an R console command. I like the fact that I 
get an R help page with `findFn`. I suspect it has prevented many more 
questions that we never see.

The other search tool I have used in preference to Google is Markmail. I find 
Google to be sometimes non-specific and possesses an very annoying tendency to 
give priority to Nabble citations. None of the first page Google citations 
actually answered the question when I tried. Rseek was much better, but I have 
found it to be less focused than sos::findFn.  De gustibus non disputandem, I 
suppose.

I suppose I should crack open Spencer's code and learn how to call Markmail and 
Rseek from my console session, that is unless he accepts this feature request 
and beats me to it.



  1.  I would happily accept code to generalize findFn{sos} to use 
another search capability like Google, Markmail, Nabble or Rseek. 
However, that might not be feasible, because the current code rests on a 
database of R packages (CRAN, Bioconductor, plus a few others) 
maintained by Jonathan Baron.  When Jonathan stops maintaining that 
database, that will be the end of findFn, unless someone else takes over 
that maintenance.



  2.  Do you also use writeFindFn2xls{sos}?  That produces an Excel 
file with 3 sheets, the first of which is a summary by package.  In 
addition to the sort by count, maxScore and totalScore, I get the date 
of the latest update, whether the package has a vignette, and the names 
of author(s) and maintainer.  That tells me whether the package is being 
maintained and how easy it might be to learn.  It is by far the fastest 
literature search I know for anything statistical.  In seconds, I can 
have the outline for a talk on R capabilities for __ (as 
mentioned in the sos vignette ;-)



  3.  Thanks for the kind words about findFn.


  Spencer


--
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.com

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


Re: [R] getting arg names in function calls?

2014-04-08 Thread Hadley Wickham
You might find it helpful to read
http://adv-r.had.co.nz/Expressions.html, and look at pryr::
standardise_call().

Hadley

On Tue, Apr 8, 2014 at 6:52 PM, Spencer Graves
spencer.gra...@structuremonitoring.com wrote:
 Hi, Bill:


   Thanks for the reply.  Unfortunately, I don't see how that solves the
 example I gave of extracting plot(x=0, y=1) from tstFn -
 function()plot(0, 1).


   As I noted, body(tstFn) returns plot(0, 1) as an language object
 of class call.  My challenge is to convert that into something similar,
 with explicit names for the arguments.


   Any thoughts?
   Spencer



 On 4/7/2014 3:18 PM, William Dunlap wrote:

 Look at match.call().  E.g.,
 f - function(x, y = log2(x), ...) match.call()
 f()
f()
 f(1, x=2, anotherArg=3, 4)
f(x = 2, y = 1, anotherArg = 3, 4)
 or, using its 'definition' and 'call' arguments directly
 match.call(function(x, y, ...)NULL, quote(foo(1, x=2, extraArg=3,
 4)))
foo(x = 2, y = 1, extraArg = 3, 4)
 match.call(function(x, y, ...)NULL, quote(foo(1, x=2, extraArg=3,
 4)), expand.dots=FALSE)
foo(x = 2, y = 1, ... = list(extraArg = 3, 4))

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf
 Of Spencer Graves
 Sent: Monday, April 07, 2014 3:05 PM
 To: R list
 Subject: [R] getting arg names in function calls?

 How can I convert plot(0, 1) into plot(x=0, y=1)?


 More generally, how can I get argument names assigned to function
 calls in language objects?


 Example:


 tstFn - function()plot(0, 1)
 bo - body(tstFn)


 tstFnxy - function()plot(x=0, y=1)
 boxy - body(tstFnxy)


 Is there a function that will modify bo to match boxy?


 My current solution requires me to know the names of the
 arguments for plot (in this example).  I'd prefer a more general
 solution.


 Thanks,
 Spencer


 p.s.  I'm trying to create an animation by repeatedly calling a function
 that contains something like text(0, 1, abc).  By computing on the
 language object 'text(0, 1, abc)', I can call text(0, 1, 'a') the
 first time, text(0, 1, 'ab') the second, and text(0, 1, 'abc') the
 third.  The function will be more general if I can get the names of the
 arguments as just described.

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



 --
 Spencer Graves, PE, PhD
 President and Chief Technology Officer
 Structure Inspection and Monitoring, Inc.
 751 Emerson Ct.
 San José, CA 95126
 ph:  408-655-4567
 web:  www.structuremonitoring.com


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



-- 
http://had.co.nz/

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


Re: [R] getting arg names in function calls?

2014-04-08 Thread William Dunlap
 I don't see how that solves
 the example I gave of extracting plot(x=0, y=1) from tstFn -
 function()plot(0, 1).

Try
 match.call(definition=plot, call=body(tstFn))
plot(x = 0, y = 1)

plot() is not a great example, since some of its methods do not have an
argument called 'y' (e.g., plot.stepfun) and it has a lot of ... arguments which
you need to go to the help file for.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: Spencer Graves [mailto:spencer.gra...@structuremonitoring.com]
 Sent: Tuesday, April 08, 2014 4:53 PM
 To: William Dunlap; R list
 Subject: Re: [R] getting arg names in function calls?
 
 Hi, Bill:
 
 
Thanks for the reply.  Unfortunately, I don't see how that solves
 the example I gave of extracting plot(x=0, y=1) from tstFn -
 function()plot(0, 1).
 
 
As I noted, body(tstFn) returns plot(0, 1) as an language
 object of class call.  My challenge is to convert that into something
 similar, with explicit names for the arguments.
 
 
Any thoughts?
Spencer
 
 
 On 4/7/2014 3:18 PM, William Dunlap wrote:
  Look at match.call().  E.g.,
  f - function(x, y = log2(x), ...) match.call()
  f()
 f()
  f(1, x=2, anotherArg=3, 4)
 f(x = 2, y = 1, anotherArg = 3, 4)
  or, using its 'definition' and 'call' arguments directly
  match.call(function(x, y, ...)NULL, quote(foo(1, x=2, extraArg=3, 4)))
 foo(x = 2, y = 1, extraArg = 3, 4)
  match.call(function(x, y, ...)NULL, quote(foo(1, x=2, extraArg=3, 4)),
 expand.dots=FALSE)
 foo(x = 2, y = 1, ... = list(extraArg = 3, 4))
 
  Bill Dunlap
  TIBCO Software
  wdunlap tibco.com
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf
  Of Spencer Graves
  Sent: Monday, April 07, 2014 3:05 PM
  To: R list
  Subject: [R] getting arg names in function calls?
 
  How can I convert plot(0, 1) into plot(x=0, y=1)?
 
 
  More generally, how can I get argument names assigned to function
  calls in language objects?
 
 
  Example:
 
 
  tstFn - function()plot(0, 1)
  bo - body(tstFn)
 
 
  tstFnxy - function()plot(x=0, y=1)
  boxy - body(tstFnxy)
 
 
  Is there a function that will modify bo to match boxy?
 
 
  My current solution requires me to know the names of the
  arguments for plot (in this example).  I'd prefer a more general
  solution.
 
 
  Thanks,
  Spencer
 
 
  p.s.  I'm trying to create an animation by repeatedly calling a function
  that contains something like text(0, 1, abc).  By computing on the
  language object 'text(0, 1, abc)', I can call text(0, 1, 'a') the
  first time, text(0, 1, 'ab') the second, and text(0, 1, 'abc') the
  third.  The function will be more general if I can get the names of the
  arguments as just described.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 --
 Spencer Graves, PE, PhD
 President and Chief Technology Officer
 Structure Inspection and Monitoring, Inc.
 751 Emerson Ct.
 San José, CA 95126
 ph:  408-655-4567
 web:  www.structuremonitoring.com

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


Re: [R] Label axis tick marks with a simple function of axis value

2014-04-08 Thread Hurr

This still puts tick marks at data points:
h=c(1,2,3,4,5,6,7,8,9)
v=c(9,8,7,6,5,4,3,2,1)
plot(h,v,xaxt='n')
x-c(1.6,2.6,6.6,9.6,12.9)
axis_labels-1/pretty(x)
axis(1,at=pretty(x),labels=axis_labels)
How do I get the axis to approx 13 ?




--
View this message in context: 
http://r.789695.n4.nabble.com/Label-axis-tick-marks-with-a-simple-function-of-axis-value-tp4687917p4688443.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Pull Stock Symbol Out of String

2014-04-08 Thread arun
Hi,
You may try:
library(qdap)
str1 - c(American Tower Corporation (REIT) (AMT), Aetna Inc. (AET))
unlist(lapply(bracketXtract(str1,round),tail,1),use.names=F)
#[1] AMT AET 

A.K.


On Tuesday, April 8, 2014 7:48 PM, Sparks, John James jspa...@uic.edu wrote:
Dear R Helpers,

My regex skills are beginner to intermediate and banging around the web
has not resulted in a solution to the problem below so I hope that one of
you who has mad skills can help me out.

I want to extract the stock ticker--AMT-- out of the string

American Tower Corporation (REIT) (AMT)

The presence of the other parenthetical text (REIT) makes this difficult. 
Please note that the string may or may not have a interfering set of
characters such as the (REIT) so the solution needs to be generalizable to
the last set of characters that are contained in parentheses in the larger
string.  So an example of a string without the interfering (REIT) would be

Aetna Inc. (AET)


Your assistance would be very much appreciated.

--John Sparks

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

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


Re: [R] Plotting does odd line thing

2014-04-08 Thread Frede Aakmann Tøgersen
See ? plot.default. Add the log = y to your call. Remember to set ylim to 
positive values since log only takes positive values, e.g. ylim = c(1e-6, 0.1).

Yours sincerely / Med venlig hilsen


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

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

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

From: David Doyle [mailto:kydaviddo...@gmail.com]
Sent: 8. april 2014 18:52
To: Frede Aakmann Tøgersen
Cc: Jim Lemon; r-help@r-project.org
Subject: Re: [R] Plotting does odd line thing

THANK you for the help!!

One more question.  Being I  need to compare 4 different wells, I like to have 
them all at the same scale which I can do with the  ylim=c(min,max).  But so 
the low concentrations don't get washed out, I like to plot the y axis in log 
format.  ie 0.001, 0.010, 0.100.  Below is the code I have so far.

Thanks in advance.

setwd(c:/R)

mydata -read.csv(http://doylesdartden.com/R/2014_02_data.csv;, sep=,)

attach(mydata)

plot(Arsenic~Year,data=mydata, subset = Well.ID %in% c(MW-1, D_Arsenic), 
col=ifelse(D_Arsenic, black, red),
ylab = mg/L,xlab = , pch=ifelse(D_Arsenic, 19, 17), cex = 1.5, ylim=c(0, 
0.1))


subset-Well.ID %in% c(MW-1, D_Arsenic)
lines(Arsenic[subset]~Year[subset])

#Add title
title(main=MW-1)


On Tue, Apr 8, 2014 at 12:52 AM, Frede Aakmann Tøgersen 
fr...@vestas.commailto:fr...@vestas.com wrote:
Well the lines() function has a subset argument as does plot() so why not do 
this?

lines(EMD ~ Year, data = mydata, subset = Well.ID %in% c(MW-1, D_EMD))

And yes lines() also have a data argument so why do you not use that (as you do 
with plot()) instead of attaching.

Attaching dataframes may be a potential danger when some time in the future you 
have forgot that you attached the dataframe and you have forgot the warnings 
you get when attaching (making debugging difficult).

Try this:

 ## Define an object named Year
 ## in which case call to lines do not what you think it will do
 Year - 1:nrow(mydata)

 ## or Year - 'foo' in which case one gets an error later

 ## attach the dataframe
  attach(mydata)

The following object is masked _by_ .GlobalEnv:

Year

Now what will happen if you do lines(EMD ~ Year)?

Here is the search path in my session:

 search()
 [1] .GlobalEnvmydatapackage:lattice
 [4] package:RODBC package:stats package:graphics
 [7] package:grDevices ESSR  package:utils
[10] package:datasets  package:methods   Autoloads
[13] package:base


Yours sincerely / Med venlig hilsen


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

Technology  Service Solutions
T +45 9730 5135tel:%2B45%209730%205135
M +45 2547 6050tel:%2B45%202547%206050
fr...@vestas.commailto:fr...@vestas.com
http://www.vestas.com

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


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org]
 On Behalf Of Jim Lemon
 Sent: 8. april 2014 04:53
 To: David Doyle
 Cc: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: Re: [R] Plotting does odd line thing

 On 04/08/2014 12:20 PM, David Doyle wrote:
  Hello folks,
 
  When I use the lines function below it connects all my points but then
  draws a line back to the start point.  Any suggestions on what is going on??
 
  mydata-read.csv(http://doylesdartden.com/R/test_data.csv;, sep=,)
 
  attach(mydata)
 
  plot(EMD~Year,data=mydata, subset = Well.ID %in% c(MW-1, D_EMD),
  col=ifelse(D_EMD, black, red), pch=ifelse(D_EDM, 19, 17), cex = 1.5)
 
  lines(EMD~Year)
 
 Hi David,
 While you will get what you expect with:

 lines(EMD[1:39]~Year[1:39])

 I would be unnecessarily obscure in suggesting it. Try this:

 subset-Well.ID %in% c(MW-1, D_EMD)
 lines(EMD[subset]~Year[subset])

 You haven't selected the same points for the lines function as you have
 for the plot function.

 Jim

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


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the