Re: [R] Euclidean Distance in 3 Dimensions

2014-08-22 Thread Patzelt, Edward
This function unfortunately does not work in 3d space.

Thoughts?


On Wed, Aug 20, 2014 at 4:57 PM, Don McKenzie d...@u.washington.edu wrote:

 ?dist

 from the help

 dist {stats}R Documentation
 Distance Matrix Computation

 Description

 This function computes and returns the distance matrix computed by using
 the specified distance measure to compute the distances between the rows of
 a data matrix.

 Is this what you want?  Computing on a matrix whose rows are your x, y,
 and z values?


 On Aug 20, 2014, at 1:12 PM, Patzelt, Edward patz...@g.harvard.edu
 wrote:

  R Community -
 
  I am attempting to write a function that will calculate the distance
  between points in 3 dimensional space for unique regions (e.g. localized
  brain regions such as the frontal lobe).
 
  For example I'm looking to compare each point in region 45 to every other
  region in 45 to establish if they are a distance of 8 or more apart. I
 can
  do this linearly comparing each distance to the previous but this is not
  comparing all points.
 
  structure(list(Cluster.Index = c(46L, 46L, 46L, 46L, 46L, 45L,
  45L, 45L, 45L, 45L, 44L, 44L, 44L, 44L, 44L, 43L, 43L, 43L, 43L,
  43L), Value = c(8.21, 7.96, 7.85, 7.83, 7.8, 5.38, 4.56, 4.5,
  4, 3.99, 5.42, 4.82, 4.21, 4.18, 3.91, 4.79, 4.27, 3.24, 3.06,
  3.04), x = c(33L, 38L, 37L, 36L, 38L, 47L, 42L, 43L, 44L, 42L,
  50L, 41L, 39L, 41L, 44L, 46L, 45L, 45L, 41L, 46L), y = c(15L,
  12L, 12L, 13L, 13L, 91L, 84L, 84L, 95L, 96L, 69L, 70L, 65L, 65L,
  59L, 41L, 40L, 46L, 44L, 47L), z = c(41L, 38L, 41L, 39L, 33L,
  39L, 40L, 42L, 44L, 45L, 34L, 36L, 30L, 35L, 39L, 53L, 47L, 61L,
  52L, 57L), X = c(NA, 6.557438524302, 3.16227766016838, 2.44948974278318,
  6.32455532033676, 78.7464284904401, 8.66025403784439, 2.23606797749979,
  11.2249721603218, 2.44948974278318, 30.2324329156619, 9.2736184954957,
  8.06225774829855, 5.3851648071345, 7.81024967590665, 22.8910462845192,
  6.16441400296898, 15.2315462117278, 10.0498756211209, 7.68114574786861
  )), .Names = c(Cluster.Index, Value, x, y, z, X), row.names =
  c(NA,
  20L), class = data.frame)
 
  mainDat - data.frame()
  for(i in 2:nrow(dat)){
  tempDist - (sqrt((dat$x[i] - dat$x[i-1])^2 + (dat$y[i] - dat$y[i-1])^2 +
  (dat$z[i] - dat$z[i-1])^2))
  dat$X[i] - c(tempDist)
  if(dat$Cluster.Index[i] != dat$Cluster.Index[i-1]){
  mainDat - rbind(mainDat, dat[i,])
  }
  if((dat$Cluster.Index[i] == dat$Cluster.Index[i-1])) {
  if(tempDist  8){
  mainDat - rbind(mainDat, dat[i,])
  }
  }
  }
 
 
 
 
  --
 
  *Edward H Patzelt | Clinical Science PhD StudentPsychology | Harvard
  University *
 
