[R] Specify multiple nested random effects in lme with heteroskedastic variance across group

2018-02-20 Thread suraj keshri
I want to fit a random effects model with two separate nested random
effects. I can easily do this using the `lmer` package in R. Here's how:

model<-lmer(y ~ 1 + x + (1 | oid/gid) + (1 | did/gid), data=data)

Here, I'm fitting a random intercept for `oid` nested within `gid` and
`did` nested within `gid`. This works well. However, I want to fit a model
where the variance of the intercept changes with the `gid` for both the
random effects. `nlme` package is capable of doing that. However, it's not
clear how. The best I could do is like so:

model <- lme(y ~ 1 + x, random=list(gid=~1, oid=~1, did=~1),
weights=varIdent(form=~1|gid), data = data)

but this nests the `did` within `oid` and `gid` nested together. I tried to
use the idea from a similar [question][1], which seems like a close problem
but the answer has not been explained well in that question. I hope someone
can figure this out.


  [1]:
https://stats.stackexchange.com/questions/58669/specifying-multiple-separate-random-effects-in-lme

[[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] regex for "[2440810] / www.tinyurl.com/hgaco4fha3"

2018-02-20 Thread Bert Gunter
These are always kind of fun, not least because of the variety of different
replies that "work" at least somewhat. Here's mine:

> stringa <- "[2440810] / www.tinyurl.com/hgaco4fha3"

> sub("^(.+)www\\.(.+)\\.com.+","\\1\\2",stringa)
[1] "[2440810] / tinyurl"

Note the use of doubled backslashes to escape the regex metacharacters. See
?regexp for details.

Cheers,
Bert





On Tue, Feb 20, 2018 at 9:19 PM, Omar André Gonzáles Díaz <
oma.gonza...@gmail.com> wrote:

> Hi, I need help for cleaning this:
>
> "[2440810] / www.tinyurl.com/hgaco4fha3"
>
> My desired output is:
>
> "[2440810] / tinyurl".
>
> My attemps:
>
> stringa <- "[2440810] / www.tinyurl.com/hgaco4fha3"
>
> b <- sub('^www.', '', stringa) #wanted  to get rid of "www." part. Until
> first dot.
>
> b <- sub('[.].*', '', b) #clean from ".com" until the end.
>
> b #returns ""[2440810] / www"
>
> Thank you.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] regex for "[2440810] / www.tinyurl.com/hgaco4fha3"

2018-02-20 Thread Ulrik Stervbo
Hi Omar,

you are almost there but! Your first substitution looks 'www' as the
start of the line followed by anything (which then do nothing), so your
second substitution removes everything from the first '.' to be found
(which is the one after www).

What you want to do is
x <- "[2440810] / www.tinyurl.com/hgaco4fha3"

y <- sub('www\\.', '', x) # Note the escape of '.'
y <- sub('\\..*', '', y)
y

Altrenatively, all in one (if all addresses are .com)
gsub("(www\\.|\\.com.*)", "", x)

And the same using stringr
library(stringr)
x %>% str_replace_all("(www\\.|\\.com.*)", "")

HTH
Ulrik


On Wed, 21 Feb 2018 at 06:20 Omar André Gonzáles Díaz <
oma.gonza...@gmail.com> wrote:

> Hi, I need help for cleaning this:
>
> "[2440810] / www.tinyurl.com/hgaco4fha3"
>
> My desired output is:
>
> "[2440810] / tinyurl".
>
> My attemps:
>
> stringa <- "[2440810] / www.tinyurl.com/hgaco4fha3"
>
> b <- sub('^www.', '', stringa) #wanted  to get rid of "www." part. Until
> first dot.
>
> b <- sub('[.].*', '', b) #clean from ".com" until the end.
>
> b #returns ""[2440810] / www"
>
> Thank you.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] regex for "[2440810] / www.tinyurl.com/hgaco4fha3"

2018-02-20 Thread Omar André Gonzáles Díaz
Hi, I need help for cleaning this:

"[2440810] / www.tinyurl.com/hgaco4fha3"

My desired output is:

"[2440810] / tinyurl".

My attemps:

stringa <- "[2440810] / www.tinyurl.com/hgaco4fha3"

b <- sub('^www.', '', stringa) #wanted  to get rid of "www." part. Until
first dot.

b <- sub('[.].*', '', b) #clean from ".com" until the end.

b #returns ""[2440810] / www"

Thank you.

[[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] Aggregate over multiple and unequal column length data frames

2018-02-20 Thread Bert Gunter
All columns in a data.frame **must** have the same length. So you cannot do
this unless empty values are filled with missings (NA's).

-- Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 6:33 PM, Ek Esawi  wrote:

>  Hi All--
>
> I have generated several 2 column data frames with variable length. The
> data frames have the same column names and variable types. I was trying to
> aggregate over the 2nd column for all the date frames, but could not figure
> out how.
>
> I thought i could make them all of equal length then combine them in 1 data
> frame where i can use aggregate, the formula version
> Or to put them in a list and loop use lapply but did not know how to do
> that and thought there might be a simpler way.
>
> Below is an example of 3 data frames and the desired result; note that some
> levels don't appear in all and may be null over all variable, like the case
> of dd on the desired result which i would like to list all levels even if
> some are all null.
>
> Thanks in advance,
>
> EK
>
>df1   df2  df3
>
> c1 c2 c1 c2 c1 c2
> 1 aa 1 bb 1 aa
> 2 aa 2 bb 2 aa
> 3 bb 3 cc
> 4 cc 4 bb
> 5 bb
>
> desired result
>
> c1 c2 c2 c2
> aa 2 2
> bb 1 2 2
> cc 1 1
> dd
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] deparseDots to get names of all arguments?

2018-02-20 Thread Spencer Graves


On 2018-02-20 20:52, William Dunlap wrote:
> Does substitute(...()) do what you want?


   That's the key.  Thanks very much.
   Spencer Graves

>
> > myFunc <- function(x, ...) substitute(...())
> > myFunc(y=1/(1:10), x=sin(3:1), z=stop("Oops"), "untagged arg")
> $y
> 1/(1:10)
>
> $z
> stop("Oops")
>
> [[3]]
> [1] "untagged arg"
>
> > names(.Last.value)
> [1] "y" "z" ""
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com 
>
> On Tue, Feb 20, 2018 at 2:36 PM, Spencer Graves 
>  > wrote:
>
> Hi, All:
>
>
>   How can I get the names of all the arguments in dots(...)?
>
>
>   I'm able to get the name of the first argument but not the
> second:
>
>
>
> deparseDots <- function(...){
>   deparse(substitute(...))
> }
> a <- 1
> b <- 2
> deparseDots(a, b)
> [1] "a"
>
>
>   I'd like to get c('a', 'b').
>
>
>   Thanks,
>   Spencer Graves
>
>
> > sessionInfo()
> R version 3.4.3 (2017-11-30)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: macOS High Sierra 10.13.3
>
> Matrix products: default
> BLAS:
> 
> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
> LAPACK:
> 
> /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets methods base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.4.3 tools_3.4.3    yaml_2.1.16
>
> __
> 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] deparseDots to get names of all arguments?

2018-02-20 Thread William Dunlap via R-help
Does substitute(...()) do what you want?

> myFunc <- function(x, ...) substitute(...())
> myFunc(y=1/(1:10), x=sin(3:1), z=stop("Oops"), "untagged arg")
$y
1/(1:10)

$z
stop("Oops")

[[3]]
[1] "untagged arg"

> names(.Last.value)
[1] "y" "z" ""


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Feb 20, 2018 at 2:36 PM, Spencer Graves <
spencer.gra...@effectivedefense.org> wrote:

> Hi, All:
>
>
>   How can I get the names of all the arguments in dots(...)?
>
>
>   I'm able to get the name of the first argument but not the second:
>
>
>
> deparseDots <- function(...){
>   deparse(substitute(...))
> }
> a <- 1
> b <- 2
> deparseDots(a, b)
> [1] "a"
>
>
>   I'd like to get c('a', 'b').
>
>
>   Thanks,
>   Spencer Graves
>
>
> > sessionInfo()
> R version 3.4.3 (2017-11-30)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: macOS High Sierra 10.13.3
>
> Matrix products: default
> BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/
> Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
> LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/
> libRlapack.dylib
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.4.3 tools_3.4.3yaml_2.1.16
>
> __
> 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/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Aggregate over multiple and unequal column length data frames

2018-02-20 Thread Ek Esawi
 Hi All--

I have generated several 2 column data frames with variable length. The
data frames have the same column names and variable types. I was trying to
aggregate over the 2nd column for all the date frames, but could not figure
out how.

I thought i could make them all of equal length then combine them in 1 data
frame where i can use aggregate, the formula version
Or to put them in a list and loop use lapply but did not know how to do
that and thought there might be a simpler way.

Below is an example of 3 data frames and the desired result; note that some
levels don't appear in all and may be null over all variable, like the case
of dd on the desired result which i would like to list all levels even if
some are all null.

Thanks in advance,

EK

   df1   df2  df3

c1 c2 c1 c2 c1 c2
1 aa 1 bb 1 aa
2 aa 2 bb 2 aa
3 bb 3 cc
4 cc 4 bb
5 bb

