Re: [R] double-axis labels function of each other

2015-04-03 Thread Hurr
Yes, I keep a copy in MS Word. 
Would Notepad be OK?
I need sleep now, will work tomorrow.




--
View this message in context: 
http://r.789695.n4.nabble.com/double-axis-labels-function-of-each-other-tp4705457p4705463.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] RInside

2015-04-03 Thread Michel
help

Hello
I'm newbee with R and RInside
My question is about stderr in R. Is there a way to collect R stderr in C++
program embedding R Thanks in advance

Michel


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.

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

[R] Package build system adds line break in DESCRIPTION URL

2015-04-03 Thread Daniel Lewandowski
Has anybody noticed that if field URL in DESCRIPTION contains a uri with 
66 or more characters, then file DESCRIPTION in the resulting package 
includes a line break at the beginning?


So this (source DESCRIPTION):

URL: 
http://ecdc.europa.eu/en/data-tools/seroincidence-calculator-tool/Pages/default.aspx


becomes (again file DESCRIPTION, but inside the package)

URL:
http://ecdc.europa.eu/en/data-tools/seroincidence-calculator-tool/Pages/default.aspx

This has been tested with R on Windows 8.1 (devel 01/04/2015 and 3.1.3) 
and Linux Mint (3.1.3). It has many sad implications including not 
acceptance of such packages to CRAN.


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


[R] applying cumsum within groups

2015-04-03 Thread Morway, Eric
This small example will be applied to a problem with 1.4e6 lines of data.
First, here is the dataset and a few lines of R script, followed by an
explanation of what I'd like to get:

dat - read.table(textConnection(ISEG  IRCH  val
 11   265
 12   260
 13   234
54   39   467
54   40   468
54   41   460
54   42   489
 11   265
 12   276
 13   217
54   39   456
54   40   507
54   41   483
54   42   457
 11   265
 12   287
 13   224
54   39   473
54   40   502
54   41   497
54   42   447
 11   230
 12   251
 13   199
54   39   439
54   40   474
54   41   477
54   42   413
 11   230
 12   262
 13   217
54   39   455
54   40   493
54   41   489
54   42   431
 11   1002
 12   1222
 13   1198
54   39   1876
54   40   1565
54   41   1455
54   42   1427
 11   1002
 12   1246
 13   1153
54   39   1813
54   40   1490
54   41   1518
54   42   1486
 11   1002
 12   1229
 13   1142
54   39   1797
54   40   1517
54   41   1527
54   42   1514),header=TRUE)

dat$seq - ifelse(dat$ISEG==1  dat$IRCH==1, 1, 0)
tmp - diff(dat[dat$seq==1,]$val)!=0
dat$idx - 0
dat[dat$seq==1,][c(TRUE,tmp),]$idx - 1
dat$ts - cumsum(dat$idx)

At this point, I'd like to add one more column called iter that counts up
by 1 based on seq, but within each ts.  So, the result would look like
this (undoubtedly this is a simple problem with something like ddply, but
I've been unable to construct the R for it):

dat
 ISEG IRCH  val seq idx ts iter
11  265   1   1  11
12  260   0   0  11
13  234   0   0  11
   54   39  467   0   0  11
   54   40  468   0   0  11
   54   41  460   0   0  11
   54   42  489   0   0  11
11  265   1   0  12
12  276   0   0  12
13  217   0   0  12
   54   39  456   0   0  12
   54   40  507   0   0  12
   54   41  483   0   0  12
   54   42  457   0   0  12
11  265   1   0  13
12  287   0   0  13
13  224   0   0  13
   54   39  473   0   0  13
   54   40  502   0   0  13
   54   41  497   0   0  13
   54   42  447   0   0  13
11  230   1   1  21
12  251   0   0  21
13  199   0   0  21
   54   39  439   0   0  21
   54   40  474   0   0  21
   54   41  477   0   0  21
   54   42  413   0   0  21
11  230   1   0  22
12  262   0   0  22
13  217   0   0  22
   54   39  455   0   0  22
   54   40  493   0   0  22
   54   41  489   0   0  22
   54   42  431   0   0  22
11 1002   1   1  31
12 1222   0   0  31
13 1198   0   0  31
   54   39 1876   0   0  31
   54   40 1565   0   0  31
   54   41 1455   0   0  31
   54   42 1427   0   0  31
11 1002   1   0  32
12 1246   0   0  32
13 1153   0   0  32
   54   39 1813   0   0  32
   54   40 1490   0   0  32
   54   41 1518   0   0  32
   54   42 1486   0   0  32
11 1002   1   0  33
12 1229   0   0  33
13 1142   0   0  33
   54   39 1797   0   0  33
   54   40 1517   0   0  33
   54   41 1527   0   0  33
   54   42 1514   0   0  33

[[alternative HTML version deleted]]

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


Re: [R] idiom for constructing data frame

2015-04-03 Thread peter dalgaard

 On 31 Mar 2015, at 20:55 , William Dunlap wdun...@tibco.com wrote:
 
 You can use structure() to attach the names to a list that is input to
 data.frame.
 E.g.,
 
 dfNames - c(First, Second Name)
 data.frame(lapply(structure(dfNames, names=dfNames),
 function(name)rep(NA_real_, 5)))
 

Yes, I cooked up something similar:

names - c(foo,bar,baz)
names(names) - names # confuse 'em
as.data.frame(lapply(names, function(x) rep(NA_real_,10)))

but wouldn't it be more to the point to do

df - as.data.frame(rep(list(rep(NA_real_, 10)),3))
names(df) - names

?

The lapply() approach could be generalized to a vector of column classes, 
though. 

A general solution looks impracticable; once you start considering how to 
specify factor columns with each their own level set, things get a bit out of 
hand. 

-pd

 
 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com
 
 On Tue, Mar 31, 2015 at 11:37 AM, Sarah Goslee sarah.gos...@gmail.com
 wrote:
 
 Hi,
 
 Duncan Murdoch suggested:
 
 The matrix() function has a dimnames argument, so you could do this:
 
 names - c(strat, id, pid)
 data.frame(matrix(NA, nrow=10, ncol=3, dimnames=list(NULL, names)))
 
 That's a definite improvement, thanks. But no way to skip matrix()? It
 just seems unRlike, although since it's only full of NA values there
 are no coercion issues with column types or anything, so it doesn't
 hurt. It's just inelegant. :)
 
 Sarah
 --
 Sarah Goslee
 http://www.functionaldiversity.org
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] idiom for constructing data frame

2015-04-03 Thread William Dunlap
 but wouldn't it be more to the point to do

 df - as.data.frame(rep(list(rep(NA_real_, 10)),3))
 names(df) - names

As a matter of personal style (and functional programming
sensibility), I prefer not to make named objects and then modify them.
Also, the names coming out of that as.data.frame call are exceedingly
ugly and I'd rather not generate them at all.