[[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.

 Don McKenzie
 Research Ecologist
 Pacific Wildland Fire Sciences Lab
 US Forest Service

 Affiliate Professor
 School of Environmental and Forest Sciences
 University of Washington
 d...@uw.edu







-- 

*Edward H Patzelt | Clinical Science PhD StudentPsychology | Harvard
University *

[[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] Euclidean Distance in 3 Dimensions

2014-08-22 Thread Patzelt, Edward
Your first description is correct with slight modification compare point 1
to all the other points in that Cluster.Index and see if any of euclidean
distances are greater than 8; do this for each point (i.e. point 2, point
3) in that specific Cluster.Index (i.e. 45)




On Thu, Aug 21, 2014 at 3:35 PM, David L Carlson dcarl...@tamu.edu wrote:

  The dist() function works just fine in 2d or 3d or 100d. Your
 description of what you want to accomplish is not clear. Your code compares
 rows 1 and 2, then 2 and 3, then 3 and 4, and so on. You are comparing only
 adjacent points, but your description makes it sound like you want to
 compare point 1 to all the other points and see if they are in the same
 group and over 8 or in another group. If you type the following command you
 will see that your dat$X is just the diagonal of the distance matrix: 1
 with 2, 2 with 3, 3 with 4 etc:



 dist(dat[, 3:5])



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



 *From:* r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 *On Behalf Of *Don McKenzie
 *Sent:* Thursday, August 21, 2014 1:44 PM
 *To:* Patzelt, Edward
 *Cc:* R-help@r-project.org
 *Subject:* Re: [R] Euclidean Distance in 3 Dimensions



 Ugh sorry.  I misread your message obviously. Cc�ing back to the list (as
 is the protocol)

 I�m surprised no one else has replied. I�m a lightweight compared to
 others on the list.  It looks as if the dist() function has compiled code,
 which suggests that there is some gnarly linear algebra underneath to
 speed it up even in 2D. Not for the faint-of-heart to hack.

 Others?  �dist3D�?

 On Aug 21, 2014, at 11:34 AM, Patzelt, Edward patz...@g.harvard.edu
 wrote:

  This function unfortunately does not work in 3d space.
 
  Thoughts?
 
 
  On Wed, Aug 20, 2014 at 4:57 PM, Don McKenzie d...@u.washington.edu
 wrote:
  ?dist
 
  from the help
 
  dist {stats}R Documentation
  Distance Matrix Computation
 
  Description
 
  This function computes and returns the distance matrix computed by using
 the specified distance measure to compute the distances between the rows of
 a data matrix.
 
  Is this what you want?  Computing on a matrix whose rows are your x, y,
 and z values?
 
 
  On Aug 20, 2014, at 1:12 PM, Patzelt, Edward patz...@g.harvard.edu
 wrote:
 
   R Community -
  
   I am attempting to write a function that will calculate the distance
   between points in 3 dimensional space for unique regions (e.g.
 localized
   brain regions such as the frontal lobe).
  
   For example I'm looking to compare each point in region 45 to every
 other
   region in 45 to establish if they are a distance of 8 or more apart. I
 can
   do this linearly comparing each distance to the previous but this is
 not
   comparing all points.
  
   structure(list(Cluster.Index = c(46L, 46L, 46L, 46L, 46L, 45L,
   45L, 45L, 45L, 45L, 44L, 44L, 44L, 44L, 44L, 43L, 43L, 43L, 43L,
   43L), Value = c(8.21, 7.96, 7.85, 7.83, 7.8, 5.38, 4.56, 4.5,
   4, 3.99, 5.42, 4.82, 4.21, 4.18, 3.91, 4.79, 4.27, 3.24, 3.06,
   3.04), x = c(33L, 38L, 37L, 36L, 38L, 47L, 42L, 43L, 44L, 42L,
   50L, 41L, 39L, 41L, 44L, 46L, 45L, 45L, 41L, 46L), y = c(15L,
   12L, 12L, 13L, 13L, 91L, 84L, 84L, 95L, 96L, 69L, 70L, 65L, 65L,
   59L, 41L, 40L, 46L, 44L, 47L), z = c(41L, 38L, 41L, 39L, 33L,
   39L, 40L, 42L, 44L, 45L, 34L, 36L, 30L, 35L, 39L, 53L, 47L, 61L,
   52L, 57L), X = c(NA, 6.557438524302, 3.16227766016838,
 2.44948974278318,
   6.32455532033676, 78.7464284904401, 8.66025403784439, 2.23606797749979,
   11.2249721603218, 2.44948974278318, 30.2324329156619, 9.2736184954957,
   8.06225774829855, 5.3851648071345, 7.81024967590665, 22.8910462845192,
   6.16441400296898, 15.2315462117278, 10.0498756211209, 7.68114574786861
   )), .Names = c(Cluster.Index, Value, x, y, z, X),
 row.names =
   c(NA,
   20L), class = data.frame)
  
   mainDat - data.frame()
   for(i in 2:nrow(dat)){
   tempDist - (sqrt((dat$x[i] - dat$x[i-1])^2 + (dat$y[i] -
 dat$y[i-1])^2 +
   (dat$z[i] - dat$z[i-1])^2))
   dat$X[i] - c(tempDist)
   if(dat$Cluster.Index[i] != dat$Cluster.Index[i-1]){
   mainDat - rbind(mainDat, dat[i,])
   }
   if((dat$Cluster.Index[i] == dat$Cluster.Index[i-1])) {
   if(tempDist  8){
   mainDat - rbind(mainDat, dat[i,])
   }
   }
   }
  
  
  
  
   --
  
   *Edward H Patzelt | Clinical Science PhD StudentPsychology | Harvard
   University *
  
 [[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.
 
  Don McKenzie
  Research Ecologist
  Pacific Wildland Fire Sciences Lab
  US Forest Service
 
  Affiliate Professor
  School of Environmental and Forest Sciences
  University of Washington
  

[R] Subsetting data for split-sample validation, then repeating 1000x

2014-08-22 Thread Angela Boag
Hi all,

I'm doing some within-dataset model validation and would like to subset a
dataset 70/30 and fit a model to 70% of the data (the training data), then
validate it by predicting the remaining 30% (the testing data), and I would
like to do this split-sample validation 1000 times and average the
correlation coefficient and r2 between the training and testing data.

I have the following working for a single iteration, and would like to know
how to use either the replicate() or for-loop functions to average the 1000
'r2' and 'cor' outputs.

--

# create 70% training sample
A.samp - sample(1:nrow(A),floor(0.7*nrow(A)), replace = TRUE)

# Fit model (I'm modeling native plant richness, 'nat.r')
A.model - glmmadmb(nat.r ~ isl.sz + nr.mead, random = ~ 1 | site, family =
poisson, data = A[A.samp,])

# Use the model to predict the remaining 30% of the data
A.pred - predict(A.model, newdata = A[-A.samp,], type = response)

# Correlation between predicted 30% and actual 30%
cor - cor(A[-A.samp,]$nat.r, A.pred, method = pearson)

# r2 between predicted and observed
lm.A - lm(A.pred ~ A[-A.samp,]$nat.r)
r2 - summary(lm.A)$r.squared

# print values
r2
cor

--

Thanks for your time!

Cheers,
Angela

--
Angela E. Boag
Ph.D. Student, Environmental Studies
CAFOR Project Researcher
University of Colorado, Boulder
Mobile: 720-212-6505

[[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] loading saved files with objects in same names

2014-08-22 Thread Martin Maechler

 Have you tried the 'envir' argument to load()?  E.g.,
envA - new.environment()
load(A.RData, envir=envA)
envB - new.environment()
load(B.RData, envir=envB)
plot(A$object, B$object)

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

An alternative that I have been advocating is using

  attach(A.RData)

etc. It does something similar as the above, but more
conveniently:
It loads the objects into a new environment  *and* attaches that
environment to your search()  path, so you can access them
directly, but attach() will never accidentally destroy existing
R objects in your global environment ( = search()[[1]] ).

Martin





 On Mon, Aug 18, 2014 at 5:30 PM, Jinsong Zhao jsz...@yeah.net wrote:
 Hi there,

 I have several saved data files (e.g., A.RData, B.RData and C.RData). In
 each file, there are some objects with same names but different contents.
 Now, I need to compare those objects through plotting. However, I can't find
 a way to load them into a workspace. The only thing I can do is to rename
 them and then save and load again.

 Is there a convenient to load those objects?

 Thanks a lot in advance.

 Best regards,
 Jinsong

 __
 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-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 on installing R packages in a Citrix

2014-08-22 Thread Jon-Paul Cameron
Hi



We are currently trying to migrate 3 users of R to a citrix based 
environment, but are coming across major issues trying to install the packages 
to the relevant image. Can someone please contact me around how the install 
should be done - as we can find no supporting documentation or help on this 
matter.



I already sent this request to R-packages for help, but was told this was the 
correct Forum for info of this type.



Many thanks



Jon-Paul Cameron

Systems Support Manager




Jon-Paul Cameron
Systems Support Manager


Direct tel: + 44  (0)20  7680 8046
Email: j.came...@hermes.co.ukmailto:j.came...@hermes.co.uk

Hermes Fund Managers
1 Portsoken Street
London, E1 8HZ
Switchboard: +44 (0)20 7702 0888

www.hermesfundmanagers.comhttp://www.hermesfundmanagers.com/





**
Hermes Fund Managers Limited
Registered in England No. 1661776, 1 Portsoken Street, London E1 8HZ

***Please read the Hermes email disclaimer at 
http://www.hermes.co.uk/email_terms.htm before acting on this email or opening 
any attachment***
The contents of this email are confidential.  If you hav...{{dropped:20}}

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


Re: [R] Help on installing R packages in a Citrix

2014-08-22 Thread David Winsemius

On Aug 22, 2014, at 12:36 AM, Jon-Paul Cameron wrote:

 Hi
 
 We are currently trying to migrate 3 users of R to a citrix based 
 environment,

Windows?, Linux? Citrix isn't usually thought of as an OS is it?


 but are coming across major issues trying to install the packages to the 
 relevant image. Can someone please contact me around how the install should 
 be done - as we can find no supporting documentation or help on this matter.

http://cran.us.r-project.org/manuals.html

 
 I already sent this request to R-packages for help, but was told this was 
 the correct Forum for info of this type.

Have you installed R? Which OS? Which version?

-- 
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] no visible binding for global variable and with() vs. within()

2014-08-22 Thread Martin Maechler
 Rolf Turner r.tur...@auckland.ac.nz
 on Mon, 18 Aug 2014 08:47:36 +1200 writes:

 On 17/08/14 23:05, Duncan Murdoch wrote:
 On 16/08/2014, 9:36 PM, Daniel Braithwaite wrote:
 R CMD check does not object to this code when checking a
 package:
 
 foo1 - function (bar) { with(bar, { x }) }
 
 but produces a warning:
 
 foo2: no visible binding for global variable 'x'
 
 in response to this:
 
 foo2 - function (bar) { within(bar, { x }) }
 
 Is this an R bug, or at least, an inadvertent
 inconsistency?  Here is sessionInfo() from my machine,
 right after starting an interactive session:
 
 I'm not sure, but I suspect it's an intentional
 inconsistency.  The code that checks for use of globals
 can't do anything in with() or within() code, so bugs can
 slip by if you use those.  I think with() had been around
 for a long time and was in wide use when that test was
 added, but within() is newer, and it was less disruptive
 to warn about it, so the warning has been left in.  (I
 don't remember whether the test came before or after
 within() was introduced.)
 
 So if you want to avoid the warning, don't use within().

 Or you could have a file, say melvin.R, in the R
 directory of your package, containing the line:

   utils::globalVariables(x)

Yes,  but that would be a quite bad idea, IMHO:

The checking code {from package 'codetools' BTW}
would no longer warn you about any accidental global 'x'
variable in any of your functions in your package.

After all, these codetools checks *are* very helpful in
detecting typos and thinkos.
Consequently, I'd strongly advise to only use
globalVariables(.) on *rare* variable names.

Martin Maechler, 
ETH Zurich

__
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] loading saved files with objects in same names

2014-08-22 Thread Martin Maechler
 On 20/08/2014, 8:58 AM, Barry Rowlingson wrote:
  On Tue, Aug 19, 2014 at 1:30 AM, Jinsong Zhao jsz...@yeah.net wrote:
  Hi there,
 
  I have several saved data files (e.g., A.RData, B.RData and C.RData). In
  each file, there are some objects with same names but different
  contents. Now, I need to compare those objects through plotting.
  However, I can't find a way to load them into a workspace. The only
  thing I can do is to rename them and then save and load again.
 
  Is there a convenient to load those objects?
 
  Thanks a lot in advance.
  
  The technique of loading into an environment already mentioned can be
  cleaned up and put into a function.
  
  First lets save a thing called x into two files with different values:
  
x=first
save(x,file=f.RData))
x=second
save(x,file=s.RData)
  
  This little function wraps the loading:
  
getFrom=function(file, name){e=new.env();load(file,env=e);e[[name]]}
  
  So now I can get 'x' from the first file - the value is returned from
  `getFrom` so I can assign it to anything:
  
x1 =  getFrom(f.RData,x)
x1
  [1] first
x2 = getFrom(s.RData,x)
x2
  [1] second
  
  And I can even loop over RData files and read in all the `x`s into a vector:
  
sapply(c(f.RData,s.RData),function(f){getFrom(f,x)})
f.RData  s.RData
first second
  
  (on second thoughts, possibly 'loadFrom' is a better name)

 That's a nice little function.  You could also have lsFrom, that lists
 the objects stored in the file, along the same lines:

 lsFrom - function(file, all.names = FALSE, pattern) {
   e - new.env()
   load(file, envir = e)
   ls(e, all.names = all.names, pattern = pattern)
 }

 Duncan Murdoch

Note that the solution of simply using 

 attach(f.RData)

makes the use of  ls()  very natural, 
and for Rstudio and similar gui users, even automatically part of
their GUI.

Martin Maechler

__
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] knitr and stopifnot replacement.

2014-08-22 Thread Bart Kastermans
I have a daily generated report in which I put a check using stopifnot.  
Unfortunately
I didn’t check the effect very well, turns out that if the condition checked 
fails
this is not shown in the knitr output (I only get an error much later due to a 
missing
object).

So my question is, what is the correct way to use assertions in a filename.Rnw
file.  I want to perform a check, and if it fails everything should stop with a 
message
I can generate.

Thanks,

Best,
Bart
__
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] knitr and stopifnot replacement.

2014-08-22 Thread Duncan Murdoch
On 22/08/2014, 6:02 AM, Bart Kastermans wrote:
 I have a daily generated report in which I put a check using stopifnot.  
 Unfortunately
 I didn’t check the effect very well, turns out that if the condition checked 
 fails
 this is not shown in the knitr output (I only get an error much later due to 
 a missing
 object).
 
 So my question is, what is the correct way to use assertions in a 
 filename.Rnw
 file.  I want to perform a check, and if it fails everything should stop with 
 a message
 I can generate.
 

One of the differences between knitr and Sweave is that knitr handles
errors, and Sweave doesn't.  I expect there's some knitr option to tell
it to quit in case of error (a hook?), but you'll have to check the
documentation to find it.

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] knitr and stopifnot replacement.