desired result

c1 c2 c2 c2
aa 2 2
bb 1 2 2
cc 1 1
dd

[[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] deparseDots to get names of all arguments?

2018-02-20 Thread Bert Gunter
Duncan et.al:

Referring to my previous suggestion for f:

> f(log(x),x^2)
[1] "log(x)" "x^2"

Is this not what you want?

Cheers,
Bert


On Tue, Feb 20, 2018 at 4:00 PM, Duncan Murdoch 
wrote:

> On 20/02/2018 5:47 PM, Rolf Turner wrote:
>
>> On 21/02/18 11:36, Spencer Graves wrote:
>>
>>> Hi, All:
>>>
>>>
>>> How can I get the names of all the arguments in dots(...)?
>>>
>>>
>>> I'm able to get the name of the first argument but not the
>>> second:
>>>
>>>
>>>
>>> deparseDots <- function(...){
>>> deparse(substitute(...))
>>> }
>>> a <- 1
>>> b <- 2
>>> deparseDots(a, b)
>>> [1] "a"
>>>
>>>   >I'd like to get c('a', 'b').
>>>
>>
>> Does
>>
>>   names(list(...))
>>
>> do what you want?
>>
>
> No, that does what he asked for, not what he wants :-).  Spencer, you want
> to deparse all of the expressions in ..., not their names.
>
> I think base R doesn't have a way to do this (but I may be wrong).  You
> can do it using some the rlang package.  For example, this seems to work:
>
> deparseDots <- function(...) {
>   unname(sapply(rlang::exprs(...), deparse))
> }
>
> Duncan Murdoch
>
>
> __
> 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/posti
> ng-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] deparseDots to get names of all arguments?

2018-02-20 Thread Bert Gunter
If you want to avoid the inefficiency and memory overhead of first
constructing the list and work directly on the language, then I think
?match.call is the tool you want. e.g.


> f <- function(...){
z <- as.list(match.call())[-1]
vapply(z,deparse,"a")
 }

> a <- 1
> b <- 2

> f(a,b)
[1] "a" "b"

I am sure that there are packages that may do this more elegantly and
perhaps reliably, though.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 2:47 PM, Rolf Turner 
wrote:

> On 21/02/18 11:36, Spencer Graves wrote:
>
>> Hi, All:
>>
>>
>>How can I get the names of all the arguments in dots(...)?
>>
>>
>>I'm able to get the name of the first argument but not the second:
>>
>>
>>
>> deparseDots <- function(...){
>>deparse(substitute(...))
>> }
>> a <- 1
>> b <- 2
>> deparseDots(a, b)
>> [1] "a"
>>
>>  >I'd like to get c('a', 'b').
>>
>
> Does
>
> names(list(...))
>
> do what you want?
>
> cheers,
>
> Rolf
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
>
> __
> 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/posti
> ng-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] deparseDots to get names of all arguments?

2018-02-20 Thread Duncan Murdoch

On 20/02/2018 5:47 PM, Rolf Turner wrote:

On 21/02/18 11:36, Spencer Graves wrote:

Hi, All:


    How can I get the names of all the arguments in dots(...)?


    I'm able to get the name of the first argument but not the second:



deparseDots <- function(...){
    deparse(substitute(...))
}
a <- 1
b <- 2
deparseDots(a, b)
[1] "a"

  >    I'd like to get c('a', 'b').


Does

  names(list(...))

do what you want?


No, that does what he asked for, not what he wants :-).  Spencer, you 
want to deparse all of the expressions in ..., not their names.


I think base R doesn't have a way to do this (but I may be wrong).  You 
can do it using some the rlang package.  For example, this seems to work:


deparseDots <- function(...) {
  unname(sapply(rlang::exprs(...), deparse))
}

Duncan Murdoch

__
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] deparseDots to get names of all arguments?

2018-02-20 Thread Rolf Turner

On 21/02/18 11:36, Spencer Graves wrote:

Hi, All:


   How can I get the names of all the arguments in dots(...)?


   I'm able to get the name of the first argument but not the second:



deparseDots <- function(...){
   deparse(substitute(...))
}
a <- 1
b <- 2
deparseDots(a, b)
[1] "a"

 >    I'd like to get c('a', 'b').


Does

names(list(...))

do what you want?

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] deparseDots to get names of all arguments?

2018-02-20 Thread Spencer Graves

Hi, All:


  How can I get the names of all the arguments in dots(...)?


  I'm able to get the name of the first argument but not the second:



deparseDots <- function(...){
  deparse(substitute(...))
}
a <- 1
b <- 2
deparseDots(a, b)
[1] "a"


  I'd like to get c('a', 'b').


  Thanks,
  Spencer Graves


> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: 
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: 
/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib


locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods base

loaded via a namespace (and not attached):
[1] compiler_3.4.3 tools_3.4.3    yaml_2.1.16

__
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] question regarding the AICcmodavg package

2018-02-20 Thread Cade, Brian
Do not model average the regression coefficients.  This makes no sense (see
Cade 2015.  Model averaging and muddled multimodel inferences).  And, no
there is no reasonable way to model average regression coefficients ala
Burnham and Anderson approach when some of your models include interactions
among predictors and some don't.  Stick to model averaging the predicted
responses and you can do something that is sensible and that can be applied
to any combination of predictor variables including those with interactions.

Brian Cade

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  ca...@usgs.gov 
tel:  970 226-9326


On Tue, Feb 20, 2018 at 2:19 PM, Hannah van Noort 
wrote:

> Dear moderator,
>
> If possible I would like to send in the following question for R-help:
>
> I am analyzing a small data set using PGLS with phylogenetic uncertainty
> taken into account and thereby including 100 potential phylogenetic tree
> scenarios. I've managed to run models on all of the different trees and
> performed model averaging to get parameter estimates for the intercept and
> most of the predictor variable slopes using the *AICcmodavg* package and
> *APE*, but I seem to get stuck with some of the variables that are also
> included in a two-way interaction in the model. I can obtain values for the
> two-way interaction but not for the variables separately.
>
> The error I receive is:
>
> “Error in modavg.AICgls(parm = "agefirstbreed", cand.set = Cand.models4, :
>
> Some models include more than one instance of the parameter of interest.
> This may be due to the presence of interaction/polynomial terms, or
> variables with similar names: see "?modavg" for details on variable
> specification and "exclude" argument”
>
>
>
> I'm familiar with the *exclude* function of the *AICcmodavg* package, but
> this only works when different models have been specified including ones
> without these specific two-way interactions and my models are all similar
> with regards to the interactions, only the phylogenetic tree scenarios
> differ.
>
>
>
> I was wondering if there is another method to obtain these averaged
> parameter estimates for the concerning predictor variable slopes? Not
> excluding the (significant) two-way interaction in which they are also
> involved?
> Thank you in advance for your reply.
>
> Kind regards,
>
> Hannah van Noort
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


[R] question regarding the AICcmodavg package

2018-02-20 Thread Hannah van Noort
Dear moderator,

If possible I would like to send in the following question for R-help:

I am analyzing a small data set using PGLS with phylogenetic uncertainty
taken into account and thereby including 100 potential phylogenetic tree
scenarios. I've managed to run models on all of the different trees and
performed model averaging to get parameter estimates for the intercept and
most of the predictor variable slopes using the *AICcmodavg* package and
*APE*, but I seem to get stuck with some of the variables that are also
included in a two-way interaction in the model. I can obtain values for the
two-way interaction but not for the variables separately.

The error I receive is:

“Error in modavg.AICgls(parm = "agefirstbreed", cand.set = Cand.models4, :

Some models include more than one instance of the parameter of interest.
This may be due to the presence of interaction/polynomial terms, or
variables with similar names: see "?modavg" for details on variable
specification and "exclude" argument”



I'm familiar with the *exclude* function of the *AICcmodavg* package, but
this only works when different models have been specified including ones
without these specific two-way interactions and my models are all similar
with regards to the interactions, only the phylogenetic tree scenarios
differ.



I was wondering if there is another method to obtain these averaged
parameter estimates for the concerning predictor variable slopes? Not
excluding the (significant) two-way interaction in which they are also
involved?
Thank you in advance for your reply.

Kind regards,

Hannah van Noort

[[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] Take the maximum of every 12 columns

2018-02-20 Thread Henrik Bengtsson
It looks like OP uses a data.frame, so in order to use matrixStats
(I'm the author) one would have to pay the price to coerce to a matrix
before using matrixStats::rowMaxs().  However, if it is that the
original data could equally well live in a matrix, then matrixStats
should be computational efficient for this task.  (I've seen cases
where an original matrix was turned into a data.frame just because
that is what is commonly used elsewhere and because the user may not
pay attention to the differences between matrices and data.frame.)

If the original data would be a matrix 'X', then one can do the
following with matrixStats:

Y <- sapply(seq(from = 0, to = 2880, by = 12), FUN = function(offset) {
   rowMaxs(X, cols = offset + 1:12)
})

which avoids internal temporary copies required when using regular
subsetting, e.g.

Y <- sapply(seq(from = 0, to = 2880, by = 12), FUN = function(offset) {
   rowMaxs(X[, offset + 1:12])
})

Subsetting data frames by columns is already efficient, so the same
argument does not apply there.

/Henrik

On Tue, Feb 20, 2018 at 10:00 AM, Ista Zahn  wrote:
> On Tue, Feb 20, 2018 at 11:58 AM, Bert Gunter 
> wrote:
>
>> Ista, et. al: efficiency?
>> (Note: I needed to correct my previous post: do.call() is required for
>> pmax() over the data frame)
>>
>> > x <- data.frame(matrix(runif(12e6), ncol=12))
>>
>> > system.time(r1 <- do.call(pmax,x))
>>user  system elapsed
>>   0.049   0.000   0.049
>>
>> > identical(r1,r2)
>> [1] FALSE
>> > system.time(r2 <- apply(x,1,max))
>>user  system elapsed
>>   2.162   0.045   2.207
>>
>> ## 150 times slower!
>>
>> > identical(r1,r2)
>> [1] TRUE
>>
>> pmax() is there for a reason.
>> Or is there something I am missing?
>>
>
>
> Personal preference I think. I prefer the consistency of apply. If speed
> is an issue matrixStats is both consistent and fast:
>
> library(matrixStats)
> x <- matrix(runif(12e6), ncol=12)
>
> system.time(r1 <- do.call(pmax,as.data.frame(x)))
>   ##  user  system elapsed
>   ## 0.109   0.000   0.109
> system.time(r2 <- apply(x,1,max))
>   ##  user  system elapsed
>   ## 1.292   0.024   1.321
> system.time(r3 <- rowMaxs(x))
>   ##  user  system elapsed
>   ## 0.044   0.000   0.044
>
> pmax is a fine alternative for max special case.
>
> Best,
> Ista
>
>
>
>>
>> Cheers,
>> Bert
>>
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along and
>> sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>> On Tue, Feb 20, 2018 at 8:16 AM, Miluji Sb  wrote:
>>
>>> This is what I was looking for. Thank you everyone!
>>>
>>> Sincerely,
>>>
>>> Milu
>>>
>>>
>>> 
>>>  Mail
>>> priva di virus. www.avast.com
>>> 
>>> <#m_4297398466082743447_m_6071581590498622123_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>
>>> On Tue, Feb 20, 2018 at 5:10 PM, Ista Zahn  wrote:
>>>
 Hi Milu,

 byapply(df, 12, function(x) apply(x, 1, max))

 You might also be interested in the matrixStats package.

 Best,
 Ista

 On Tue, Feb 20, 2018 at 9:55 AM, Miluji Sb  wrote:
 >  Dear all,
 >
 > I have monthly data in wide format, I am only providing data (at the
 bottom
 > of the email) for the first 24 columns but I have 2880 columns in
 total.
 >
 > I would like to take max of every 12 columns. I have taken the mean of
 > every 12 columns with the following code:
 >
 > byapply <- function(x, by, fun, ...)
 > {
 >   # Create index list
 >   if (length(by) == 1)
 >   {
 > nc <- ncol(x)
 > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
 >   } else # 'by' is a vector of groups
 >   {
 > nc <- length(by)
 > split.index <- by
 >   }
 >   index.list <- split(seq(from = 1, to = nc), split.index)
 >
 >   # Pass index list to fun using sapply() and return object
 >   sapply(index.list, function(i)
 >   {
 > do.call(fun, list(x[, i], ...))
 >   })
 > }
 >
 > ## Compute annual means
 > y <- byapply(df, 12, rowMeans)
 >
 > How can I switch rowMeans with a command that takes the maximum? I am
 a bit
 > baffled. Any help will be appreciated. Thank you.
 >
 > Sincerely,
 >
 > Milu
 >
 > ###
 > dput(droplevels(head(x, 5)))
 > structure(list(X0 = c(295.812103271484, 297.672424316406,
 299.006805419922,
 > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
 > 297.345092773438,
 > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
 > c(294.279602050781,
 > 296.401550292969, 296.777984619141, 296.089111328125, 

Re: [R] "Within" model in plm package: is the reported R-squared correct?

2018-02-20 Thread Bert Gunter
Generally speaking, statistical questions are O/T here, but sometimes they
intersect with on-topic R programming issues and do get responses. So if
you do not get a response here, try a statistics forum, like
stats.stackexchange.com  .

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 11:44 AM, Dung Nguyen 
wrote:

> Hi everyone,
>
> I am doing panel data analysis using the 'plm' package. However, I have
> noticed that the plm() function reports a different value of R-squared from
> the R-squared of the lm() function with time-demeaned data. To be clear, I
> have tried to compute the within model both manually (run an OLS regression
> with time-demeaned data using lm()) and by using plm(). The two methods
> give me 2 different values of R-squared and I am not sure which one is the
> correct one for the fixed-effect estimation.
>
> I am new to R and panel data analysis thus it will be so great if someone
> can explain the difference to me.
>
> Thank you in advance.
>
> Bests,
>
> MiYung
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] "Within" model in plm package: is the reported R-squared correct?

2018-02-20 Thread Dung Nguyen
Hi everyone,

I am doing panel data analysis using the 'plm' package. However, I have
noticed that the plm() function reports a different value of R-squared from
the R-squared of the lm() function with time-demeaned data. To be clear, I
have tried to compute the within model both manually (run an OLS regression
with time-demeaned data using lm()) and by using plm(). The two methods
give me 2 different values of R-squared and I am not sure which one is the
correct one for the fixed-effect estimation.

I am new to R and panel data analysis thus it will be so great if someone
can explain the difference to me.

Thank you in advance.

Bests,

MiYung

[[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] Take the maximum of every 12 columns

2018-02-20 Thread Ista Zahn
On Tue, Feb 20, 2018 at 11:58 AM, Bert Gunter 
wrote:

> Ista, et. al: efficiency?
> (Note: I needed to correct my previous post: do.call() is required for
> pmax() over the data frame)
>
> > x <- data.frame(matrix(runif(12e6), ncol=12))
>
> > system.time(r1 <- do.call(pmax,x))
>user  system elapsed
>   0.049   0.000   0.049
>
> > identical(r1,r2)
> [1] FALSE
> > system.time(r2 <- apply(x,1,max))
>user  system elapsed
>   2.162   0.045   2.207
>
> ## 150 times slower!
>
> > identical(r1,r2)
> [1] TRUE
>
> pmax() is there for a reason.
> Or is there something I am missing?
>


​Personal preference I think. I prefer the consistency of apply. If speed
is an issue matrixStats is both consistent and fast:​

​library(matrixStats)
x <- matrix(runif(12e6), ncol=12)

system.time(r1 <- do.call(pmax,as.data.frame(x)))
  ##  user  system elapsed
  ## 0.109   0.000   0.109
system.time(r2 <- apply(x,1,max))
  ##  user  system elapsed
  ## 1.292   0.024   1.321
system.time(r3 <- rowMaxs(x))
  ##  user  system elapsed
  ## 0.044   0.000   0.044
​
​pmax is a fine alternative​ for max special case.

Best,
Ista



>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Tue, Feb 20, 2018 at 8:16 AM, Miluji Sb  wrote:
>
>> This is what I was looking for. Thank you everyone!
>>
>> Sincerely,
>>
>> Milu
>>
>>
>> 
>>  Mail
>> priva di virus. www.avast.com
>> 
>> <#m_4297398466082743447_m_6071581590498622123_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Tue, Feb 20, 2018 at 5:10 PM, Ista Zahn  wrote:
>>
>>> Hi Milu,
>>>
>>> byapply(df, 12, function(x) apply(x, 1, max))
>>>
>>> You might also be interested in the matrixStats package.
>>>
>>> Best,
>>> Ista
>>>
>>> On Tue, Feb 20, 2018 at 9:55 AM, Miluji Sb  wrote:
>>> >  Dear all,
>>> >
>>> > I have monthly data in wide format, I am only providing data (at the
>>> bottom
>>> > of the email) for the first 24 columns but I have 2880 columns in
>>> total.
>>> >
>>> > I would like to take max of every 12 columns. I have taken the mean of
>>> > every 12 columns with the following code:
>>> >
>>> > byapply <- function(x, by, fun, ...)
>>> > {
>>> >   # Create index list
>>> >   if (length(by) == 1)
>>> >   {
>>> > nc <- ncol(x)
>>> > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>>> >   } else # 'by' is a vector of groups
>>> >   {
>>> > nc <- length(by)
>>> > split.index <- by
>>> >   }
>>> >   index.list <- split(seq(from = 1, to = nc), split.index)
>>> >
>>> >   # Pass index list to fun using sapply() and return object
>>> >   sapply(index.list, function(i)
>>> >   {
>>> > do.call(fun, list(x[, i], ...))
>>> >   })
>>> > }
>>> >
>>> > ## Compute annual means
>>> > y <- byapply(df, 12, rowMeans)
>>> >
>>> > How can I switch rowMeans with a command that takes the maximum? I am
>>> a bit
>>> > baffled. Any help will be appreciated. Thank you.
>>> >
>>> > Sincerely,
>>> >
>>> > Milu
>>> >
>>> > ###
>>> > dput(droplevels(head(x, 5)))
>>> > structure(list(X0 = c(295.812103271484, 297.672424316406,
>>> 299.006805419922,
>>> > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
>>> > 297.345092773438,
>>> > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
>>> > c(294.279602050781,
>>> > 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
>>> > ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
>>> > 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
>>> > 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
>>> > ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
>>> > 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
>>> > 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
>>> > ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
>>> > 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
>>> > 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
>>> > ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
>>> > 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
>>> > 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
>>> > ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
>>> > 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
>>> > 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
>>> > ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
>>> > 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
>>> > 296.722717285156, 297.0986328125, 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Bert Gunter
Sorry, previous code should be:

> x <- data.frame(matrix(runif(12e6), ncol=12))
> system.time(r1 <- do.call(pmax,x))
   user  system elapsed
  0.049   0.000   0.049

> system.time(r2 <- apply(x,1,max))
   user  system elapsed
  2.162   0.045   2.207

> identical(r1,r2)
[1] TRUE

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 8:58 AM, Bert Gunter  wrote:

> Ista, et. al: efficiency?
> (Note: I needed to correct my previous post: do.call() is required for
> pmax() over the data frame)
>
> > x <- data.frame(matrix(runif(12e6), ncol=12))
>
> > system.time(r1 <- do.call(pmax,x))
>user  system elapsed
>   0.049   0.000   0.049
>
> > identical(r1,r2)
> [1] FALSE
> > system.time(r2 <- apply(x,1,max))
>user  system elapsed
>   2.162   0.045   2.207
>
> ## 150 times slower!
>
> > identical(r1,r2)
> [1] TRUE
>
> pmax() is there for a reason.
> Or is there something I am missing?
>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Tue, Feb 20, 2018 at 8:16 AM, Miluji Sb  wrote:
>
>> This is what I was looking for. Thank you everyone!
>>
>> Sincerely,
>>
>> Milu
>>
>>
>> 
>>  Mail
>> priva di virus. www.avast.com
>> 
>> <#m_7564601492398332906_m_6071581590498622123_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Tue, Feb 20, 2018 at 5:10 PM, Ista Zahn  wrote:
>>
>>> Hi Milu,
>>>
>>> byapply(df, 12, function(x) apply(x, 1, max))
>>>
>>> You might also be interested in the matrixStats package.
>>>
>>> Best,
>>> Ista
>>>
>>> On Tue, Feb 20, 2018 at 9:55 AM, Miluji Sb  wrote:
>>> >  Dear all,
>>> >
>>> > I have monthly data in wide format, I am only providing data (at the
>>> bottom
>>> > of the email) for the first 24 columns but I have 2880 columns in
>>> total.
>>> >
>>> > I would like to take max of every 12 columns. I have taken the mean of
>>> > every 12 columns with the following code:
>>> >
>>> > byapply <- function(x, by, fun, ...)
>>> > {
>>> >   # Create index list
>>> >   if (length(by) == 1)
>>> >   {
>>> > nc <- ncol(x)
>>> > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>>> >   } else # 'by' is a vector of groups
>>> >   {
>>> > nc <- length(by)
>>> > split.index <- by
>>> >   }
>>> >   index.list <- split(seq(from = 1, to = nc), split.index)
>>> >
>>> >   # Pass index list to fun using sapply() and return object
>>> >   sapply(index.list, function(i)
>>> >   {
>>> > do.call(fun, list(x[, i], ...))
>>> >   })
>>> > }
>>> >
>>> > ## Compute annual means
>>> > y <- byapply(df, 12, rowMeans)
>>> >
>>> > How can I switch rowMeans with a command that takes the maximum? I am
>>> a bit
>>> > baffled. Any help will be appreciated. Thank you.
>>> >
>>> > Sincerely,
>>> >
>>> > Milu
>>> >
>>> > ###
>>> > dput(droplevels(head(x, 5)))
>>> > structure(list(X0 = c(295.812103271484, 297.672424316406,
>>> 299.006805419922,
>>> > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
>>> > 297.345092773438,
>>> > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
>>> > c(294.279602050781,
>>> > 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
>>> > ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
>>> > 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
>>> > 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
>>> > ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
>>> > 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
>>> > 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
>>> > ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
>>> > 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
>>> > 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
>>> > ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
>>> > 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
>>> > 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
>>> > ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
>>> > 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
>>> > 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
>>> > ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
>>> > 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
>>> > 296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
>>> > ), X15 = c(292.176361083984, 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Bert Gunter
Ista, et. al: efficiency?
(Note: I needed to correct my previous post: do.call() is required for
pmax() over the data frame)

> x <- data.frame(matrix(runif(12e6), ncol=12))

> system.time(r1 <- do.call(pmax,x))
   user  system elapsed
  0.049   0.000   0.049

> identical(r1,r2)
[1] FALSE
> system.time(r2 <- apply(x,1,max))
   user  system elapsed
  2.162   0.045   2.207

## 150 times slower!

> identical(r1,r2)
[1] TRUE

pmax() is there for a reason.
Or is there something I am missing?

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 8:16 AM, Miluji Sb  wrote:

> This is what I was looking for. Thank you everyone!
>
> Sincerely,
>
> Milu
>
>
> 
>  Mail
> priva di virus. www.avast.com
> 
> <#m_6071581590498622123_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Tue, Feb 20, 2018 at 5:10 PM, Ista Zahn  wrote:
>
>> Hi Milu,
>>
>> byapply(df, 12, function(x) apply(x, 1, max))
>>
>> You might also be interested in the matrixStats package.
>>
>> Best,
>> Ista
>>
>> On Tue, Feb 20, 2018 at 9:55 AM, Miluji Sb  wrote:
>> >  Dear all,
>> >
>> > I have monthly data in wide format, I am only providing data (at the
>> bottom
>> > of the email) for the first 24 columns but I have 2880 columns in total.
>> >
>> > I would like to take max of every 12 columns. I have taken the mean of
>> > every 12 columns with the following code:
>> >
>> > byapply <- function(x, by, fun, ...)
>> > {
>> >   # Create index list
>> >   if (length(by) == 1)
>> >   {
>> > nc <- ncol(x)
>> > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>> >   } else # 'by' is a vector of groups
>> >   {
>> > nc <- length(by)
>> > split.index <- by
>> >   }
>> >   index.list <- split(seq(from = 1, to = nc), split.index)
>> >
>> >   # Pass index list to fun using sapply() and return object
>> >   sapply(index.list, function(i)
>> >   {
>> > do.call(fun, list(x[, i], ...))
>> >   })
>> > }
>> >
>> > ## Compute annual means
>> > y <- byapply(df, 12, rowMeans)
>> >
>> > How can I switch rowMeans with a command that takes the maximum? I am a
>> bit
>> > baffled. Any help will be appreciated. Thank you.
>> >
>> > Sincerely,
>> >
>> > Milu
>> >
>> > ###
>> > dput(droplevels(head(x, 5)))
>> > structure(list(X0 = c(295.812103271484, 297.672424316406,
>> 299.006805419922,
>> > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
>> > 297.345092773438,
>> > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
>> > c(294.279602050781,
>> > 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
>> > ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
>> > 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
>> > 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
>> > ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
>> > 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
>> > 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
>> > ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
>> > 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
>> > 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
>> > ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
>> > 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
>> > 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
>> > ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
>> > 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
>> > 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
>> > ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
>> > 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
>> > 296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
>> > ), X15 = c(292.176361083984, 294.49658203125, 293.888305664062,
>> > 294.172149658203, 296.117095947266 <(709)%20594-7266>), X16 =
>> c(288.400726318359,
>> > 291.029113769531, 289.361907958984, 290.566772460938, 293.554016113281
>> > ), X17 = c(285.665222167969, 288.293029785156, 286.118957519531,
>> > 288.105285644531, 291.429382324219), X18 = c(285.971252441406,
>> > 288.3798828125, 286.444580078125, 288.495880126953, 291.447326660156
>> > ), X19 = c(288.79296875, 290.357543945312, 289.657928466797,
>> > 291.449066162109, 293.095275878906), X20 = c(291.999877929688,
>> > 292.838348388672, 293.840362548828, 294.412322998047, 294.941253662109
>> > ), X21 = c(293.615447998047, 294.028106689453, 296.072296142578,
>> > 296.447387695312, 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Miluji Sb
This is what I was looking for. Thank you everyone!

Sincerely,

Milu


Mail
priva di virus. www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Feb 20, 2018 at 5:10 PM, Ista Zahn  wrote:

> Hi Milu,
>
> byapply(df, 12, function(x) apply(x, 1, max))
>
> You might also be interested in the matrixStats package.
>
> Best,
> Ista
>
> On Tue, Feb 20, 2018 at 9:55 AM, Miluji Sb  wrote:
> >  Dear all,
> >
> > I have monthly data in wide format, I am only providing data (at the
> bottom
> > of the email) for the first 24 columns but I have 2880 columns in total.
> >
> > I would like to take max of every 12 columns. I have taken the mean of
> > every 12 columns with the following code:
> >
> > byapply <- function(x, by, fun, ...)
> > {
> >   # Create index list
> >   if (length(by) == 1)
> >   {
> > nc <- ncol(x)
> > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
> >   } else # 'by' is a vector of groups
> >   {
> > nc <- length(by)
> > split.index <- by
> >   }
> >   index.list <- split(seq(from = 1, to = nc), split.index)
> >
> >   # Pass index list to fun using sapply() and return object
> >   sapply(index.list, function(i)
> >   {
> > do.call(fun, list(x[, i], ...))
> >   })
> > }
> >
> > ## Compute annual means
> > y <- byapply(df, 12, rowMeans)
> >
> > How can I switch rowMeans with a command that takes the maximum? I am a
> bit
> > baffled. Any help will be appreciated. Thank you.
> >
> > Sincerely,
> >
> > Milu
> >
> > ###
> > dput(droplevels(head(x, 5)))
> > structure(list(X0 = c(295.812103271484, 297.672424316406,
> 299.006805419922,
> > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
> > 297.345092773438,
> > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
> > c(294.279602050781,
> > 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
> > ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
> > 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
> > 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
> > ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
> > 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
> > 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
> > ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
> > 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
> > 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
> > ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
> > 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
> > 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
> > ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
> > 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
> > 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
> > ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
> > 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
> > 296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
> > ), X15 = c(292.176361083984, 294.49658203125, 293.888305664062,
> > 294.172149658203, 296.117095947266), X16 = c(288.400726318359,
> > 291.029113769531, 289.361907958984, 290.566772460938, 293.554016113281
> > ), X17 = c(285.665222167969, 288.293029785156, 286.118957519531,
> > 288.105285644531, 291.429382324219), X18 = c(285.971252441406,
> > 288.3798828125, 286.444580078125, 288.495880126953, 291.447326660156
> > ), X19 = c(288.79296875, 290.357543945312, 289.657928466797,
> > 291.449066162109, 293.095275878906), X20 = c(291.999877929688,
> > 292.838348388672, 293.840362548828, 294.412322998047, 294.941253662109
> > ), X21 = c(293.615447998047, 294.028106689453, 296.072296142578,
> > 296.447387695312, 295.824615478516), X22 = c(294.719848632812,
> > 295.392028808594, 297.453216552734, 297.114288330078, 296.883209228516
> > ), X23 = c(295.634429931641, 296.783294677734, 298.592346191406,
> > 297.469512939453, 297.832122802734)), .Names = c("X0", "X1",
> > "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "X11",
> > "X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19", "X20",
> > "X21", "X22", "X23"), row.names = c(NA, 5L), class = "data.frame")
> >
> >  source=link_campaign=sig-email_content=webmail>
> > Mail
> > priva di virus. www.avast.com
> >  source=link_campaign=sig-email_content=webmail>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Bert Gunter
 Do you want the max of all the data in all 12 columns -- 1 number -- or
the parallel max of the 12 columns -- a vector of length the number of rows.

In the first case,
max(df[,1:12])
will do (R uses 1-based indexing,not 0-based) ;

in the second case,
pmax(df[, 1:12])
will do.

If either of these is what you want, all your code is nonsense. Of course
you can change the indexing to march through the data frame in whatever way
you like. If this is not what you want, maybe someone wiser than I can
interpret your query.

Cheers,
Bert





Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 7:59 AM, Miluji Sb  wrote:

> Thank you for your kind replies. Maybe I was not clear with my question (I
> apologize) or I did not understand...
>
> I would like to take the max for X0...X11 and X12...X24 in my dataset.
> When I use pmax with the function byapply as in
>
> byapply(df, 12, pmax)
>
> I get back a list which I cannot convert to a dataframe. Am I missing
> something? Thanks again!
>
> Sincerely,
>
> Milu
>
>
> 
>  Mail
> priva di virus. www.avast.com
> 
> <#m_-2971460967079739222_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Tue, Feb 20, 2018 at 4:38 PM, Bert Gunter 
> wrote:
>
>> Don't do this (sorry Thierry)! max() already does this -- see ?max
>>
>> > x <- data.frame(a =rnorm(10), b = rnorm(10))
>> > max(x)
>> [1] 1.799644
>>
>> > max(sapply(x,max))
>> [1] 1.799644
>>
>> Cheers,
>> Bert
>>
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>> On Tue, Feb 20, 2018 at 7:05 AM, Thierry Onkelinx <
>> thierry.onkel...@inbo.be> wrote:
>>
>>> The maximum over twelve columns is the maximum of the twelve maxima of
>>> each of the columns.
>>>
>>> single_col_max <- apply(x, 2, max)
>>> twelve_col_max <- apply(
>>>   matrix(single_col_max, nrow = 12),
>>>   2,
>>>   max
>>> )
>>>
>>> ir. Thierry Onkelinx
>>> Statisticus / Statistician
>>>
>>> Vlaamse Overheid / Government of Flanders
>>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
>>> AND FOREST
>>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
>>> thierry.onkel...@inbo.be
>>> Havenlaan 88
>>>  bus 73,
>>> 1000 Brussel
>>> www.inbo.be
>>>
>>> 
>>> ///
>>> To call in the statistician after the experiment is done may be no
>>> more than asking him to perform a post-mortem examination: he may be
>>> able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
>>> The plural of anecdote is not data. ~ Roger Brinner
>>> The combination of some data and an aching desire for an answer does
>>> not ensure that a reasonable answer can be extracted from a given body
>>> of data. ~ John Tukey
>>> 
>>> ///
>>>
>>>
>>>
>>>
>>> 2018-02-20 15:55 GMT+01:00 Miluji Sb :
>>> >  Dear all,
>>> >
>>> > I have monthly data in wide format, I am only providing data (at the
>>> bottom
>>> > of the email) for the first 24 columns but I have 2880 columns in
>>> total.
>>> >
>>> > I would like to take max of every 12 columns. I have taken the mean of
>>> > every 12 columns with the following code:
>>> >
>>> > byapply <- function(x, by, fun, ...)
>>> > {
>>> >   # Create index list
>>> >   if (length(by) == 1)
>>> >   {
>>> > nc <- ncol(x)
>>> > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>>> >   } else # 'by' is a vector of groups
>>> >   {
>>> > nc <- length(by)
>>> > split.index <- by
>>> >   }
>>> >   index.list <- split(seq(from = 1, to = nc), split.index)
>>> >
>>> >   # Pass index list to fun using sapply() and return object
>>> >   sapply(index.list, function(i)
>>> >   {
>>> > do.call(fun, list(x[, i], ...))
>>> >   })
>>> > }
>>> >
>>> > ## Compute annual means
>>> > y <- byapply(df, 12, rowMeans)
>>> >
>>> > How can I switch rowMeans with a command that takes the maximum? I am
>>> a bit
>>> > baffled. Any help will be appreciated. Thank you.
>>> >
>>> > Sincerely,
>>> >
>>> > Milu
>>> >
>>> > ###
>>> > dput(droplevels(head(x, 5)))
>>> > structure(list(X0 = c(295.812103271484, 297.672424316406,
>>> 299.006805419922,
>>> > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
>>> > 297.345092773438,
>>> > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
>>> > c(294.279602050781,
>>> > 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Ista Zahn
Hi Milu,

byapply(df, 12, function(x) apply(x, 1, max))

You might also be interested in the matrixStats package.

Best,
Ista

On Tue, Feb 20, 2018 at 9:55 AM, Miluji Sb  wrote:
>  Dear all,
>
> I have monthly data in wide format, I am only providing data (at the bottom
> of the email) for the first 24 columns but I have 2880 columns in total.
>
> I would like to take max of every 12 columns. I have taken the mean of
> every 12 columns with the following code:
>
> byapply <- function(x, by, fun, ...)
> {
>   # Create index list
>   if (length(by) == 1)
>   {
> nc <- ncol(x)
> split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>   } else # 'by' is a vector of groups
>   {
> nc <- length(by)
> split.index <- by
>   }
>   index.list <- split(seq(from = 1, to = nc), split.index)
>
>   # Pass index list to fun using sapply() and return object
>   sapply(index.list, function(i)
>   {
> do.call(fun, list(x[, i], ...))
>   })
> }
>
> ## Compute annual means
> y <- byapply(df, 12, rowMeans)
>
> How can I switch rowMeans with a command that takes the maximum? I am a bit
> baffled. Any help will be appreciated. Thank you.
>
> Sincerely,
>
> Milu
>
> ###
> dput(droplevels(head(x, 5)))
> structure(list(X0 = c(295.812103271484, 297.672424316406, 299.006805419922,
> 297.631500244141, 298.372741699219), X1 = c(295.361328125,
> 297.345092773438,
> 298.067504882812, 297.285339355469, 298.275268554688), X2 =
> c(294.279602050781,
> 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
> ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
> 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
> 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
> ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
> 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
> 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
> ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
> 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
> 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
> ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
> 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
> 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
> ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
> 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
> 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
> ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
> 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
> 296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
> ), X15 = c(292.176361083984, 294.49658203125, 293.888305664062,
> 294.172149658203, 296.117095947266), X16 = c(288.400726318359,
> 291.029113769531, 289.361907958984, 290.566772460938, 293.554016113281
> ), X17 = c(285.665222167969, 288.293029785156, 286.118957519531,
> 288.105285644531, 291.429382324219), X18 = c(285.971252441406,
> 288.3798828125, 286.444580078125, 288.495880126953, 291.447326660156
> ), X19 = c(288.79296875, 290.357543945312, 289.657928466797,
> 291.449066162109, 293.095275878906), X20 = c(291.999877929688,
> 292.838348388672, 293.840362548828, 294.412322998047, 294.941253662109
> ), X21 = c(293.615447998047, 294.028106689453, 296.072296142578,
> 296.447387695312, 295.824615478516), X22 = c(294.719848632812,
> 295.392028808594, 297.453216552734, 297.114288330078, 296.883209228516
> ), X23 = c(295.634429931641, 296.783294677734, 298.592346191406,
> 297.469512939453, 297.832122802734)), .Names = c("X0", "X1",
> "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "X11",
> "X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19", "X20",
> "X21", "X22", "X23"), row.names = c(NA, 5L), class = "data.frame")
>
> 
> Mail
> priva di virus. www.avast.com
> 
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> [[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] Take the maximum of every 12 columns

2018-02-20 Thread Miluji Sb
Thank you for your kind replies. Maybe I was not clear with my question (I
apologize) or I did not understand...

I would like to take the max for X0...X11 and X12...X24 in my dataset. When
I use pmax with the function byapply as in

byapply(df, 12, pmax)

I get back a list which I cannot convert to a dataframe. Am I missing
something? Thanks again!

Sincerely,

Milu


Mail
priva di virus. www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Feb 20, 2018 at 4:38 PM, Bert Gunter  wrote:

> Don't do this (sorry Thierry)! max() already does this -- see ?max
>
> > x <- data.frame(a =rnorm(10), b = rnorm(10))
> > max(x)
> [1] 1.799644
>
> > max(sapply(x,max))
> [1] 1.799644
>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Tue, Feb 20, 2018 at 7:05 AM, Thierry Onkelinx <
> thierry.onkel...@inbo.be> wrote:
>
>> The maximum over twelve columns is the maximum of the twelve maxima of
>> each of the columns.
>>
>> single_col_max <- apply(x, 2, max)
>> twelve_col_max <- apply(
>>   matrix(single_col_max, nrow = 12),
>>   2,
>>   max
>> )
>>
>> ir. Thierry Onkelinx
>> Statisticus / Statistician
>>
>> Vlaamse Overheid / Government of Flanders
>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
>> AND FOREST
>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
>> thierry.onkel...@inbo.be
>> Havenlaan 88
>>  bus 73,
>> 1000 Brussel
>> www.inbo.be
>>
>> 
>> ///
>> To call in the statistician after the experiment is done may be no
>> more than asking him to perform a post-mortem examination: he may be
>> able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does
>> not ensure that a reasonable answer can be extracted from a given body
>> of data. ~ John Tukey
>> 
>> ///
>>
>>
>>
>>
>> 2018-02-20 15:55 GMT+01:00 Miluji Sb :
>> >  Dear all,
>> >
>> > I have monthly data in wide format, I am only providing data (at the
>> bottom
>> > of the email) for the first 24 columns but I have 2880 columns in total.
>> >
>> > I would like to take max of every 12 columns. I have taken the mean of
>> > every 12 columns with the following code:
>> >
>> > byapply <- function(x, by, fun, ...)
>> > {
>> >   # Create index list
>> >   if (length(by) == 1)
>> >   {
>> > nc <- ncol(x)
>> > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>> >   } else # 'by' is a vector of groups
>> >   {
>> > nc <- length(by)
>> > split.index <- by
>> >   }
>> >   index.list <- split(seq(from = 1, to = nc), split.index)
>> >
>> >   # Pass index list to fun using sapply() and return object
>> >   sapply(index.list, function(i)
>> >   {
>> > do.call(fun, list(x[, i], ...))
>> >   })
>> > }
>> >
>> > ## Compute annual means
>> > y <- byapply(df, 12, rowMeans)
>> >
>> > How can I switch rowMeans with a command that takes the maximum? I am a
>> bit
>> > baffled. Any help will be appreciated. Thank you.
>> >
>> > Sincerely,
>> >
>> > Milu
>> >
>> > ###
>> > dput(droplevels(head(x, 5)))
>> > structure(list(X0 = c(295.812103271484, 297.672424316406,
>> 299.006805419922,
>> > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
>> > 297.345092773438,
>> > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
>> > c(294.279602050781,
>> > 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
>> > ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
>> > 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
>> > 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
>> > ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
>> > 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
>> > 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
>> > ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
>> > 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
>> > 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
>> > ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
>> > 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
>> > 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
>> > ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
>> > 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Bert Gunter
Don't do this (sorry Thierry)! max() already does this -- see ?max

> x <- data.frame(a =rnorm(10), b = rnorm(10))
> max(x)
[1] 1.799644

> max(sapply(x,max))
[1] 1.799644

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 7:05 AM, Thierry Onkelinx 
wrote:

> The maximum over twelve columns is the maximum of the twelve maxima of
> each of the columns.
>
> single_col_max <- apply(x, 2, max)
> twelve_col_max <- apply(
>   matrix(single_col_max, nrow = 12),
>   2,
>   max
> )
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
> AND FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkel...@inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
>
> 
> ///
> To call in the statistician after the experiment is done may be no
> more than asking him to perform a post-mortem examination: he may be
> able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does
> not ensure that a reasonable answer can be extracted from a given body
> of data. ~ John Tukey
> 
> ///
>
>
>
>
> 2018-02-20 15:55 GMT+01:00 Miluji Sb :
> >  Dear all,
> >
> > I have monthly data in wide format, I am only providing data (at the
> bottom
> > of the email) for the first 24 columns but I have 2880 columns in total.
> >
> > I would like to take max of every 12 columns. I have taken the mean of
> > every 12 columns with the following code:
> >
> > byapply <- function(x, by, fun, ...)
> > {
> >   # Create index list
> >   if (length(by) == 1)
> >   {
> > nc <- ncol(x)
> > split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
> >   } else # 'by' is a vector of groups
> >   {
> > nc <- length(by)
> > split.index <- by
> >   }
> >   index.list <- split(seq(from = 1, to = nc), split.index)
> >
> >   # Pass index list to fun using sapply() and return object
> >   sapply(index.list, function(i)
> >   {
> > do.call(fun, list(x[, i], ...))
> >   })
> > }
> >
> > ## Compute annual means
> > y <- byapply(df, 12, rowMeans)
> >
> > How can I switch rowMeans with a command that takes the maximum? I am a
> bit
> > baffled. Any help will be appreciated. Thank you.
> >
> > Sincerely,
> >
> > Milu
> >
> > ###
> > dput(droplevels(head(x, 5)))
> > structure(list(X0 = c(295.812103271484, 297.672424316406,
> 299.006805419922,
> > 297.631500244141, 298.372741699219), X1 = c(295.361328125,
> > 297.345092773438,
> > 298.067504882812, 297.285339355469, 298.275268554688), X2 =
> > c(294.279602050781,
> > 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
> > ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
> > 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
> > 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
> > ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
> > 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
> > 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
> > ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
> > 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
> > 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
> > ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
> > 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
> > 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
> > ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
> > 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
> > 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
> > ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
> > 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
> > 296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
> > ), X15 = c(292.176361083984, 294.49658203125, 293.888305664062,
> > 294.172149658203, 296.117095947266), X16 = c(288.400726318359,
> > 291.029113769531, 289.361907958984, 290.566772460938, 293.554016113281
> > ), X17 = c(285.665222167969, 288.293029785156, 286.118957519531,
> > 288.105285644531, 291.429382324219), X18 = c(285.971252441406,
> > 288.3798828125, 286.444580078125, 288.495880126953, 291.447326660156
> > ), X19 = c(288.79296875, 290.357543945312, 289.657928466797,
> > 291.449066162109, 293.095275878906), X20 = c(291.999877929688,
> > 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Thierry Onkelinx
The maximum over twelve columns is the maximum of the twelve maxima of
each of the columns.

single_col_max <- apply(x, 2, max)
twelve_col_max <- apply(
  matrix(single_col_max, nrow = 12),
  2,
  max
)

ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
AND FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkel...@inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

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




2018-02-20 15:55 GMT+01:00 Miluji Sb :
>  Dear all,
>
> I have monthly data in wide format, I am only providing data (at the bottom
> of the email) for the first 24 columns but I have 2880 columns in total.
>
> I would like to take max of every 12 columns. I have taken the mean of
> every 12 columns with the following code:
>
> byapply <- function(x, by, fun, ...)
> {
>   # Create index list
>   if (length(by) == 1)
>   {
> nc <- ncol(x)
> split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>   } else # 'by' is a vector of groups
>   {
> nc <- length(by)
> split.index <- by
>   }
>   index.list <- split(seq(from = 1, to = nc), split.index)
>
>   # Pass index list to fun using sapply() and return object
>   sapply(index.list, function(i)
>   {
> do.call(fun, list(x[, i], ...))
>   })
> }
>
> ## Compute annual means
> y <- byapply(df, 12, rowMeans)
>
> How can I switch rowMeans with a command that takes the maximum? I am a bit
> baffled. Any help will be appreciated. Thank you.
>
> Sincerely,
>
> Milu
>
> ###
> dput(droplevels(head(x, 5)))
> structure(list(X0 = c(295.812103271484, 297.672424316406, 299.006805419922,
> 297.631500244141, 298.372741699219), X1 = c(295.361328125,
> 297.345092773438,
> 298.067504882812, 297.285339355469, 298.275268554688), X2 =
> c(294.279602050781,
> 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
> ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
> 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
> 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
> ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
> 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
> 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
> ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
> 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
> 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
> ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
> 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
> 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
> ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
> 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
> 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
> ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
> 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
> 296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
> ), X15 = c(292.176361083984, 294.49658203125, 293.888305664062,
> 294.172149658203, 296.117095947266), X16 = c(288.400726318359,
> 291.029113769531, 289.361907958984, 290.566772460938, 293.554016113281
> ), X17 = c(285.665222167969, 288.293029785156, 286.118957519531,
> 288.105285644531, 291.429382324219), X18 = c(285.971252441406,
> 288.3798828125, 286.444580078125, 288.495880126953, 291.447326660156
> ), X19 = c(288.79296875, 290.357543945312, 289.657928466797,
> 291.449066162109, 293.095275878906), X20 = c(291.999877929688,
> 292.838348388672, 293.840362548828, 294.412322998047, 294.941253662109
> ), X21 = c(293.615447998047, 294.028106689453, 296.072296142578,
> 296.447387695312, 295.824615478516), X22 = c(294.719848632812,
> 295.392028808594, 297.453216552734, 297.114288330078, 296.883209228516
> ), X23 = c(295.634429931641, 296.783294677734, 298.592346191406,
> 297.469512939453, 297.832122802734)), .Names = c("X0", "X1",
> "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "X11",
> "X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19", "X20",
> "X21", "X22", "X23"), row.names = c(NA, 5L), class = "data.frame")
>
> 

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Bert Gunter
?pmax

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Feb 20, 2018 at 6:55 AM, Miluji Sb  wrote:

>  Dear all,
>
> I have monthly data in wide format, I am only providing data (at the bottom
> of the email) for the first 24 columns but I have 2880 columns in total.
>
> I would like to take max of every 12 columns. I have taken the mean of
> every 12 columns with the following code:
>
> byapply <- function(x, by, fun, ...)
> {
>   # Create index list
>   if (length(by) == 1)
>   {
> nc <- ncol(x)
> split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
>   } else # 'by' is a vector of groups
>   {
> nc <- length(by)
> split.index <- by
>   }
>   index.list <- split(seq(from = 1, to = nc), split.index)
>
>   # Pass index list to fun using sapply() and return object
>   sapply(index.list, function(i)
>   {
> do.call(fun, list(x[, i], ...))
>   })
> }
>
> ## Compute annual means
> y <- byapply(df, 12, rowMeans)
>
> How can I switch rowMeans with a command that takes the maximum? I am a bit
> baffled. Any help will be appreciated. Thank you.
>
> Sincerely,
>
> Milu
>
> ###
> dput(droplevels(head(x, 5)))
> structure(list(X0 = c(295.812103271484, 297.672424316406, 299.006805419922,
> 297.631500244141, 298.372741699219), X1 = c(295.361328125,
> 297.345092773438,
> 298.067504882812, 297.285339355469, 298.275268554688), X2 =
> c(294.279602050781,
> 296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
> ), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
> 293.916229248047, 296.129943847656), X4 = c(288.525024414062,
> 291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
> ), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
> 288.393951416016, 291.710266113281), X6 = c(285.550537109375,
> 288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
> ), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
> 291.796203613281, 293.423248291016), X8 = c(292.410003662109,
> 292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
> ), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
> 296.963531494141, 296.036224365234), X10 = c(294.532531738281,
> 295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
> ), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
> 297.627593994141, 297.964935302734), X12 = c(295.986236572266,
> 297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
> ), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
> 297.704925537109, 298.819091796875), X14 = c(294.654327392578,
> 296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
> ), X15 = c(292.176361083984, 294.49658203125, 293.888305664062,
> 294.172149658203, 296.117095947266), X16 = c(288.400726318359,
> 291.029113769531, 289.361907958984, 290.566772460938, 293.554016113281
> ), X17 = c(285.665222167969, 288.293029785156, 286.118957519531,
> 288.105285644531, 291.429382324219), X18 = c(285.971252441406,
> 288.3798828125, 286.444580078125, 288.495880126953, 291.447326660156
> ), X19 = c(288.79296875, 290.357543945312, 289.657928466797,
> 291.449066162109, 293.095275878906), X20 = c(291.999877929688,
> 292.838348388672, 293.840362548828, 294.412322998047, 294.941253662109
> ), X21 = c(293.615447998047, 294.028106689453, 296.072296142578,
> 296.447387695312, 295.824615478516), X22 = c(294.719848632812,
> 295.392028808594, 297.453216552734, 297.114288330078, 296.883209228516
> ), X23 = c(295.634429931641, 296.783294677734, 298.592346191406,
> 297.469512939453, 297.832122802734)), .Names = c("X0", "X1",
> "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "X11",
> "X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19", "X20",
> "X21", "X22", "X23"), row.names = c(NA, 5L), class = "data.frame")
>
>  source=link_campaign=sig-email_content=webmail>
> Mail
> priva di virus. www.avast.com
>  source=link_campaign=sig-email_content=webmail>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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

[R] Take the maximum of every 12 columns

2018-02-20 Thread Miluji Sb
 Dear all,

I have monthly data in wide format, I am only providing data (at the bottom
of the email) for the first 24 columns but I have 2880 columns in total.

I would like to take max of every 12 columns. I have taken the mean of
every 12 columns with the following code:

byapply <- function(x, by, fun, ...)
{
  # Create index list
  if (length(by) == 1)
  {
nc <- ncol(x)
split.index <- rep(1:ceiling(nc / by), each = by, length.out = nc)
  } else # 'by' is a vector of groups
  {
nc <- length(by)
split.index <- by
  }
  index.list <- split(seq(from = 1, to = nc), split.index)

  # Pass index list to fun using sapply() and return object
  sapply(index.list, function(i)
  {
do.call(fun, list(x[, i], ...))
  })
}

## Compute annual means
y <- byapply(df, 12, rowMeans)

How can I switch rowMeans with a command that takes the maximum? I am a bit
baffled. Any help will be appreciated. Thank you.

Sincerely,

Milu

###
dput(droplevels(head(x, 5)))
structure(list(X0 = c(295.812103271484, 297.672424316406, 299.006805419922,
297.631500244141, 298.372741699219), X1 = c(295.361328125,
297.345092773438,
298.067504882812, 297.285339355469, 298.275268554688), X2 =
c(294.279602050781,
296.401550292969, 296.777984619141, 296.089111328125, 297.540374755859
), X3 = c(292.103118896484, 294.253601074219, 293.773803710938,
293.916229248047, 296.129943847656), X4 = c(288.525024414062,
291.274505615234, 289.502777099609, 290.723388671875, 293.615112304688
), X5 = c(286.018371582031, 288.748565673828, 286.463134765625,
288.393951416016, 291.710266113281), X6 = c(285.550537109375,
288.159149169922, 285.976501464844, 287.999816894531, 291.228271484375
), X7 = c(289.136962890625, 290.751159667969, 290.170257568359,
291.796203613281, 293.423248291016), X8 = c(292.410003662109,
292.701263427734, 294.25244140625, 295.320404052734, 295.248199462891
), X9 = c(293.821655273438, 294.139068603516, 296.630157470703,
296.963531494141, 296.036224365234), X10 = c(294.532531738281,
295.366607666016, 297.677551269531, 296.715911865234, 296.564178466797
), X11 = c(295.869476318359, 297.010070800781, 299.330169677734,
297.627593994141, 297.964935302734), X12 = c(295.986236572266,
297.675567626953, 299.056671142578, 297.598907470703, 298.481842041016
), X13 = c(295.947601318359, 297.934448242188, 298.745391845703,
297.704925537109, 298.819091796875), X14 = c(294.654327392578,
296.722717285156, 297.0986328125, 296.508239746094, 297.822021484375
), X15 = c(292.176361083984, 294.49658203125, 293.888305664062,
294.172149658203, 296.117095947266), X16 = c(288.400726318359,
291.029113769531, 289.361907958984, 290.566772460938, 293.554016113281
), X17 = c(285.665222167969, 288.293029785156, 286.118957519531,
288.105285644531, 291.429382324219), X18 = c(285.971252441406,
288.3798828125, 286.444580078125, 288.495880126953, 291.447326660156
), X19 = c(288.79296875, 290.357543945312, 289.657928466797,
291.449066162109, 293.095275878906), X20 = c(291.999877929688,
292.838348388672, 293.840362548828, 294.412322998047, 294.941253662109
), X21 = c(293.615447998047, 294.028106689453, 296.072296142578,
296.447387695312, 295.824615478516), X22 = c(294.719848632812,
295.392028808594, 297.453216552734, 297.114288330078, 296.883209228516
), X23 = c(295.634429931641, 296.783294677734, 298.592346191406,
297.469512939453, 297.832122802734)), .Names = c("X0", "X1",
"X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "X11",
"X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19", "X20",
"X21", "X22", "X23"), row.names = c(NA, 5L), class = "data.frame")


Mail
priva di virus. www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

[[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] JGR not installed. Attempting to install from CRAN...

2018-02-20 Thread Jenny Coetzee
thanks Loris

you are bering so helpful!

So, i have done what you explained, but the RDS package that runs “using or 
through” R is now just closing each time i open it. I have googled and seen 
that i need to to the following:

 Tips: The recent updates to the Apple Mac OS (Sierra and High Sierra) have 
reorganized the ways apps, like RDS Analyst, work. So sometimes RDS Analyst 
will not be configured correctly and will not start (e.g., bouncing icon or no 
response to double clicking). Most of these relate to how Java works on the 
Mac. The first thing to try is to open the Terminal and type in :
R CMD javareconf
This asks R to check on the configuration of Java and try to get in sync with 
it.
off website:
http://wiki.stat.ucla.edu/hpmrg/index.php/RDS_Analyst_Install


BUT, when i do enter  R CMD javareconf, i get the following error:
Error: unexpected symbol in "R CMD”

so what should i do now?

thanks


Jen





Jenny Coetzee (PhD Candidate)
Head of Prevention in Key Populations & Head of the Soweto Sex Worker Project
Perinatal HIV Research Unit (PHRU)
New Nurses Home
Chris Hani Baragwanath Academic Hospital
Soweto

B: +27 11 989 9821
M: +27 84 761 1193
E: coetz...@phru.co.za

"Here's to the crazy ones, the misfits, the rebels, the troublemakers, the 
round pegs in the square holes ... the ones who see things differently - 
they're not fond of rules, and they have no respect for the status quo. ... You 
can quote them, disagree with them, glorify or vilify them, but the only thing 
you can't do is ignore them because they change things. ... They push the human 
race forward, and while some may see them as the crazy ones, we see genius, 
because the people who are crazy enough to think that they can change the 
world, are the ones who do."
(Steve Jobs)

On 20 Feb 2018, at 10:05, Loris Bennett 
> wrote:

Hi Jenny,

Jenny Coetzee > writes:

Loris, thank you thank you so much!!!

do you know which CRAN mirror i select? There are loads - all related to 
various countries..

so appreciate the help

It shouldn't really matter, although I'd choose one that is
geographically close.  Occasionally there can be problems with HTTP
vs. HTTPS, which can lead to spurious errors about a packages not being
available for your version of R.  Because R caches the mirror, if you
run into any issues you might have to exit R and start again.

Cheers,

Loris

--
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email 
loris.benn...@fu-berlin.de


[[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] JGR not installed. Attempting to install from CRAN...

2018-02-20 Thread Loris Bennett
Jenny Coetzee  writes:

> thanks Loris 
>
> you are bering so helpful!
>
> So, i have done what you explained, but the RDS package that runs
> “using or through” R is now just closing each time i open it. I have
> googled and seen that i need to to the following:
>
> Tips: The recent updates to the Apple Mac OS (Sierra and High Sierra)
> have reorganized the ways apps, like RDS Analyst, work. So sometimes
> RDS Analyst will not be configured correctly and will not start (e.g.,
> bouncing icon or no response to double clicking). Most of these relate
> to how Java works on the Mac. The first thing to try is to open the
> Terminal and type in : R CMD javareconf This asks R to check on the
> configuration of Java and try to get in sync with it.  off website:
> http://wiki.stat.ucla.edu/hpmrg/index.php/RDS_Analyst_Install
>
> BUT, when i do enter R CMD javareconf, i get the following error:
> Error: unexpected symbol in "R CMD”
>
> so what should i do now?

I'll have to guess now, because I don't know much about Macs or Java.  I
assume there is something wrong with your java installation.  You can
check by writing the following in a terminal:

  java -version

If the output of this isn't something sensible, then you probably need
to (re-)install Java.

Otherwise there is some information here (Point 3. "Configure Java for
R"):

  
https://www.ibm.com/support/knowledgecenter/en/SSPT3X_3.0.0/com.ibm.swg.im.infosphere.biginsights.install.doc/doc/install_install_r.html

If that doesn't help (and probably even if it does) you should consider
joining the RDS Users Group, if you haven't already:

  http://wiki.stat.ucla.edu/hpmrg/index.php/RDS_Analyst_Users_Group

Cheers,

Loris

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de

__
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] JGR not installed. Attempting to install from CRAN...

2018-02-20 Thread Michael Dewey

Dear Jenny

From your email address I would have thought one of the two South 
African ones would be best. In the unlikely event of your chosen mirror 
not being up-to-date, try another one.


Michael

On 20/02/2018 07:55, Jenny Coetzee wrote:

Loris, thank you thank you so much!!!

do you know which CRAN mirror i select? There are loads - all related to 
various countries..

so appreciate the help

Jenny




Jenny Coetzee (PhD Candidate)
Head of Prevention in Key Populations & Head of the Soweto Sex Worker Project
Perinatal HIV Research Unit (PHRU)
New Nurses Home
Chris Hani Baragwanath Academic Hospital
Soweto

B: +27 11 989 9821
M: +27 84 761 1193
E: coetz...@phru.co.za

"Here's to the crazy ones, the misfits, the rebels, the troublemakers, the round 
pegs in the square holes ... the ones who see things differently - they're not fond of 
rules, and they have no respect for the status quo. ... You can quote them, disagree with 
them, glorify or vilify them, but the only thing you can't do is ignore them because they 
change things. ... They push the human race forward, and while some may see them as the 
crazy ones, we see genius, because the people who are crazy enough to think that they can 
change the world, are the ones who do."
(Steve Jobs)

On 20 Feb 2018, at 09:16, Loris Bennett 
> wrote:

Hi Jenny,

Jenny Coetzee > writes:

Hello

I am new to R, and am running a programme called RDS Analyst which
uses R. When trying to open RDS i am getting the following message:
JGR not installed. Attempting to install from CRAN…

I am not sure if the issue is a Java one or an R one…

I am working off a Mac using High Sierra

Any help please..?

Here

  http://rforge.net/JGR/

it says that you need two bits: the R package from CRAN and the launcher
for MacOS.  You should be able to install the R package using

  install.packages("JGR")

from the R shell and the launcher just like a regular binary.

Cheers,

Loris

--
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email 
loris.benn...@fu-berlin.de


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



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
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] JGR not installed. Attempting to install from CRAN...

2018-02-20 Thread Jenny Coetzee
Loris, thank you thank you so much!!!

do you know which CRAN mirror i select? There are loads - all related to 
various countries..

so appreciate the help

Jenny




Jenny Coetzee (PhD Candidate)
Head of Prevention in Key Populations & Head of the Soweto Sex Worker Project
Perinatal HIV Research Unit (PHRU)
New Nurses Home
Chris Hani Baragwanath Academic Hospital
Soweto

B: +27 11 989 9821
M: +27 84 761 1193
E: coetz...@phru.co.za

"Here's to the crazy ones, the misfits, the rebels, the troublemakers, the 
round pegs in the square holes ... the ones who see things differently - 
they're not fond of rules, and they have no respect for the status quo. ... You 
can quote them, disagree with them, glorify or vilify them, but the only thing 
you can't do is ignore them because they change things. ... They push the human 
race forward, and while some may see them as the crazy ones, we see genius, 
because the people who are crazy enough to think that they can change the 
world, are the ones who do."
(Steve Jobs)

On 20 Feb 2018, at 09:16, Loris Bennett 
> wrote:

Hi Jenny,

Jenny Coetzee > writes:

Hello

I am new to R, and am running a programme called RDS Analyst which
uses R. When trying to open RDS i am getting the following message:
JGR not installed. Attempting to install from CRAN…

I am not sure if the issue is a Java one or an R one…

I am working off a Mac using High Sierra

Any help please..?

Here

 http://rforge.net/JGR/

it says that you need two bits: the R package from CRAN and the launcher
for MacOS.  You should be able to install the R package using

 install.packages("JGR")

from the R shell and the launcher just like a regular binary.

Cheers,

Loris

--
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email 
loris.benn...@fu-berlin.de


[[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] JGR not installed. Attempting to install from CRAN...

2018-02-20 Thread Loris Bennett
Hi Jenny,

Jenny Coetzee  writes:

> Loris, thank you thank you so much!!! 
>
> do you know which CRAN mirror i select? There are loads - all related to 
> various countries..
>
> so appreciate the help

It shouldn't really matter, although I'd choose one that is
geographically close.  Occasionally there can be problems with HTTP
vs. HTTPS, which can lead to spurious errors about a packages not being
available for your version of R.  Because R caches the mirror, if you
run into any issues you might have to exit R and start again.

Cheers,

Loris

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de

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