Also adding the names after calling data.frame means can give
different results than passing them into data.frame(), which can
mangle nonsyntactic names like Second Name into Second.Name.
It is often preferable, but it is different.



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Apr 3, 2015 at 5:51 AM, peter dalgaard pda...@gmail.com wrote:


  On 31 Mar 2015, at 20:55 , William Dunlap wdun...@tibco.com wrote:
 
  You can use structure() to attach the names to a list that is input to
  data.frame.
  E.g.,
 
  dfNames - c(First, Second Name)
  data.frame(lapply(structure(dfNames, names=dfNames),
  function(name)rep(NA_real_, 5)))
 

 Yes, I cooked up something similar:

 names - c(foo,bar,baz)
 names(names) - names # confuse 'em
 as.data.frame(lapply(names, function(x) rep(NA_real_,10)))

 but wouldn't it be more to the point to do

 df - as.data.frame(rep(list(rep(NA_real_, 10)),3))
 names(df) - names

 ?

 The lapply() approach could be generalized to a vector of column classes,
 though.

 A general solution looks impracticable; once you start considering how to
 specify factor columns with each their own level set, things get a bit out
 of hand.

 -pd

 
  Bill Dunlap
  TIBCO Software
  wdunlap tibco.com
 
  On Tue, Mar 31, 2015 at 11:37 AM, Sarah Goslee sarah.gos...@gmail.com
  wrote:
 
  Hi,
 
  Duncan Murdoch suggested:
 
  The matrix() function has a dimnames argument, so you could do this:
 
  names - c(strat, id, pid)
  data.frame(matrix(NA, nrow=10, ncol=3, dimnames=list(NULL, names)))
 
  That's a definite improvement, thanks. But no way to skip matrix()? It
  just seems unRlike, although since it's only full of NA values there
  are no coercion issues with column types or anything, so it doesn't
  hurt. It's just inelegant. :)
 
  Sarah
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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










[[alternative HTML version deleted]]

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


Re: [R] applying cumsum within groups

2015-04-03 Thread peter dalgaard
ave() is your friend (unfortunately named as it may be):

 ave(dat$seq, dat$ts, FUN=cumsum)
 [1] 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 1 1 1 1 1 1 1 2 2 2 2 2 2 2 1 1 1