2014-08-22 Thread Bart Kastermans
On 22 Aug 2014, at 12:39, Duncan Murdoch murdoch.dun...@gmail.com wrote:

 On 22/08/2014, 6:02 AM, Bart Kastermans wrote:
 I have a daily generated report in which I put a check using stopifnot.  
 Unfortunately
 I didn’t check the effect very well, turns out that if the condition checked 
 fails
 this is not shown in the knitr output (I only get an error much later due to 
 a missing
 object).
 
 So my question is, what is the correct way to use assertions in a 
 filename.Rnw
 file.  I want to perform a check, and if it fails everything should stop 
 with a message
 I can generate.
 
 
 One of the differences between knitr and Sweave is that knitr handles
 errors, and Sweave doesn't.  I expect there's some knitr option to tell
 it to quit in case of error (a hook?), but you'll have to check the
 documentation to find it.

Thanks; that helped me to find the exact right option:

filelist, error=FALSE=
# check all files exist before continuing
stopifnot(all(sapply(files, file.exists)))
@


 
 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] Help on installing R packages in a Citrix

2014-08-22 Thread S Ellison
 We are currently trying to migrate 3 users of R to a citrix based
 environment, but are coming across major issues trying to install the
 packages to the relevant image. 

Why can't you open a virtualised OS instance, install and start R in the normal 
way, install the packages normally in R using install.packages and then save 
the image for re-use?

S


***
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] Help on installing R packages in a Citrix

2014-08-22 Thread arnaud gaboury
On Fri, Aug 22, 2014 at 2:03 PM, S Ellison s.elli...@lgcgroup.com wrote:
 We are currently trying to migrate 3 users of R to a citrix based
 environment, but are coming across major issues trying to install the
 packages to the relevant image.


Please be more precised in your issue.

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


[R] Help with analysis of variance

2014-08-22 Thread McCulloch, Andrew
Hi,



I have an observational dataset which consists of eight annual observations 
(year) for children (id) recording the rate of unemployment in the 
neighbourhood in which they lived (rate). I know if children move home so the 
data also has an identifier for spells in the same neighbourhood (spell). I 
want to decompose the overall variation in children's experience of area 
unemployment, given by the sum of (rate - mean rate)^2, into a) the component 
within a residential spell, sum of (rate - spell mean of rate)^2, b) the 
component between spells, sum of (spell mean), and c) the component between 
children, sum of (rate - mean rate for child). I think I can do this longhand 
using the calculations below:



mobility - structure(list(year = c(2002L, 2003L, 2004L, 2005L, 2006L, 
2007L,2008L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2002L,

2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2002L, 2003L, 2004L,

2005L, 2006L, 2007L, 2008L, 2002L, 2003L, 2004L, 2005L, 2006L,

2007L, 2008L), rate = c(13.08962, 14.27165, 4.496403, 3.89839,

4.60199, 5.138746, 5.251025, 4.874652, 5.880996, 5.813953, 6.204044,

6.93802, 6.866853, 7.614808, 4.405841, 4.826733, 4.760742, 3.762136,

4.60199, 5.138746, 5.251025, 4.405841, 4.826733, 4.760742, 3.762136,

4.60199, 5.138746, 5.251025, 4.405841, 5.789474, 5.889423, 4.61211,

4.642526, 6.838906, 9.683488), spell = c(1L, 2L, 2L, 3L, 3L,

3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,

1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L), id = c(1L,

1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,

3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L,

5L, 5L)), .Names = c(year, rate, spell, id), row.names = c(NA,

-35L), class = data.frame)



mobility$id - factor(mobility$id)

mobility$spell - factor(mobility$spell)



mobility$spellmean - ave(mobility$rate,mobility$id,mobility$spell,FUN=mean)

mobility$personmean - ave(mobility$rate,mobility$id,FUN=mean)

mobility$totalmean - mean(mobility$rate,na.rm=TRUE)

N - dim(mobility)[1]

# observation deviation from overall mean

sum(((mobility$rate-mobility$totalmean)^2)/N)

5.159846

# observation deviation from spell mean

sum(((mobility$rate-mobility$spellmean)^2)/N)

2.039461

# deviation of spell mean from person mean

sum(((mobility$spellmean-mobility$personmean)^2)/N)

2.13787

# deviation of person mean from overall mean

sum(((mobility$personmean-mobility$totalmean)^2)/N)

0.982515



I think this is correct because the sum of the three components of variation 
sums to the total:

2.039461+2.13787+0.982515 = 5.159846



Can someone show me how to use the analysis of variance functions in R to get 
the same result. Thanks.

Andrew McCulloch
Leeds Metropolitan University






From 22 September 2014 Leeds Metropolitan University will become Leeds Beckett 
University.
Find out more at http://www.leedsbeckett.ac.uk
To view the terms under which this email is distributed, please go to:-
http://www.leedsmet.ac.uk/email-disclaimer.htm

[[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] print vectors with consecutive numbers

2014-08-22 Thread James Wei


Hi all,

I have a matrix with consecutive and non-consecutive numbers
in columns. For example, the first 2 columns have consecutive numbers. I want R
to print only columns with consecutive numbers. Here is the matrix and how I
did using conditional statement: 

##

mat=matrix(data=c(9,2,3,4,5,6,10,13,15,17,19,22,
25,27,29,31,34,37,39,41),ncol=5)

mat

difference = diff(mat)==1

difference

y1=difference[1,]

y2=difference[2,]

y3=difference[3,]

y=(y1|y2|y3)

y

 

if (y==TRUE) mat else 0

## 

However, R still print all 5 columns, not the first 2
columns I wanted. I got the Warning message:

In if (y == TRUE) mat else 0 :

  the condition has
length  1 and only the first element will be used 

How can I change the code to get only the first 2 columns
with consecutive numbers printed? I am new to R.  

Thanks in advance for your help. James  

  
[[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] print vectors with consecutive numbers

2014-08-22 Thread Jorge I Velez
Hi James,

Try

mat[, apply(mat, 2, function(x) any(diff(x) == 1))]

HTH,
Jorge.-



On Fri, Aug 22, 2014 at 10:18 PM, James Wei zwei0...@hotmail.com wrote:



 Hi all,

 I have a matrix with consecutive and non-consecutive numbers
 in columns. For example, the first 2 columns have consecutive numbers. I
 want R
 to print only columns with consecutive numbers. Here is the matrix and how
 I
 did using conditional statement:

 ##

 mat=matrix(data=c(9,2,3,4,5,6,10,13,15,17,19,22,
 25,27,29,31,34,37,39,41),ncol=5)

 mat

 difference = diff(mat)==1

 difference

 y1=difference[1,]

 y2=difference[2,]

 y3=difference[3,]

 y=(y1|y2|y3)

 y



 if (y==TRUE) mat else 0

 ##

 However, R still print all 5 columns, not the first 2
 columns I wanted. I got the Warning message:

 In if (y == TRUE) mat else 0 :

   the condition has
 length  1 and only the first element will be used

 How can I change the code to get only the first 2 columns
 with consecutive numbers printed? I am new to R.

 Thanks in advance for your help. James


 [[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] Help with analysis of variance

2014-08-22 Thread Richard M. Heiberger
Andrew,

I plotted your data first.  Then I made id, spell, year into factors
and did the ANOVA.
From the graph, it looks like the two ids who had more than one spell
show variability in rate.
The ANOVA table agrees by showing high significance for the id:spell
interaction.
The numbers in this ANOVA table are not similar to your numbers.

Rich

mobility$id - factor(mobility$id)
mobility$spell - factor(mobility$spell)
mobility$year - factor(mobility$year)

xyplot(rate ~ year | id, group=spell, data=mobility,
   pch=19, layout=c(1,5), scales=list(alternating=FALSE),
   between=list(y=1),
   strip=FALSE, strip.left=strip.custom(strip.names=c(TRUE,TRUE)))

mobility.aov - aov(rate ~ year + id/spell, data=mobility)
anova(mobility.aov)


On Fri, Aug 22, 2014 at 7:51 AM, McCulloch, Andrew
a.mccull...@leedsmet.ac.uk wrote:
 Hi,



 I have an observational dataset which consists of eight annual observations 
 (year) for children (id) recording the rate of unemployment in the 
 neighbourhood in which they lived (rate). I know if children move home so the 
 data also has an identifier for spells in the same neighbourhood (spell). I 
 want to decompose the overall variation in children's experience of area 
 unemployment, given by the sum of (rate - mean rate)^2, into a) the component 
 within a residential spell, sum of (rate - spell mean of rate)^2, b) the 
 component between spells, sum of (spell mean), and c) the component between 
 children, sum of (rate - mean rate for child). I think I can do this longhand 
 using the calculations below:



 mobility - structure(list(year = c(2002L, 2003L, 2004L, 2005L, 2006L, 
 2007L,2008L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2002L,

 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2002L, 2003L, 2004L,

 2005L, 2006L, 2007L, 2008L, 2002L, 2003L, 2004L, 2005L, 2006L,

 2007L, 2008L), rate = c(13.08962, 14.27165, 4.496403, 3.89839,

 4.60199, 5.138746, 5.251025, 4.874652, 5.880996, 5.813953, 6.204044,

 6.93802, 6.866853, 7.614808, 4.405841, 4.826733, 4.760742, 3.762136,

 4.60199, 5.138746, 5.251025, 4.405841, 4.826733, 4.760742, 3.762136,

 4.60199, 5.138746, 5.251025, 4.405841, 5.789474, 5.889423, 4.61211,

 4.642526, 6.838906, 9.683488), spell = c(1L, 2L, 2L, 3L, 3L,

 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,

 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L), id = c(1L,

 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,

 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L,

 5L, 5L)), .Names = c(year, rate, spell, id), row.names = c(NA,

 -35L), class = data.frame)



 mobility$id - factor(mobility$id)

 mobility$spell - factor(mobility$spell)



 mobility$spellmean - ave(mobility$rate,mobility$id,mobility$spell,FUN=mean)

 mobility$personmean - ave(mobility$rate,mobility$id,FUN=mean)

 mobility$totalmean - mean(mobility$rate,na.rm=TRUE)

 N - dim(mobility)[1]

 # observation deviation from overall mean

 sum(((mobility$rate-mobility$totalmean)^2)/N)

 5.159846

 # observation deviation from spell mean

 sum(((mobility$rate-mobility$spellmean)^2)/N)

 2.039461

 # deviation of spell mean from person mean

 sum(((mobility$spellmean-mobility$personmean)^2)/N)

 2.13787

 # deviation of person mean from overall mean

 sum(((mobility$personmean-mobility$totalmean)^2)/N)

 0.982515



 I think this is correct because the sum of the three components of variation 
 sums to the total:

 2.039461+2.13787+0.982515 = 5.159846



 Can someone show me how to use the analysis of variance functions in R to get 
 the same result. Thanks.

 Andrew McCulloch
 Leeds Metropolitan University






 From 22 September 2014 Leeds Metropolitan University will become Leeds 
 Beckett University.
 Find out more at http://www.leedsbeckett.ac.uk
 To view the terms under which this email is distributed, please go to:-
 http://www.leedsmet.ac.uk/email-disclaimer.htm

 [[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] knitr and stopifnot replacement.

2014-08-22 Thread Yihui Xie
Yep, that is exactly the answer.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Web: http://yihui.name


On Fri, Aug 22, 2014 at 6:35 AM, Bart Kastermans kaste...@kasterma.net wrote:
 On 22 Aug 2014, at 12:39, Duncan Murdoch murdoch.dun...@gmail.com wrote:

 On 22/08/2014, 6:02 AM, Bart Kastermans wrote:
 I have a daily generated report in which I put a check using stopifnot.  
 Unfortunately
 I didn’t check the effect very well, turns out that if the condition 
 checked fails
 this is not shown in the knitr output (I only get an error much later due 
 to a missing
 object).

 So my question is, what is the correct way to use assertions in a 
 filename.Rnw
 file.  I want to perform a check, and if it fails everything should stop 
 with a message
 I can generate.


 One of the differences between knitr and Sweave is that knitr handles
 errors, and Sweave doesn't.  I expect there's some knitr option to tell
 it to quit in case of error (a hook?), but you'll have to check the
 documentation to find it.

 Thanks; that helped me to find the exact right option:

 filelist, error=FALSE=
 # check all files exist before continuing
 stopifnot(all(sapply(files, file.exists)))
 @

__
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] Euclidean Distance in 3 Dimensions