[39] 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3


 On 03 Apr 2015, at 14:17 , Morway, Eric emor...@usgs.gov wrote:
 
 This small example will be applied to a problem with 1.4e6 lines of data.
 First, here is the dataset and a few lines of R script, followed by an
 explanation of what I'd like to get:
 
 dat - read.table(textConnection(ISEG  IRCH  val
 11   265
 12   260
 13   234
 54   39   467
 54   40   468
 54   41   460
 54   42   489
 11   265
 12   276
 13   217
 54   39   456
 54   40   507
 54   41   483
 54   42   457
 11   265
 12   287
 13   224
 54   39   473
 54   40   502
 54   41   497
 54   42   447
 11   230
 12   251
 13   199
 54   39   439
 54   40   474
 54   41   477
 54   42   413
 11   230
 12   262
 13   217
 54   39   455
 54   40   493
 54   41   489
 54   42   431
 11   1002
 12   1222
 13   1198
 54   39   1876
 54   40   1565
 54   41   1455
 54   42   1427
 11   1002
 12   1246
 13   1153
 54   39   1813
 54   40   1490
 54   41   1518
 54   42   1486
 11   1002
 12   1229
 13   1142
 54   39   1797
 54   40   1517
 54   41   1527
 54   42   1514),header=TRUE)
 
 dat$seq - ifelse(dat$ISEG==1  dat$IRCH==1, 1, 0)
 tmp - diff(dat[dat$seq==1,]$val)!=0
 dat$idx - 0
 dat[dat$seq==1,][c(TRUE,tmp),]$idx - 1
 dat$ts - cumsum(dat$idx)
 
 At this point, I'd like to add one more column called iter that counts up
 by 1 based on seq, but within each ts.  So, the result would look like
 this (undoubtedly this is a simple problem with something like ddply, but
 I've been unable to construct the R for it):
 
 dat
 ISEG IRCH  val seq idx ts iter
11  265   1   1  11
12  260   0   0  11
13  234   0   0  11
   54   39  467   0   0  11
   54   40  468   0   0  11
   54   41  460   0   0  11
   54   42  489   0   0  11
11  265   1   0  12
12  276   0   0  12
13  217   0   0  12
   54   39  456   0   0  12
   54   40  507   0   0  12
   54   41  483   0   0  12
   54   42  457   0   0  12
11  265   1   0  13
12  287   0   0  13
13  224   0   0  13
   54   39  473   0   0  13
   54   40  502   0   0  13
   54   41  497   0   0  13
   54   42  447   0   0  13
11  230   1   1  21
12  251   0   0  21
13  199   0   0  21
   54   39  439   0   0  21
   54   40  474   0   0  21
   54   41  477   0   0  21
   54   42  413   0   0  21
11  230   1   0  22
12  262   0   0  22
13  217   0   0  22
   54   39  455   0   0  22
   54   40  493   0   0  22
   54   41  489   0   0  22
   54   42  431   0   0  22
11 1002   1   1  31
12 1222   0   0  31
13 1198   0   0  31
   54   39 1876   0   0  31
   54   40 1565   0   0  31
   54   41 1455   0   0  31
   54   42 1427   0   0  31
11 1002   1   0  32
12 1246   0   0  32
13 1153   0   0  32
   54   39 1813   0   0  32
   54   40 1490   0   0  32
   54   41 1518   0   0  32
   54   42 1486   0   0  32
11 1002   1   0  33
12 1229   0   0  33
13 1142   0   0  33
   54   39 1797   0   0  33
   54   40 1517   0   0  33
   54   41 1527   0   0  33
   54   42 1514   0   0  33
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Color US counties on US map using a numeric variable for color intensity

2015-04-03 Thread Adams, Jean
Dimitri,

To answer your questions:
The colorRamp() function creates a new function, newpal().
The value returned by newpal() is a numeric matrix of RGB color values.
The rgb() function is then used to convert this numeric matrix to colors,
with the argument maxColorValue
giving the maximum of the color values range.  Typically either 255 or 1.
See the help files for more information

?colorRamp
?rgb


I think Jim Lemon's suggestion to use color.scale() function is a handier
solution.

Jean

On Thu, Apr 2, 2015 at 6:05 PM, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:

 This is really cool, Jim - thanks a lot!

 On Thu, Apr 2, 2015 at 6:18 PM, Jim Lemon drjimle...@gmail.com wrote:
  Hi Dimitri,
  You can also try the color.scale function in plotrix, which allows you to
  specify the NA color in the call.
 
 
 newcol-color.scale(mydata.final$Mean.Wait,extremes=c(yellow,red),na.color=white)
 
  Jim
 
 
  On Fri, Apr 3, 2015 at 8:08 AM, Dimitri Liakhovitski
  dimitri.liakhovit...@gmail.com wrote:
 
  Jean, I think I fixed it:
 
  newpal - colorRamp(c(yellow, red))
  missing - is.na(mydata.final$Mean.Wait)
  newcol - ifelse(missing, white,
 
  rgb(newpal(mydata.final$Mean.Wait[!is.na(mydata.final$Mean.Wait)]/
max(mydata.final$Mean.Wait,
  na.rm=T)), maxColorValue=255))
  map('county', fill=TRUE, col=newcol,
  resolution=0, lty=0, bg=transparent)
  map('state', lwd=1, add=TRUE)
 
  One understanding question: what exactly does this rgb line do and why
  do we have to say maxColorValue=255?
  Thank you!
 
  On Thu, Apr 2, 2015 at 5:02 PM, Dimitri Liakhovitski
  dimitri.liakhovit...@gmail.com wrote:
   Thank you, Jean, but I think this newcol line is not working. I am
   running:
  
   newcol - ifelse(missing, white,
  
   rgb(newpal(mydata.final$Mean.Wait/max(mydata.final$Mean.Wait,
   na.rm=T)),
maxColorValue=255))
  
   # And I am getting:
   Error in rgb(newpal(mydata.final$Mean.Wait/max(mydata.final$Mean.Wait,
   :
 color intensity NA, not in 0:255
  
   I think it's not liking the NAs - despite the ifelse...
  
   On Thu, Apr 2, 2015 at 4:26 PM, Adams, Jean jvad...@usgs.gov wrote:
   Dimitri,
  
   You could use colorRamp() and rgb() to get more continuous colors.
   For example
  
   newpal - colorRamp(c(yellow, red))
   missing - is.na(mydata.final$Mean.Wait)
   newcol - ifelse(missing, white,
 rgb(newpal(mydat$Mean.Wait/max(mydat$Mean.Wait)),
 maxColorValue=255))
   map('county', fill=TRUE, col=newcol,
   resolution=0, lty=0, bg=transparent)
   map('state', lwd=1, add=TRUE)
  
   Jean
  
  
   On Thu, Apr 2, 2015 at 12:03 PM, Dimitri Liakhovitski
   dimitri.liakhovit...@gmail.com wrote:
  
   I have a data frame 'mydata.final' (see below) that contains US
   counties and a continuous numeric variable 'Mean.Wait' that ranges
   from zero to 10 or so. I also created variable 'wait' that is based
 on
   the 'Mean.Wait' and takes on discrete values from 1 (lowest values
 on
   'Mean.Wait') to 5 (highest values on 'Mean.Wait').
  
   I can create a map of the US with the counties colored based on the
   values of 'wait' using R package 'maps':
  
   #
   ### Generating an artificial data file:
   #
   library(maps)
   mydata.final - data.frame(county = (map('county', plot =
   FALSE)$names),
stringsAsFactors = F)
  
   ### My numeric variable:
   set.seed(123)
   mydata.final$Mean.Wait - runif(nrow(mydata.final)) * 10
  
   ### Introducing NAs to mimic my real data set:
   set.seed(1234)
   mydata.final$Mean.Wait[sample(1:nrow(mydata.final), 1500)] - NA
  
   ### Cutting the original numeric variable into categories
   ### because I don't know how to color based on 'Mean.Wait':
   mydata.final$wait - cut(mydata.final$Mean.Wait, breaks = 5)
   levels(mydata.final$wait) - 1:5
   mydata.final$wait - as.numeric(as.character(mydata.final$wait))
  
   
   Building a US map based on 'wait' (5 categories)
   #
  
   ### Creating my 5 colors:
   pal - colorRampPalette(c(yellow, red))
   allcolors - pal(5)
  
   ### Looking at my 5 colors:
   barplot(1:5, rep(1,5), col = allcolors, horiz = T)
  
   ### Builiding the US map using 5 categories in 'wait':
   map('county', fill = TRUE, col = allcolors[mydata.final$wait],
   resolution = 0, lty = 0, bg = transparent)
   map('state', lwd=1, add=TRUE)
  
   My goal is: instead of splitting 'Mean.Wait' into 5 ordered
 categories
   ('wait'), I'd like to color the counties on the map based on the
   intensity of my (continuous) 'Mean.Wait'. What would be the way to
 do
   it and maybe even to add a legend?
   Thanks a lot!
  
   --
   Dimitri Liakhovitski
  
   

[R] question on waveletcomp plot image

2015-04-03 Thread Sudheer Joseph
Dear R experts,
 I have used waveletcomp package of R  and was
trying to get the dates formatted as month  year but get below error while
trying it with the example provided  in
http://www.hs-stat.com/projects/WaveletComp/WaveletComp_guided_tour.pdf
Kindly help me with the dateformat so that I can get %Y-%m as xaxis label
data(FXtrade.transactions)
my.data.a = FXtrade.transactions[FXtrade.transactions$active == T, ]
my.w.a = analyze.wavelet(
+ my.data.a, transactions,
+ loess.span = 0.0, # no detrending required
+ dt = 1/(12*24),
+ # one day has 12*24 5-minute time slots
+ dj = 1/250,
+ # resolution along period axis
+ lowerPeriod = 1/8, # lowest period of interest: 3 hours
+ make.pval = T,
+ # draws white lines indicating significance
+ n.sim = 10)


wt.image(my.w.a, n.levels = 250, periodlab = periods (days),
+  legend.params = list(lab = wavelet power levels),
+  show.date = T, date.format = %Y %m, timelab = )
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -In
with best regards

Sudheer

**
Dr. Sudheer Joseph

Scientist,

INCOIS, MoES, Govt. of India.
OCEAN VALLEY , Pragathi Nagar (BO), Nizampet SO,  Telangana, India. PIN-
500 090.
Tel:+91-9440832534(Mobile) Tel:+91-40-23886047(O),Fax:+91-40-23892910(O)
E-mail: sjo.in...@gmail.com;  s...@incois.gov.in.
---* 
The ultimate measure of a man is not where he stands in moments of
comfort and convenience, but where he stands at times of challenge and
controversy.
Martin Luther King, Jr.
***

[[alternative HTML version deleted]]

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


[R] Cut breaks in descending order

2015-04-03 Thread Wing Keong Lew
Hi,

Is it a requirement to provide the break intervals of the cut function in 
ascending order? The help documentation for cut didn't specify this but the 
labels returned are reversed if I indicate the break intervals in a descending 
order. Here is an example

tbl-data.frame(x=c(0:10))
tbl$ascending-cut(tbl$x, breaks=c(0,3,5,9,99), 
labels=c('3','4-5','6-9','9'), include.lowest=T)
tbl$descending-cut(tbl$x, breaks=c(99,9,5,3,0), 
labels=c('9','6-8','4-5','3'), include.lowest=T)
tbl
    x ascending descending
1   0        3        9
2   1        3        9
3   2        3        9
4   3        3        9
5   4       4-5       6-8
6   5       4-5       6-8
7   6       6-9       4-5
8   7       6-9       4-5
9   8       6-9       4-5
10  9       6-9       4-5
11 10        9        3

Appreciate any guidance on this.
Regards
Wing Keong

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


Re: [R] applying cumsum within groups

2015-04-03 Thread David Winsemius

On Apr 3, 2015, at 5:17 AM, Morway, Eric wrote:

 This small example will be applied to a problem with 1.4e6 lines of data.
 First, here is the dataset and a few lines of R script, followed by an
 explanation of what I'd like to get:
 
 dat - read.table(textConnection(ISEG  IRCH  val
 11   265
 12   260
 13   234
 54   39   467
 54   40   468
 54   41   460
 54   42   489
 11   265
 12   276
 13   217
 54   39   456
 54   40   507
 54   41   483
 54   42   457
 11   265
 12   287
 13   224
 54   39   473
 54   40   502
 54   41   497
 54   42   447
 11   230
 12   251
 13   199
 54   39   439
 54   40   474
 54   41   477
 54   42   413
 11   230
 12   262
 13   217
 54   39   455
 54   40   493
 54   41   489
 54   42   431
 11   1002
 12   1222
 13   1198
 54   39   1876
 54   40   1565
 54   41   1455
 54   42   1427
 11   1002
 12   1246
 13   1153
 54   39   1813
 54   40   1490
 54   41   1518
 54   42   1486
 11   1002
 12   1229
 13   1142
 54   39   1797
 54   40   1517
 54   41   1527
 54   42   1514),header=TRUE)
 
 dat$seq - ifelse(dat$ISEG==1  dat$IRCH==1, 1, 0)
 tmp - diff(dat[dat$seq==1,]$val)!=0
 dat$idx - 0
 dat[dat$seq==1,][c(TRUE,tmp),]$idx - 1
 dat$ts - cumsum(dat$idx)
 
 At this point, I'd like to add one more column called iter that counts up
 by 1 based on seq, but within each ts.  So, the result would look like
 this (undoubtedly this is a simple problem with something like ddply, but
 I've been unable to construct the R for it):

 dat$iter2 - ave(dat$seq, dat$ts,FUN=cumsum)
 dat
   ISEG IRCH  val seq idx ts iter iter2
1 11  265   1   1  1  1_1 1
2 12  260   0   0  1  1_1 1
3 13  234   0   0  1  1_1 1
454   39  467   0   0  1  1_1 1
554   40  468   0   0  1  1_1 1
654   41  460   0   0  1  1_1 1
754   42  489   0   0  1  1_1 1
8 11  265   1   0  1  1_2 2
9 12  276   0   0  1  1_2 2
1013  217   0   0  1  1_2 2
11   54   39  456   0   0  1  1_2 2
12   54   40  507   0   0  1  1_2 2
13   54   41  483   0   0  1  1_2 2
14   54   42  457   0   0  1  1_2 2
1511  265   1   0  1  1_3 3
1612  287   0   0  1  1_3 3
1713  224   0   0  1  1_3 3
18   54   39  473   0   0  1  1_3 3
19   54   40  502   0   0  1  1_3 3
20   54   41  497   0   0  1  1_3 3
21   54   42  447   0   0  1  1_3 3
2211  230   1   1  2  2_4 1
2312  251   0   0  2  2_4 1
snipped-

-- 
David
 
 dat
 ISEG IRCH  val seq idx ts iter
11  265   1   1  11
12  260   0   0  11
13  234   0   0  11
   54   39  467   0   0  11
   54   40  468   0   0  11
   54   41  460   0   0  11
   54   42  489   0   0  11
11  265   1   0  12
12  276   0   0  12
13  217   0   0  12
   54   39  456   0   0  12
   54   40  507   0   0  12
   54   41  483   0   0  12
   54   42  457   0   0  12
11  265   1   0  13
12  287   0   0  13
13  224   0   0  13
   54   39  473   0   0  13
   54   40  502   0   0  13
   54   41  497   0   0  13
   54   42  447   0   0  13
11  230   1   1  21
12  251   0   0  21
13  199   0   0  21
   54   39  439   0   0  21
   54   40  474   0   0  21
   54   41  477   0   0  21
   54   42  413   0   0  21
11  230   1   0  22
12  262   0   0  22
13  217   0   0  22
   54   39  455   0   0  22
   54   40  493   0   0  22
   54   41  489   0   0  22
   54   42  431   0   0  22
11 1002   1   1  31
12 1222   0   0  31
13 1198   0   0  31
   54   39 1876   0   0  31
   54   40 1565   0   0  31
   54   41 1455   0   0  31
   54   42 1427   0   0  31
11 1002   1   0  32
12 1246   0   0  32
13 1153   0   0  32
   54   39 1813   0   0  32
   54   40 1490   0   0  32
   54   41 1518   0   0  32
   54   42 1486   0   0  32
11 1002   1   0  33
12 1229   0   0  33
13 1142   0   0  33
   54   39 1797   0   0  33
   54   40 1517   0   0  33
   54   41 1527   0   0  33
   54   42 1514   0   0  33
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do 

[R] open xlsx file using read.xls function of gdata package

2015-04-03 Thread Luigi Marongiu
Dear all,
I am trying to open excel files using the gdata package. I can do that
using a .xls file, but the same file, containing the same data,
formatted in .xlsx gives error (R does not recognize the pattern from
where to start reading the data).
Doen anybody knows whether it is possible to read .xlslx with this package?
Am I missing another package to implement the reading of the .xlsx?
Thank you
Luigi

PS: this is the error I get:
 my.file - array.xlsx
 my.data-read.xls(
+   my.file,
+   sheet=sheet x,
+   verbose=FALSE,
+   pattern=row name,
+   na.strings=c(NA,#DIV/0!),
+   method=tab,
+   perl=perl
+ )
 Warning message:
In read.xls(my.file, sheet = sheet x, verbose = FALSE,  :
  pattern not found


The verbose version runs like this:
“array.xlsx”
to tab  file
“/tmp/Rtmp2tAjzz/filef06102dd018.tab”
...

Executing ' '/usr/bin/perl'
'/home/gigiux/R/x86_64-pc-linux-gnu-library/3.0/gdata/perl/xls2tab.pl'
 'array.xlsx' '/tmp/Rtmp2tAjzz/filef06102dd018.tab' 'sheet x' '...

Loading 'array.xlsx'...
Done.

Orignal Filename: array.xlsx
Number of Sheets: 2

Writing sheet 'sheet x' to file '/tmp/Rtmp2tAjzz/filef06102dd018.tab'
Minrow=31 Maxrow=17310 Mincol=0 Maxcol=4
  (Ignored 0 blank lines.)

0

Done.

Searching for lines tfntaining pattern  row name ...
Warning message:
In read.xls(my.file, sheet = sheet x, verbose = TRUE,  :
  pattern not found


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

Re: [R] Cut breaks in descending order

2015-04-03 Thread David Winsemius

On Apr 3, 2015, at 5:09 AM, Wing Keong Lew wrote:

 Hi,
 
 Is it a requirement to provide the break intervals of the cut function in 
 ascending order?

Apparently not. I get teh sam splits even with random permutations. It is 
apparently a requirement to make sure you labels match the sorted order of 
the breaks.

The findInterval function does require that its `vec` argument be 
non-decreasing, but I do not see a discussion of break order in the help page. 
Looking at cut.default the first think it does to the breaks is sort them.

  #... snipped code that deals with length(breaks)==1
   else nb - length(breaks - sort.int(as.double(breaks)))

-- 
David.

 The help documentation for cut didn't specify this but the labels returned 
 are reversed if I indicate the break intervals in a descending order. Here is 
 an example
 
 tbl-data.frame(x=c(0:10))
 tbl$ascending-cut(tbl$x, breaks=c(0,3,5,9,99), 
 labels=c('3','4-5','6-9','9'), include.lowest=T)
 tbl$descending-cut(tbl$x, breaks=c(99,9,5,3,0), 
 labels=c('9','6-8','4-5','3'), include.lowest=T)
 tbl
 x ascending descending
 1   039
 2   139
 3   239
 4   339
 5   4   4-5   6-8
 6   5   4-5   6-8
 7   6   6-9   4-5
 8   7   6-9   4-5
 9   8   6-9   4-5
 10  9   6-9   4-5
 11 1093
 
 Appreciate any guidance on this.
 Regards
 Wing Keong
 
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] open xlsx file using read.xls function of gdata package

2015-04-03 Thread Jeff Newmiller
I had poor luck with gdata. I have had better luck with XLConnect. There is no 
single best package for this, since each seems to leverage efforts made in 
other languages (so there are non-R configuration requirements to keep working) 
and Excel is a proprietary moving target. In general YMMV when it comes to 
Excel data. In most cases I just export the data to CSV and avoid the issue.
---
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 3, 2015 11:24:29 AM PDT, Luigi Marongiu marongiu.lu...@gmail.com 
wrote:
Dear all,
I am trying to open excel files using the gdata package. I can do that
using a .xls file, but the same file, containing the same data,
formatted in .xlsx gives error (R does not recognize the pattern from
where to start reading the data).
Doen anybody knows whether it is possible to read .xlslx with this
package?
Am I missing another package to implement the reading of the .xlsx?
Thank you
Luigi

PS: this is the error I get:
 my.file - array.xlsx
 my.data-read.xls(
+   my.file,
+   sheet=sheet x,
+   verbose=FALSE,
+   pattern=row name,
+   na.strings=c(NA,#DIV/0!),
+   method=tab,
+   perl=perl
+ )
 Warning message:
In read.xls(my.file, sheet = sheet x, verbose = FALSE,  :
  pattern not found


The verbose version runs like this:
“array.xlsx”
to tab  file
“/tmp/Rtmp2tAjzz/filef06102dd018.tab”
...

Executing ' '/usr/bin/perl'
'/home/gigiux/R/x86_64-pc-linux-gnu-library/3.0/gdata/perl/xls2tab.pl'
 'array.xlsx' '/tmp/Rtmp2tAjzz/filef06102dd018.tab' 'sheet x' '...

Loading 'array.xlsx'...
Done.

Orignal Filename: array.xlsx
Number of Sheets: 2

Writing sheet 'sheet x' to file '/tmp/Rtmp2tAjzz/filef06102dd018.tab'
Minrow=31 Maxrow=17310 Mincol=0 Maxcol=4
  (Ignored 0 blank lines.)

0

Done.

Searching for lines tfntaining pattern  row name ...
Warning message:
In read.xls(my.file, sheet = sheet x, verbose = TRUE,  :
  pattern not found


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

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

Re: [R] Kruskal-Wallace power calculations.

2015-04-03 Thread Collin Lynch
Thank you very much Greg, I will give that a try.

Best,
Collin.

On Fri, Apr 3, 2015 at 1:43 PM, Greg Snow 538...@gmail.com wrote:
 Here is some sample code:

 ## Simulation function to create data, analyze it using
 ## kruskal.test, and return the p-value
 ## change rexp to change the simulation distribution

 simfun - function(means, k=length(means), n=rep(50,k)) {
   mydata - lapply( seq_len(k), function(i) {
 rexp(n[i], 1) - 1 + means[i]
   })
   kruskal.test(mydata)$p.value
 }

 # simulate under the null to check proper sizing
 B - 1
 out1 - replicate(B, simfun(rep(3,4)))
 hist(out1)
 mean( out1 = 0.05 )
 binom.test( sum(out1 = 0.05), B, p=0.05)

 ### Now simulate for power

 B - 1
 out2 - replicate(B, simfun( c(3,3,3.2,3.3)))
 hist(out2)
 mean( out2 = 0.05 )
 binom.test( sum(out2 = 0.05), B, p=0.05 )

 This simulates from a continuous exponential (skewed) and shifts to
 get the means (shifted location is a common assumption, though not
 required for the actual test).

 On Thu, Apr 2, 2015 at 8:19 PM, Collin Lynch cfly...@ncsu.edu wrote:
 Thank you Jim, I did see those (though not my typo :) and am still
 pondering the warning about post-hoc analyses.

 The situation that I am in is that I have a set of individuals who
 have been assigned a course grade.  We have then clustered these
 individuals into about 50 communities using standard community
 detection algorithms with the goal of determining whether community
 membership affects one of their grades.  We are using the KW test as
 the grade data is strongly non-normal and my coauthors preferred KW as
 an alternative.

 The two issues that I am struggling with are: 1) whether the post-hoc
 power analysis would be useful; and 2) how to code the simulation
 studies that are described in:
 http://onlinelibrary.wiley.com/doi/10.1002/bimj.4710380510/abstract


 Problem #1 is of course beyond the scope of this e-mail list though I
 would welcome anyone's suggestions on that point.  I am not sure that
 I buy the arguments against it offered here:

 http://graphpad.com/support/faq/why-it-is-not-helpful-to-compute-the-power-of-an-experiment-to-detect-the-difference-actually-observed-why-is-post-hoc-power-analysis-futile/

 It seems that the rationale boils down to you didn't find it so you
 couldn't find it but that does not tell me how far off I was from the
 goal.  I am still perusing the articles the author cites however.


 With respect to question #2 I am trying to lay my hands on the article
 and did find this old r-help discussion:
 http://r.789695.n4.nabble.com/Power-of-Kruskal-Wallis-Test-td4671188.html
 however I am not sure how to adapt the simulation studies that it
 links to to my current problem.  The links it leads to focus on
 mixed-effects models.  This may be more of a pure stats question and
 not suited for this list but I thought I'd ask in the hopes that
 anyone had any more specific KW code or knew of a good tutorial for
 the right kinds of simulation studies.

 Thank you,
 Collin.




 On Thu, Apr 2, 2015 at 6:35 PM, Jim Lemon drjimle...@gmail.com wrote:
 Hi Collin,
 Have a look at this:

 http://stats.stackexchange.com/questions/70643/power-analysis-for-kruskal-wallis-or-mann-whitney-u-test-using-r

 Although, thinking about it, this might have constituted your perusal of
 the literature.

 Plus it always looks better when you spell the names properly

 Jim


 On Fri, Apr 3, 2015 at 2:23 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us
 wrote:

 Please stop... you are acting like a broken record, and are also posting
 in HTML format. Please read the Posting Guide and demonstrate that you have
 used a search engine on this topic before posting again.

 ---
 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 2, 2015 7:25:20 AM PDT, Collin Lynch cfly...@ncsu.edu wrote:
 Greetings, I am working on a project where we are applying the
 Kruskal-Wallace test to some factor data to evaluate their correlation
 with
 existing grade data.  I know that the grade data is nonnormal therefore
 we
 cannot rely on ANOVA or a similar parametric test.  What I would like
 to
 find is a mechanism for making power calculations for the KW test given
 the
 nonparametric assumptions.  My perusal of the literature has suggested
 that
 a simulation would be the best method.
 
 Can anyone point me to good examples of such simulations for KW in R?
 And
 does anyone have a favourite package for generating simulated 

Re: [R] Repeated failures to install caret package (of Max Kuhn)

2015-04-03 Thread Sarah Goslee
Hi Ron,

Without knowing more it's really hard to help. What error messages are
you getting?
failed and no success are utterly uninformative - there are many
things that could be wrong.

The first thing, though, is always to check whether you have the
necessary dependencies installed, eg devel libraries.

Sarah

On Fri, Apr 3, 2015 at 5:07 PM, Ronald Wyllys wyl...@ischool.utexas.edu wrote:
 For an edx course, MIT's The Analtics Edge, I need to install the caret
 package that was originated and is maintained by Dr. Max Kuhn of Pfizer. So
 far, every effort I've made to try to install.packages(caret) has failed.
 (I'm using R v. 3.1.3 and RStudio v. 0.98.1103 in LinuxMint 17.1)

 Here are some of the things I've tried unsuccessfully:
 install.packages(caret, repos=c(http://rstudio.org/_packages;,
 http://cran.rstudio.com;))
 install.packages(caret, dependencies=TRUE)
 install.packages(caret, repos=c(http://rstudio.org/_packages;,
 http://cran.rstudio.com;), dependencies=TRUE)
 install.packages(caret, dependencies = c(Depends, Suggests))
 install.packages(caret, repos=http://cran.rstudio.com/;)

 I've changed my CRAN mirror from UCLA to Revolution Analytics in Dallas, and
 tried the above installs again, unsuccessfully.

 I've succeeded in individually installing a number of packages on which
 caret appears to be dependent.  Specifically, I've been able to install
 nloptr, minqa, Rcpp, reshape2, stringr, and scales.  But I've
 had no success with trying to do individual installs of BradleyTerry2,
 car, lme4, quantreg, and RcppEigen.

 Any suggestions will be very gratefully received (and tried out quickly).

 Thanks in advance.

 Ron Wyllys


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] WEIBULL or EXPONENTIAL?

2015-04-03 Thread varin sacha
Hi Xavier,

I use the fitdistrplus and logspline packages to know which distribution fits 
better my data.


Here is an example :

install.packages(fitdistrplus)
library(fitdistrplus)
instal.packages(logspline)
library(logspline)
x=c(44986,18288,56147,44488,41018,40631,27301,39025,45688,47172,12300,21558,16103,48874,67245,36119,10398,42630,12879,34058,84443,30639)
descdist(x,discrete=FALSE) 

Cheers,
S.




De : CHIRIBOGA Xavier xavier.chirib...@unine.ch
À : r-help@r-project.org r-help@r-project.org 
Envoyé le : Vendredi 3 avril 2015 16h33
Objet : [R] WEIBULL or EXPONENTIAL?


Dear members,



I am doing a survival analysis wiith the function coxph...however I am 
wondering how can I know if my data follows a EXPONENTIAL or WEIBULL 
distribution?

I have 3 censored datum. Using R studio.



Thanks for the suggestions,



Xavier

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

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

[R] Repeated failures to install caret package (of Max Kuhn)

2015-04-03 Thread Ronald Wyllys
For an edx course, MIT's The Analtics Edge, I need to install the 
caret package that was originated and is maintained by Dr. Max Kuhn of 
Pfizer. So far, every effort I've made to try to 
install.packages(caret) has failed.  (I'm using R v. 3.1.3 and RStudio 
v. 0.98.1103 in LinuxMint 17.1)


Here are some of the things I've tried unsuccessfully:
install.packages(caret, repos=c(http://rstudio.org/_packages;, 
http://cran.rstudio.com;))

install.packages(caret, dependencies=TRUE)
install.packages(caret, repos=c(http://rstudio.org/_packages;, 
http://cran.rstudio.com;), dependencies=TRUE)

install.packages(caret, dependencies = c(Depends, Suggests))
install.packages(caret, repos=http://cran.rstudio.com/;)

I've changed my CRAN mirror from UCLA to Revolution Analytics in Dallas, 
and tried the above installs again, unsuccessfully.


I've succeeded in individually installing a number of packages on which 
caret appears to be dependent.  Specifically, I've been able to 
install  nloptr, minqa, Rcpp, reshape2, stringr, and 
scales.  But I've had no success with trying to do individual installs 
of BradleyTerry2, car, lme4, quantreg, and RcppEigen.


Any suggestions will be very gratefully received (and tried out quickly).

Thanks in advance.

Ron Wyllys

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


Re: [R] Repeated failures to install caret package (of Max Kuhn)

2015-04-03 Thread Uwe Ligges

What is the error message?

Best,
Uwe Ligges

On 03.04.2015 23:07, Ronald Wyllys wrote:

For an edx course, MIT's The Analtics Edge, I need to install the
caret package that was originated and is maintained by Dr. Max Kuhn of
Pfizer. So far, every effort I've made to try to
install.packages(caret) has failed.  (I'm using R v. 3.1.3 and RStudio
v. 0.98.1103 in LinuxMint 17.1)

Here are some of the things I've tried unsuccessfully:
install.packages(caret, repos=c(http://rstudio.org/_packages;,
http://cran.rstudio.com;))
install.packages(caret, dependencies=TRUE)
install.packages(caret, repos=c(http://rstudio.org/_packages;,
http://cran.rstudio.com;), dependencies=TRUE)
install.packages(caret, dependencies = c(Depends, Suggests))
install.packages(caret, repos=http://cran.rstudio.com/;)

I've changed my CRAN mirror from UCLA to Revolution Analytics in Dallas,
and tried the above installs again, unsuccessfully.

I've succeeded in individually installing a number of packages on which
caret appears to be dependent.  Specifically, I've been able to
install  nloptr, minqa, Rcpp, reshape2, stringr, and
scales.  But I've had no success with trying to do individual installs
of BradleyTerry2, car, lme4, quantreg, and RcppEigen.

Any suggestions will be very gratefully received (and tried out quickly).

Thanks in advance.

Ron Wyllys

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


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


[R] species names on a RDA plot

2015-04-03 Thread Antonio Silva
Dear R users

I'm trying to do a RDA analysis based on Borcard et al. 2011 Numerical
Ecology with R examples.

What I cannot understand is why when I run the script (RDA.R) using the
dataset from book (dataset1.rar) RDA triplot shows species names and when I
use my dataset (dataset2.rar) species names are not shown.

Data and script can be downloaded at
https://app.box.com/s/oayq7tglbmdsu72fj05h83dlzclsiglg

Does anyone know why this happens? Thanks for any clue.

Best regards

Antônio Olinto Ávila da Silva
Fisheries Institute
São Paulo, Brasil

[[alternative HTML version deleted]]

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

[R] command help

2015-04-03 Thread ali alRubaiee
Dear colleagues,
I wanted to run a command to do iteration for the following equation:
Pj+1=TT11+FtransposeTT22F-FtransposeTT21-TT12
F+y[(Atranspose-FtransposeBtranspose)P(A-BF)]

where TT11, TT22,TT12, TT21, F transpose, A, B and F are matrices and y is
a scalar
we want to find the iteration for P using loop. Can you send me the right
command for the loop for the above equation?


Thank you in advance,
Ali

[[alternative HTML version deleted]]

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


Re: [R] open xlsx file using read.xls function of gdata package

2015-04-03 Thread Hadley Wickham
You might try the readxl package - it's only available on github but it
reads both xlsx and xls. All going well, it should be on its way to CRAN
next week.

Hadley

On Friday, April 3, 2015, Luigi Marongiu marongiu.lu...@gmail.com wrote:

 Dear all,
 I am trying to open excel files using the gdata package. I can do that
 using a .xls file, but the same file, containing the same data,
 formatted in .xlsx gives error (R does not recognize the pattern from
 where to start reading the data).
 Doen anybody knows whether it is possible to read .xlslx with this package?
 Am I missing another package to implement the reading of the .xlsx?
 Thank you
 Luigi

 PS: this is the error I get:
  my.file - array.xlsx
  my.data-read.xls(
 +   my.file,
 +   sheet=sheet x,
 +   verbose=FALSE,
 +   pattern=row name,
 +   na.strings=c(NA,#DIV/0!),
 +   method=tab,
 +   perl=perl
 + )
  Warning message:
 In read.xls(my.file, sheet = sheet x, verbose = FALSE,  :
   pattern not found


 The verbose version runs like this:
 “array.xlsx”
 to tab  file
 “/tmp/Rtmp2tAjzz/filef06102dd018.tab”
 ...

 Executing ' '/usr/bin/perl'
 '/home/gigiux/R/x86_64-pc-linux-gnu-library/3.0/gdata/perl/xls2tab.pl'
  'array.xlsx' '/tmp/Rtmp2tAjzz/filef06102dd018.tab' 'sheet x' '...

 Loading 'array.xlsx'...
 Done.

 Orignal Filename: array.xlsx
 Number of Sheets: 2

 Writing sheet 'sheet x' to file '/tmp/Rtmp2tAjzz/filef06102dd018.tab'
 Minrow=31 Maxrow=17310 Mincol=0 Maxcol=4
   (Ignored 0 blank lines.)

 0

 Done.

 Searching for lines tfntaining pattern  row name ...
 Warning message:
 In read.xls(my.file, sheet = sheet x, verbose = TRUE,  :
   pattern not found
 

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



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

[[alternative HTML version deleted]]

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

Re: [R] glmnet: converting coefficients back to original scale

2015-04-03 Thread Suzen, Mehmet
This is interesting, can you post your lm.ridge solution as well?  I
suspect in glmnet, you need to use model.matrix with intercept, that
could be the reason.

-m

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


Re: [R] command help

2015-04-03 Thread Jeff Newmiller
I cannot make sense of your email. This is partly due to your use of HTML, 
which the Posting Guidelines warn you not to do. 

The symbolic language used on this mailing list is R. The linear algebra 
operations available in R are rather straightforward. Please read the 
documentation and convey your request using R do we can understand you.
---
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 3, 2015 11:16:11 AM PDT, ali alRubaiee ali.alrubaiee1...@gmail.com 
wrote:
Dear colleagues,
I wanted to run a command to do iteration for the following equation:
Pj+1=TT11+FtransposeTT22F-FtransposeTT21-TT12
F+y[(Atranspose-FtransposeBtranspose)P(A-BF)]

where TT11, TT22,TT12, TT21, F transpose, A, B and F are matrices and y
is
a scalar
we want to find the iteration for P using loop. Can you send me the
right
command for the loop for the above equation?


Thank you in advance,
Ali

   [[alternative HTML version deleted]]

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

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


Re: [R] Kruskal-Wallace power calculations.

2015-04-03 Thread Greg Snow
Here is some sample code:

## Simulation function to create data, analyze it using
## kruskal.test, and return the p-value
## change rexp to change the simulation distribution

simfun - function(means, k=length(means), n=rep(50,k)) {
  mydata - lapply( seq_len(k), function(i) {
rexp(n[i], 1) - 1 + means[i]
  })
  kruskal.test(mydata)$p.value
}

# simulate under the null to check proper sizing
B - 1
out1 - replicate(B, simfun(rep(3,4)))
hist(out1)
mean( out1 = 0.05 )
binom.test( sum(out1 = 0.05), B, p=0.05)

### Now simulate for power

B - 1
out2 - replicate(B, simfun( c(3,3,3.2,3.3)))
hist(out2)
mean( out2 = 0.05 )
binom.test( sum(out2 = 0.05), B, p=0.05 )

This simulates from a continuous exponential (skewed) and shifts to
get the means (shifted location is a common assumption, though not
required for the actual test).

On Thu, Apr 2, 2015 at 8:19 PM, Collin Lynch cfly...@ncsu.edu wrote:
 Thank you Jim, I did see those (though not my typo :) and am still
 pondering the warning about post-hoc analyses.

 The situation that I am in is that I have a set of individuals who
 have been assigned a course grade.  We have then clustered these
 individuals into about 50 communities using standard community
 detection algorithms with the goal of determining whether community
 membership affects one of their grades.  We are using the KW test as
 the grade data is strongly non-normal and my coauthors preferred KW as
 an alternative.

 The two issues that I am struggling with are: 1) whether the post-hoc
 power analysis would be useful; and 2) how to code the simulation
 studies that are described in:
 http://onlinelibrary.wiley.com/doi/10.1002/bimj.4710380510/abstract


 Problem #1 is of course beyond the scope of this e-mail list though I
 would welcome anyone's suggestions on that point.  I am not sure that
 I buy the arguments against it offered here:

 http://graphpad.com/support/faq/why-it-is-not-helpful-to-compute-the-power-of-an-experiment-to-detect-the-difference-actually-observed-why-is-post-hoc-power-analysis-futile/

 It seems that the rationale boils down to you didn't find it so you
 couldn't find it but that does not tell me how far off I was from the
 goal.  I am still perusing the articles the author cites however.


 With respect to question #2 I am trying to lay my hands on the article
 and did find this old r-help discussion:
 http://r.789695.n4.nabble.com/Power-of-Kruskal-Wallis-Test-td4671188.html
 however I am not sure how to adapt the simulation studies that it
 links to to my current problem.  The links it leads to focus on
 mixed-effects models.  This may be more of a pure stats question and
 not suited for this list but I thought I'd ask in the hopes that
 anyone had any more specific KW code or knew of a good tutorial for
 the right kinds of simulation studies.

 Thank you,
 Collin.




 On Thu, Apr 2, 2015 at 6:35 PM, Jim Lemon drjimle...@gmail.com wrote:
 Hi Collin,
 Have a look at this:

 http://stats.stackexchange.com/questions/70643/power-analysis-for-kruskal-wallis-or-mann-whitney-u-test-using-r

 Although, thinking about it, this might have constituted your perusal of
 the literature.

 Plus it always looks better when you spell the names properly

 Jim


 On Fri, Apr 3, 2015 at 2:23 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us
 wrote:

 Please stop... you are acting like a broken record, and are also posting
 in HTML format. Please read the Posting Guide and demonstrate that you have
 used a search engine on this topic before posting again.

 ---
 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 2, 2015 7:25:20 AM PDT, Collin Lynch cfly...@ncsu.edu wrote:
 Greetings, I am working on a project where we are applying the
 Kruskal-Wallace test to some factor data to evaluate their correlation
 with
 existing grade data.  I know that the grade data is nonnormal therefore
 we
 cannot rely on ANOVA or a similar parametric test.  What I would like
 to
 find is a mechanism for making power calculations for the KW test given
 the
 nonparametric assumptions.  My perusal of the literature has suggested
 that
 a simulation would be the best method.
 
 Can anyone point me to good examples of such simulations for KW in R?
 And
 does anyone have a favourite package for generating simulated data or
 conducting such tests?
 
 Thank you,
 Collin.
 
[[alternative HTML version deleted]]
 
 __
 

Re: [R] Package build system adds line break in DESCRIPTION URL

2015-04-03 Thread Ben Bolker
Daniel Lewandowski daniel at nextpagesoft.net writes:

 
 Has anybody noticed that if field URL in DESCRIPTION contains a uri with 
 66 or more characters, then file DESCRIPTION in the resulting package 
 includes a line break at the beginning?
 
 So this (source DESCRIPTION):
 
 URL: 
 http://ecdc.europa.eu/en/data-tools/
   seroincidence-calculator-tool/Pages/default.aspx

 
 becomes (again file DESCRIPTION, but inside the package)
 
 URL:
 http://ecdc.europa.eu/en/data-tools/seroincidence-calculator-tool/
   Pages/default.aspx
 
 This has been tested with R on Windows 8.1 (devel 01/04/2015 and 3.1.3) 
 and Linux Mint (3.1.3). It has many sad implications including not 
 acceptance of such packages to CRAN.
 

  (links line-broken above to make gmane happy).

  Haven't tested, but seems it would not be *too* hard to trace
through the code to see what's happening in the package-building
process.  Two thoughts:

 (1) as a workaround, could you use a URL-shortener such as tinyurl?
tinyurl allows you to specify a somewhat meaningful name for the
shortened URL, e.g. http://tinyurl.com/reproducible-000

 (2) this feels like it is more suitable for r-de...@r-project.org

  Ben Bolker

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


[R] WEIBULL or EXPONENTIAL?

2015-04-03 Thread CHIRIBOGA Xavier
Dear members,



I am doing a survival analysis wiith the function coxph...however I am 
wondering how can I know if my data follows a EXPONENTIAL or WEIBULL 
distribution?

I have 3 censored datum. Using R studio.



Thanks for the suggestions,



Xavier

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


Re: [R-es] Mapas con spplot

2015-04-03 Thread Oscar Perpiñan
Hola,

Yo lo resuelvo usando grid.rect. Tienes una posible solución aquí:
https://github.com/oscarperpinan/spacetime-vis/blob/master/choropleth.R#L216
(que es una versión actualizada de este artículo
https://procomun.wordpress.com/2012/02/18/maps_with_r_1/)

Saludos.

Oscar.
-
Oscar Perpiñán Lamigueiro
Dpto. Ing. Eléctrica, Electrónica, Automática y Física Aplicada (ETSIDI-UPM)
Grupo de Sistemas Fotovoltaicos (IES-UPM)
URL: http://oscarperpinan.github.io


2015-04-02 23:33 GMT+02:00 Ivan Aguilar iagui...@gmail.com:
 Hola

 He hecho el típico mapa con gadm y spplot:


 library(sp)
 ES -
 local(get(load(url(http://biogeo.ucdavis.edu/data/gadm2/R/ESP_adm2.RData
 

 acerco las canarias:

 A - which(ES@data$NAME_1 == Islas Canarias)
 L - length(ES@polygons[[A]]@Polygons)

 L - length(ES@polygons[[A]]@Polygons)
 for (i in 1:L){
   ES@polygons[[A]]@Polygons[[i]]@coords - cbind(ES@polygons
 [[A]]@Polygons[[i]]@coords[,1]+6,ES@polygons
 [[A]]@Polygons[[i]]@coords[,2]+5)
 }

 El tema es q quiero añadirle un recuadro a las islas usando spplot (o
 lattice) ya que es lo q voy a usar.

 Ayuda?




 --
 Ivan

 [[alternative HTML version deleted]]

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

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


Re: [R] idiom for constructing data frame

2015-04-03 Thread Hadley Wickham
On Tue, Mar 31, 2015 at 6:42 PM, Sarah Goslee sarah.gos...@gmail.com wrote:
 On Tue, Mar 31, 2015 at 6:35 PM, Richard M. Heiberger r...@temple.edu wrote:
 I got rid of the extra column.

 data.frame(r=seq(8), foo=NA, bar=NA, row.names=r)

 Brilliant!

 After much fussing, including a disturbing detour into nested lapply
 statements from which I barely emerged with my sanity (arguable, I
 suppose), here is a one-liner that creates a data frame of arbitrary
 number of rows given an existing data frame as template for column
 number and name:


 n - 8
 df1 - data.frame(A=runif(9), B=runif(9))

 do.call(data.frame, setNames(c(list(seq(n), r), as.list(rep(NA,
 ncol(df1, c(r, row.names, colnames(df1

 It's not elegant, but it is fairly R-ish. I should probably stop
 hunting for an elegant solution now.

Given a template df, you can create a new df with subsetting:

df2 - df1[rep(NA_real_, 8), ]
rownames(df2) - NULL
df2

This has the added benefit of preserving the types.

Hadley

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

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


Re: [R] WEIBULL or EXPONENTIAL?

2015-04-03 Thread JLucke
As a start you can use an exploratory approach.  Standard survival 
analysis texts show you how to use a log-log plot to assess whether a 
distribution is Weibull.   Of course, the exponential is a special case of 
the Weibull. 



CHIRIBOGA Xavier xavier.chirib...@unine.ch 
Sent by: R-help r-help-boun...@r-project.org
04/03/2015 10:33 AM

To
r-help@r-project.org r-help@r-project.org, 
cc

Subject
[R] WEIBULL or EXPONENTIAL?






Dear members,



I am doing a survival analysis wiith the function coxph...however I am 
wondering how can I know if my data follows a EXPONENTIAL or WEIBULL 
distribution?

I have 3 censored datum. Using R studio.



Thanks for the suggestions,



Xavier

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


[[alternative HTML version deleted]]

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


Re: [R] idiom for constructing data frame

2015-04-03 Thread peter dalgaard

 On 03 Apr 2015, at 16:46 , William Dunlap wdun...@tibco.com wrote:
 
  
  df - as.data.frame(rep(list(rep(NA_real_, 10)),3))
  names(df) - names
 
 As a matter of personal style (and functional programming
 sensibility), I prefer not to make named objects and then modify them.
 Also, the names coming out of that as.data.frame call are exceedingly
 ugly and I'd rather not generate them at all.
 

Ah, yes, I missed the generation of intermediate names. You can name the list 
before as.data.frame, though:

l - rep(list(rep(NA_real_, 10)),3)
names(l) - names
as.data.frame(l)

or as a one-liner:

as.data.frame(structure(rep(list(rep(NA_real_, 10)), 3) , .Names=names))

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

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


Re: [R] double-axis labels function of each other

2015-04-03 Thread John Kane
Notepad should be fine but you will, I think, still have to correct the 
apostrophes if you are copying from Word.  

Any code written in Notepad should be fine.  

There are several dedicated editors or IDE's for use with R that you might want 
to look into.  RStudio, Tinn-R and EMACs with ESS are some that come to mind.  
Among other things, they usually offer code highlighting which can be very 
useful for finding where there are typos, missing commas, and so on.

I run Linux (Ubuntu) and find gedit with an R plug-in to be very good also.


John Kane
Kingston ON Canada


 -Original Message-
 From: hill0...@umn.edu
 Sent: Thu, 2 Apr 2015 23:59:17 -0700 (PDT)
 To: r-help@r-project.org
 Subject: Re: [R] double-axis labels function of each other
 
 Yes, I keep a copy in MS Word.
 Would Notepad be OK?
 I need sleep now, will work tomorrow.
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/double-axis-labels-function-of-each-other-tp4705457p4705463.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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

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