2014-08-22 Thread William Dunlap
 This function unfortunately does not work in 3d space.

[I think 'this' is refering to the 'dist' function.]

Can you show how it is not working for you?  I.e., what does it
produce compared to what you want for a given input?

dist() does work on a 3-column (or n-column) matrix or data.frame,
which is how R generally represents 3 dimensional (or n dimensional)
data.  E.g.,

   d - data.frame(One=1:3, Two=c(3,5,8), Three=c(4,8,16))
   d
One Two Three
  1   1   3 4
  2   2   5 8
  3   3   816
   dist(d)
1 2
  2  4.582576
  3 13.152946  8.602325
   as.matrix(dist(d)) # the matrix format makes further compuations easier
12 3
  1  0.00 4.582576 13.152946
  2  4.582576 0.00  8.602325
  3 13.152946 8.602325  0.00
   which(as.matrix(dist(d))8, arr.ind=TRUE)
row col
  3   3   1
  3   3   2
  1   1   3
  2   2   3
   sqrt(sum((d[,2] - d[,3])^2)) # the 2,3 or 3,2 element, by hand
  [1] 8.602325

I think it would help if you restated your problem.  I found the original
description confusing.  A small example, with the expected output, would
be very helpful.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Aug 21, 2014 at 11:34 AM, Patzelt, Edward patz...@g.harvard.edu wrote:
 This function unfortunately does not work in 3d space.

 Thoughts?


 On Wed, Aug 20, 2014 at 4:57 PM, Don McKenzie d...@u.washington.edu wrote:

 ?dist

 from the help

 dist {stats}R Documentation
 Distance Matrix Computation

 Description

 This function computes and returns the distance matrix computed by using
 the specified distance measure to compute the distances between the rows of
 a data matrix.

 Is this what you want?  Computing on a matrix whose rows are your x, y,
 and z values?


 On Aug 20, 2014, at 1:12 PM, Patzelt, Edward patz...@g.harvard.edu
 wrote:

  R Community -
 
  I am attempting to write a function that will calculate the distance
  between points in 3 dimensional space for unique regions (e.g. localized
  brain regions such as the frontal lobe).
 
  For example I'm looking to compare each point in region 45 to every other
  region in 45 to establish if they are a distance of 8 or more apart. I
 can
  do this linearly comparing each distance to the previous but this is not
  comparing all points.
 
  structure(list(Cluster.Index = c(46L, 46L, 46L, 46L, 46L, 45L,
  45L, 45L, 45L, 45L, 44L, 44L, 44L, 44L, 44L, 43L, 43L, 43L, 43L,
  43L), Value = c(8.21, 7.96, 7.85, 7.83, 7.8, 5.38, 4.56, 4.5,
  4, 3.99, 5.42, 4.82, 4.21, 4.18, 3.91, 4.79, 4.27, 3.24, 3.06,
  3.04), x = c(33L, 38L, 37L, 36L, 38L, 47L, 42L, 43L, 44L, 42L,
  50L, 41L, 39L, 41L, 44L, 46L, 45L, 45L, 41L, 46L), y = c(15L,
  12L, 12L, 13L, 13L, 91L, 84L, 84L, 95L, 96L, 69L, 70L, 65L, 65L,
  59L, 41L, 40L, 46L, 44L, 47L), z = c(41L, 38L, 41L, 39L, 33L,
  39L, 40L, 42L, 44L, 45L, 34L, 36L, 30L, 35L, 39L, 53L, 47L, 61L,
  52L, 57L), X = c(NA, 6.557438524302, 3.16227766016838, 2.44948974278318,
  6.32455532033676, 78.7464284904401, 8.66025403784439, 2.23606797749979,
  11.2249721603218, 2.44948974278318, 30.2324329156619, 9.2736184954957,
  8.06225774829855, 5.3851648071345, 7.81024967590665, 22.8910462845192,
  6.16441400296898, 15.2315462117278, 10.0498756211209, 7.68114574786861
  )), .Names = c(Cluster.Index, Value, x, y, z, X), row.names =
  c(NA,
  20L), class = data.frame)
 
  mainDat - data.frame()
  for(i in 2:nrow(dat)){
  tempDist - (sqrt((dat$x[i] - dat$x[i-1])^2 + (dat$y[i] - dat$y[i-1])^2 +
  (dat$z[i] - dat$z[i-1])^2))
  dat$X[i] - c(tempDist)
  if(dat$Cluster.Index[i] != dat$Cluster.Index[i-1]){
  mainDat - rbind(mainDat, dat[i,])
  }
  if((dat$Cluster.Index[i] == dat$Cluster.Index[i-1])) {
  if(tempDist  8){
  mainDat - rbind(mainDat, dat[i,])
  }
  }
  }
 
 
 
 
  --
 
  *Edward H Patzelt | Clinical Science PhD StudentPsychology | Harvard
  University *
 
[[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.

 Don McKenzie
 Research Ecologist
 Pacific Wildland Fire Sciences Lab
 US Forest Service

 Affiliate Professor
 School of Environmental and Forest Sciences
 University of Washington
 d...@uw.edu







 --

 *Edward H Patzelt | Clinical Science PhD StudentPsychology | Harvard
 University *

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

Re: [R] Help on installing R packages in a Citrix

2014-08-22 Thread David Winsemius

On Aug 22, 2014, at 7:37 AM, Chirag Patel wrote:

 Hi David
  
 I have installed R Version 2.15.1 on the image but having problems install 
 rcom and rscproxy.

Those are commercial packages and not maintained or supported by R-Core

(That is also a rather old version of R and would have gotten the advice to 
update before further comments were offered if the above sentence were not 
applicable.)

Since the error message says the packages are nota available for R 2.15.1 I 
would go to the author's website and see what versions those packages are 
available for. Standard message to users: read the error messages for meaning.

-- 
David.
  
 I'm following this guide:
  
 http://homepage.univie.ac.at/erich.neuwirth/php/rcomwiki/doku.php?id=wiki:how_to_install#installation_of_r_r_d_com_server_and_rexcel
  
 Download the statconn DCOM server and execute the program you downloaded
 Start R as administrator (on Windows 7 you need to right-click the R icon and 
 click the corresponding item)
 In R, run the following commands (you must start R as administrator to do 
 this)
  
 install.packages(c(rscproxy,rcom),repos=http://rcom.univie.ac.at/download,lib=.Library)
 library(rcom)
 comRegisterRegistry()
  
 i get the following message:
  
 image001.png
 Please can you help me?
  
 Many Thanks
  
 Chirag Patel
  
  
 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net] 
 Sent: 22 August 2014 09:29
 To: Jon-Paul Cameron
 Cc: 'r-help@R-project.org'; Scott Waters; #BST - Citrix Support
 Subject: Re: [R] Help on installing R packages in a Citrix
  
  
 On Aug 22, 2014, at 12:36 AM, Jon-Paul Cameron wrote:
  
  Hi
 
  We are currently trying to migrate 3 users of R to a citrix based 
  environment,
  
 Windows?, Linux? Citrix isn't usually thought of as an OS is it?
  
  
  but are coming across major issues trying to install the packages to the 
  relevant image. Can someone please contact me around how the install should 
  be done - as we can find no supporting documentation or help on this matter.
  
 http://cran.us.r-project.org/manuals.html
  
 
  I already sent this request to R-packages for help, but was told this was 
  the correct Forum for info of this type.
  
 Have you installed R? Which OS? Which version?
  
 --
 David Winsemius
 Alameda, CA, USA
  
 __


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] print vectors with consecutive numbers

2014-08-22 Thread James Wei
Hi Jorge,
 
Thanks so much, it is working perfectly. There are so many for me to learn.
 
Cheers.
 
James
 
From: jorgeivanve...@gmail.com
Date: Fri, 22 Aug 2014 22:28:40 +1000
Subject: Re: [R] print vectors with consecutive numbers
To: zwei0...@hotmail.com
CC: r-help@r-project.org

Hi James,


Try
mat[, apply(mat, 2, function(x) any(diff(x) == 1))]



HTH,

Jorge.-


On Fri, Aug 22, 2014 at 10:18 PM, James Wei zwei0...@hotmail.com wrote:






Hi all,



I have a matrix with consecutive and non-consecutive numbers

in columns. For example, the first 2 columns have consecutive numbers. I want R

to print only columns with consecutive numbers. Here is the matrix and how I

did using conditional statement:



##



mat=matrix(data=c(9,2,3,4,5,6,10,13,15,17,19,22,

25,27,29,31,34,37,39,41),ncol=5)



mat



difference = diff(mat)==1



difference



y1=difference[1,]



y2=difference[2,]



y3=difference[3,]



y=(y1|y2|y3)



y







if (y==TRUE) mat else 0



##



However, R still print all 5 columns, not the first 2

columns I wanted. I got the Warning message:



In if (y == TRUE) mat else 0 :



  the condition has

length  1 and only the first element will be used



How can I change the code to get only the first 2 columns

with consecutive numbers printed? I am new to R.



Thanks in advance for your help. James





[[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] print vectors with consecutive numbers

2014-08-22 Thread Bert Gunter
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Fri, Aug 22, 2014 at 7:16 AM, James Wei zwei0...@hotmail.com wrote:
 Hi Jorge,

 Thanks so much, it is working perfectly. There are so many for me to learn.

Have you done an R tutorial?  e.g.

http://cran.r-project.org/doc/manuals/R-intro.pdf

(This ships with R. There are many others around the web. Just search).

If not, please do not post further until you have done so. You cannot
complain of ignorance when you have not made an honest effort to
learn. And if you have already, post away.

Cheers,
Bert


 Cheers.

 James

 From: jorgeivanve...@gmail.com
 Date: Fri, 22 Aug 2014 22:28:40 +1000
 Subject: Re: [R] print vectors with consecutive numbers
 To: zwei0...@hotmail.com
 CC: r-help@r-project.org

 Hi James,


 Try
 mat[, apply(mat, 2, function(x) any(diff(x) == 1))]



 HTH,

 Jorge.-


 On Fri, Aug 22, 2014 at 10:18 PM, James Wei zwei0...@hotmail.com wrote:






 Hi all,



 I have a matrix with consecutive and non-consecutive numbers

 in columns. For example, the first 2 columns have consecutive numbers. I want 
 R

 to print only columns with consecutive numbers. Here is the matrix and how I

 did using conditional statement:



 ##



 mat=matrix(data=c(9,2,3,4,5,6,10,13,15,17,19,22,

 25,27,29,31,34,37,39,41),ncol=5)



 mat



 difference = diff(mat)==1



 difference



 y1=difference[1,]



 y2=difference[2,]



 y3=difference[3,]



 y=(y1|y2|y3)



 y







 if (y==TRUE) mat else 0



 ##



 However, R still print all 5 columns, not the first 2

 columns I wanted. I got the Warning message:



 In if (y == TRUE) mat else 0 :



   the condition has

 length  1 and only the first element will be used



 How can I change the code to get only the first 2 columns

 with consecutive numbers printed? I am new to R.



 Thanks in advance for your help. James





 [[alternative HTML version deleted]]



 __

 R-help@r-project.org mailing list

 https://stat.ethz.ch/mailman/listinfo/r-help

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

 and provide commented, minimal, self-contained, reproducible code.



 [[alternative HTML version deleted]]

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

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


Re: [R] Help on installing R packages in a Citrix

2014-08-22 Thread David Winsemius

On Aug 22, 2014, at 9:13 AM, David Winsemius wrote:

 
 On Aug 22, 2014, at 7:37 AM, Chirag Patel wrote:
 
 Hi David
 
 I have installed R Version 2.15.1 on the image but having problems install 
 rcom and rscproxy.
 
 Those are commercial packages and not maintained or supported by R-Core

I need to clarify that statement:

http://homepage.univie.ac.at/erich.neuwirth/php/rcomwiki/doku.php?id=wiki:how_to_install

rcom is placed on CRAN but authored by the people who distribute RExcel, so 
technically it's not a commercial product itself but it is made available to 
support a commercial product. You will notice in its requirements statconnDCOM:

And it's wiki says rcom does not comply with CRAN open source requirements 
anymore:

http://homepage.univie.ac.at/erich.neuwirth/php/rcomwiki/doku.php?id=start

-- 
David.

 
 (That is also a rather old version of R and would have gotten the advice to 
 update before further comments were offered if the above sentence were not 
 applicable.)
 
 Since the error message says the packages are nota available for R 2.15.1 I 
 would go to the author's website and see what versions those packages are 
 available for. Standard message to users: read the error messages for meaning.
 
 -- 
 David.
 
 I'm following this guide:
 
 http://homepage.univie.ac.at/erich.neuwirth/php/rcomwiki/doku.php?id=wiki:how_to_install#installation_of_r_r_d_com_server_and_rexcel
 
 Download the statconn DCOM server and execute the program you downloaded
 Start R as administrator (on Windows 7 you need to right-click the R icon 
 and click the corresponding item)
 In R, run the following commands (you must start R as administrator to do 
 this)
 
 install.packages(c(rscproxy,rcom),repos=http://rcom.univie.ac.at/download,lib=.Library)
 library(rcom)
 comRegisterRegistry()
 
 i get the following message:
 
 image001.png
 Please can you help me?
 
 Many Thanks
 
 Chirag Patel
 
 
 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net] 
 Sent: 22 August 2014 09:29
 To: Jon-Paul Cameron
 Cc: 'r-help@R-project.org'; Scott Waters; #BST - Citrix Support
 Subject: Re: [R] Help on installing R packages in a Citrix
 
 
 On Aug 22, 2014, at 12:36 AM, Jon-Paul Cameron wrote:
 
 Hi
 
 We are currently trying to migrate 3 users of R to a citrix based 
 environment,
 
 Windows?, Linux? Citrix isn't usually thought of as an OS is it?
 
 
 but are coming across major issues trying to install the packages to the 
 relevant image. Can someone please contact me around how the install should 
 be done - as we can find no supporting documentation or help on this matter.
 
 http://cran.us.r-project.org/manuals.html
 
 
 I already sent this request to R-packages for help, but was told this was 
 the correct Forum for info of this type.
 
 Have you installed R? Which OS? Which version?
 
 --
 David Winsemius
 Alameda, CA, USA
 
 __
 
 
 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] loading saved files with objects in same names

2014-08-22 Thread Jinsong Zhao

On 2014/8/22 1:02, Martin Maechler wrote:



Have you tried the 'envir' argument to load()?  E.g.,
envA - new.environment()
load(A.RData, envir=envA)
envB - new.environment()
load(B.RData, envir=envB)
plot(A$object, B$object)



Bill Dunlap
TIBCO Software
wdunlap tibco.com


An alternative that I have been advocating is using

   attach(A.RData)

etc. It does something similar as the above, but more
conveniently:
It loads the objects into a new environment  *and* attaches that
environment to your search()  path, so you can access them
directly, but attach() will never accidentally destroy existing
R objects in your global environment ( = search()[[1]] ).

Martin



Thanks a lot.

I try your method, and I got:

 attach(D2.1.RData)
The following objects are masked _by_ .GlobalEnv:

coda.jags.1, df.1, jags.1, Mean, N

In this case, how to access the masked objects?

Best,
Jinsong







On Mon, Aug 18, 2014 at 5:30 PM, Jinsong Zhao jsz...@yeah.net wrote:
Hi there,

I have several saved data files (e.g., A.RData, B.RData and C.RData). In
each file, there are some objects with same names but different contents.
Now, I need to compare those objects through plotting. However, I can't find
a way to load them into a workspace. The only thing I can do is to rename
them and then save and load again.

Is there a convenient to load those objects?

Thanks a lot in advance.

Best regards,
Jinsong



__
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] filled.contour key axis

2014-08-22 Thread Lietz, Haiko
Hi Jim, all,

Thx, I was hoping for percentage scores, such that R puts numbers with % 
there.

And by automatically labeling I meant giving the axis a title, sorry for 
mixing that up.

I havn't found an option in the parameters for filled.contour.

Haiko



Von: Jim Lemon [j...@bitwrit.com.au]
Gesendet: Montag, 18. August 2014 14:41
An: r-help@r-project.org
Cc: Lietz, Haiko
Betreff: Re: [R] filled.contour key axis

On Mon, 18 Aug 2014 08:51:57 AM Lietz, Haiko wrote:
 Hi all,

 Using filled.contour...

 foo - matrix(seq(0.1, 0.9, 0.1), ncol = 3)
 filled.contour(foo)

 how can I set the key axis to give percentages?

 And is there a way to automatically label the key axis except for
placing
 text there?

 Thanks

 Haiko

Hi Haiko,
Try this:

filled.contour(foo,
 plot.axes={axis(1);
 axis(2,at=seq(0,1,by=0.2),labels=seq(0,100,by=20))},
 key.axes=
 {axis(4,at=seq(0,1,by=0.2),labels=seq(0,100,by=20))})

Jim


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


Re: [R] no visible binding for global variable and with() vs. within()

2014-08-22 Thread Henrik Bengtsson
I'm dealing with these type of false NOTEs as:

foo1 - function (bar) {
   # To please R CMD check
   x - NULL; rm(list=x)

   with(bar, {
 x })
}

Of course, that may one day break with more clever code inspections.

My $.02

/Henrik

On Fri, Aug 22, 2014 at 2:40 AM, Martin Maechler
maech...@stat.math.ethz.ch wrote:
 Rolf Turner r.tur...@auckland.ac.nz
 on Mon, 18 Aug 2014 08:47:36 +1200 writes:

  On 17/08/14 23:05, Duncan Murdoch wrote:
  On 16/08/2014, 9:36 PM, Daniel Braithwaite wrote:
  R CMD check does not object to this code when checking a
  package:
 
  foo1 - function (bar) { with(bar, { x }) }
 
  but produces a warning:
 
  foo2: no visible binding for global variable 'x'
 
  in response to this:
 
  foo2 - function (bar) { within(bar, { x }) }
 
  Is this an R bug, or at least, an inadvertent
  inconsistency?  Here is sessionInfo() from my machine,
  right after starting an interactive session:
 
  I'm not sure, but I suspect it's an intentional
  inconsistency.  The code that checks for use of globals
  can't do anything in with() or within() code, so bugs can
  slip by if you use those.  I think with() had been around
  for a long time and was in wide use when that test was
  added, but within() is newer, and it was less disruptive
  to warn about it, so the warning has been left in.  (I
  don't remember whether the test came before or after
  within() was introduced.)
 
  So if you want to avoid the warning, don't use within().

  Or you could have a file, say melvin.R, in the R
  directory of your package, containing the line:

utils::globalVariables(x)

 Yes,  but that would be a quite bad idea, IMHO:

 The checking code {from package 'codetools' BTW}
 would no longer warn you about any accidental global 'x'
 variable in any of your functions in your package.

 After all, these codetools checks *are* very helpful in
 detecting typos and thinkos.
 Consequently, I'd strongly advise to only use
 globalVariables(.) on *rare* variable names.

 Martin Maechler,
 ETH Zurich

 __
 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] filled.contour key axis

2014-08-22 Thread Jeff Newmiller
You seem to be thinking of Excel. R does not dress up numbers for you... if you 
want them represented in a particular way, you need to format them into a 
character string. There are plenty of options for doing that.
---
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 August 22, 2014 10:36:23 AM PDT, Lietz, Haiko haiko.li...@gesis.org 
wrote:
Hi Jim, all,

Thx, I was hoping for percentage scores, such that R puts numbers with
% there.

And by automatically labeling I meant giving the axis a title, sorry
for mixing that up.

I havn't found an option in the parameters for filled.contour.

Haiko



Von: Jim Lemon [j...@bitwrit.com.au]
Gesendet: Montag, 18. August 2014 14:41
An: r-help@r-project.org
Cc: Lietz, Haiko
Betreff: Re: [R] filled.contour key axis

On Mon, 18 Aug 2014 08:51:57 AM Lietz, Haiko wrote:
 Hi all,

 Using filled.contour...

 foo - matrix(seq(0.1, 0.9, 0.1), ncol = 3)
 filled.contour(foo)

 how can I set the key axis to give percentages?

 And is there a way to automatically label the key axis except for
placing
 text there?

 Thanks

 Haiko

Hi Haiko,
Try this:

filled.contour(foo,
 plot.axes={axis(1);
 axis(2,at=seq(0,1,by=0.2),labels=seq(0,100,by=20))},
 key.axes=
 {axis(4,at=seq(0,1,by=0.2),labels=seq(0,100,by=20))})

Jim


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

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


Re: [R] Subsetting data for split-sample validation, then repeating 1000x

2014-08-22 Thread David L Carlson
You can use replicate() or a for (i in 1:1000){} loop to do your replications, 
but you have other issues first. 

1. You are sampling with replacement which makes no sense at all. Your 70% 
sample will contain some observations multiple times and will use less than 70% 
of the data most of the time.

2. You compute r using cor() and r.squared using summary.lm(). Why? Once you 
have computed r, r*r or r^2 is equal to r.squared for the simple linear model 
you are using.

# To split your data, you need to sample without replacement, e.g.

train - sample.int(nrow(A), floor(nrow(A)*.7))
test - (1:nrow(A))[-train]

# Now run your analysis on A[train,] and test it on A[test,] 

# Fit model (I'm modeling native plant richness, 'nat.r')
A.model - glmmadmb(nat.r ~ isl.sz + nr.mead, random = ~ 1 | site, family =
poisson, data = A[train,])

# Correlation between predicted 30% and actual 30%
cor - cor(Atest$nat.r, predict(A.model, newdata = A[test,], type = response))


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

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Angela Boag
Sent: Thursday, August 21, 2014 4:46 PM
To: r-help@r-project.org
Subject: [R] Subsetting data for split-sample validation, then repeating 1000x

Hi all,

I'm doing some within-dataset model validation and would like to subset a
dataset 70/30 and fit a model to 70% of the data (the training data), then
validate it by predicting the remaining 30% (the testing data), and I would
like to do this split-sample validation 1000 times and average the
correlation coefficient and r2 between the training and testing data.

I have the following working for a single iteration, and would like to know
how to use either the replicate() or for-loop functions to average the 1000
'r2' and 'cor' outputs.

--

# create 70% training sample
A.samp - sample(1:nrow(A),floor(0.7*nrow(A)), replace = TRUE)

# Fit model (I'm modeling native plant richness, 'nat.r')
A.model - glmmadmb(nat.r ~ isl.sz + nr.mead, random = ~ 1 | site, family =
poisson, data = A[A.samp,])

# Use the model to predict the remaining 30% of the data
A.pred - predict(A.model, newdata = A[-A.samp,], type = response)

# Correlation between predicted 30% and actual 30%
cor - cor(A[-A.samp,]$nat.r, A.pred, method = pearson)

# r2 between predicted and observed
lm.A - lm(A.pred ~ A[-A.samp,]$nat.r)
r2 - summary(lm.A)$r.squared

# print values
r2
cor

--

Thanks for your time!

Cheers,
Angela

--
Angela E. Boag
Ph.D. Student, Environmental Studies
CAFOR Project Researcher
University of Colorado, Boulder
Mobile: 720-212-6505

[[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] Subsetting data for split-sample validation, then repeating 1000x

2014-08-22 Thread David L Carlson
Combine your code into a function:

Plant - function() {
train - sample.int(nrow(A), floor(nrow(A)*.7))
test - (1:nrow(A))[-train]
A.model - glmmadmb(nat.r ~ isl.sz + nr.mead, random = ~ 1 | site, family =
poisson, data = A[train,])
cor(Atest$nat.r, predict(A.model, newdata = A[test,], type = response))
}

Test the function. It should return a single correlation and no errors or 
warnings.

Plant()

If not, debug and run it again. When it works:

Out - replicate(1000, Plant())

Out should be a vector with 1000 correlation values.
hist(Out) # for a histogram of the correlation values

David C


From: Angela Boag [mailto:angela.b...@colorado.edu] 
Sent: Friday, August 22, 2014 4:01 PM
To: David L Carlson
Subject: Re: [R] Subsetting data for split-sample validation, then repeating 
1000x

Hi David,
Thanks for the feedback. I actually sampled without replacement initially but 
it's been a while since I looked at this code and just changed it because I 
thought it made more sense logically, but you've reassured me that my original 
hunch was right.
The real issue I'm having is how to use either the replicate() or for(i in 
1:1000){} loop code to get the average r value of 1000 repetitions as my 
output. I'm not familiar with either tool, so any suggestions on what that code 
would look like would be very helpful.

Thanks!
Angela 


--
Angela E. Boag
Ph.D. Student, Environmental Studies
CAFOR Project Researcher
University of Colorado, Boulder
Mobile: 720-212-6505


On Fri, Aug 22, 2014 at 2:46 PM, David L Carlson dcarl...@tamu.edu wrote:
You can use replicate() or a for (i in 1:1000){} loop to do your replications, 
but you have other issues first.

1. You are sampling with replacement which makes no sense at all. Your 70% 
sample will contain some observations multiple times and will use less than 70% 
of the data most of the time.

2. You compute r using cor() and r.squared using summary.lm(). Why? Once you 
have computed r, r*r or r^2 is equal to r.squared for the simple linear model 
you are using.

# To split your data, you need to sample without replacement, e.g.

train - sample.int(nrow(A), floor(nrow(A)*.7))
test - (1:nrow(A))[-train]

# Now run your analysis on A[train,] and test it on A[test,]

# Fit model (I'm modeling native plant richness, 'nat.r')
A.model - glmmadmb(nat.r ~ isl.sz + nr.mead, random = ~ 1 | site, family =
poisson, data = A[train,])

# Correlation between predicted 30% and actual 30%
cor - cor(Atest$nat.r, predict(A.model, newdata = A[test,], type = response))


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

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Angela Boag
Sent: Thursday, August 21, 2014 4:46 PM
To: r-help@r-project.org
Subject: [R] Subsetting data for split-sample validation, then repeating 1000x

Hi all,

I'm doing some within-dataset model validation and would like to subset a
dataset 70/30 and fit a model to 70% of the data (the training data), then
validate it by predicting the remaining 30% (the testing data), and I would
like to do this split-sample validation 1000 times and average the
correlation coefficient and r2 between the training and testing data.

I have the following working for a single iteration, and would like to know
how to use either the replicate() or for-loop functions to average the 1000
'r2' and 'cor' outputs.

--

# create 70% training sample
A.samp - sample(1:nrow(A),floor(0.7*nrow(A)), replace = TRUE)

# Fit model (I'm modeling native plant richness, 'nat.r')
A.model - glmmadmb(nat.r ~ isl.sz + nr.mead, random = ~ 1 | site, family =
poisson, data = A[A.samp,])

# Use the model to predict the remaining 30% of the data
A.pred - predict(A.model, newdata = A[-A.samp,], type = response)

# Correlation between predicted 30% and actual 30%
cor - cor(A[-A.samp,]$nat.r, A.pred, method = pearson)

# r2 between predicted and observed
lm.A - lm(A.pred ~ A[-A.samp,]$nat.r)
r2 - summary(lm.A)$r.squared

# print values
r2
cor

--

Thanks for your time!

Cheers,
Angela

--
Angela E. Boag
Ph.D. Student, Environmental Studies
CAFOR Project Researcher
University of Colorado, Boulder
Mobile: 720-212-6505
        [[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] loading saved files with objects in same names

2014-08-22 Thread Duncan Murdoch
On 22/08/2014, 1:14 PM, Jinsong Zhao wrote:
 On 2014/8/22 1:02, Martin Maechler wrote:

 Have you tried the 'envir' argument to load()?  E.g.,
 envA - new.environment()
 load(A.RData, envir=envA)
 envB - new.environment()
 load(B.RData, envir=envB)
 plot(A$object, B$object)

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

 An alternative that I have been advocating is using

attach(A.RData)

 etc. It does something similar as the above, but more
 conveniently:
 It loads the objects into a new environment  *and* attaches that
 environment to your search()  path, so you can access them
 directly, but attach() will never accidentally destroy existing
 R objects in your global environment ( = search()[[1]] ).

 Martin

 
 Thanks a lot.
 
 I try your method, and I got:
 
   attach(D2.1.RData)
 The following objects are masked _by_ .GlobalEnv:
 
  coda.jags.1, df.1, jags.1, Mean, N
 
 In this case, how to access the masked objects?

Don't ever use attach(), and this won't be a problem.  Martin gave you
bad advice.

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] BNF description for R

2014-08-22 Thread kevin2059
Thank you,that help a lot.
At 2014-08-17 19:09:00,Duncan Murdoch murdoch.dun...@gmail.com wrote:
On 16/08/2014, 7:32 PM, kevin2059 wrote:
 HOW can I get a completely BNF description for R? I try to  write a parser 
 for R now.

The R grammar is defined in the src/main/gram.y file (in Bison format).
 You can get that file from
https://svn.r-project.org/R/trunk/src/main/gram.y.

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] filled.contour key axis

2014-08-22 Thread Jim Lemon
On Fri, 22 Aug 2014 05:36:23 PM Lietz, Haiko wrote:
 Hi Jim, all,
 
 Thx, I was hoping for percentage scores, such that R puts numbers 
with %
 there.
 
 And by automatically labeling I meant giving the axis a title, sorry for
 mixing that up.
 
 I havn't found an option in the parameters for filled.contour.
 
 Haiko
 
Hi Haiko,
I think what Jeff meant was:
 
filled.contour(foo,
 plot.axes={axis(1);
 axis(2,at=seq(0,1,by=0.2),
  labels=paste(seq(0,100,by=20),%))},
 key.axes=
 {axis(4,at=seq(0,1,by=0.2),
  labels=paste(seq(0,100,by=20),%))})

Even Excel can't read your mind, although it sometimes thinks it can.

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.