Re: [R] Increasing space for main title in a lattice (xyplot()) graphics.

2020-02-12 Thread Deepayan Sarkar
Hi Bert,

You are right that the general solution is for 'main' to be a (grid)
grob. It is not clear (to me) what the "height" of a textGrob with
multiple labels should be, but the following gives reasonable results:

xyplot(1 ~ 1,
   main = textGrob(c("The quick brown fox jumped", "over the lazy dog"),
   x = unit(0.5, "npc"), y = unit(c(0.75, 0.25), "cm")))

I'm guessing your first attempt was with the default units ("npc") for y.

The correct grob (allowing more detailed control) to use for complex
grid objects is a frameGrob.

lattice does have an interface to create (simple) frameGrobs, for
constructing legends. This can be (ab)used as follows:

xyplot(1 ~ 1,
   main = draw.key(key = list(text = list(c("The quick brown fox jumped",
"over the lazy dog"),
  font = c(1, 2), col = c(2, 3)

-Deepayan

On Thu, Feb 13, 2020 at 11:36 AM Bert Gunter  wrote:
>
> OK. Now for a tougher problem: how to make the first line bold font and the 
> second line normal font (and/or different colors)?
>
> My reading of the docs did not reveal how to do it, but I found a way using a 
> textGrob for the title (i.e. main ). But it's tricky, as the "obvious 
> solution" of using different y values for the lines caused lattice to enlarge 
> the title viewport too much, shrinking the graph panels so that details were 
> lost. I think I have found a way to avoid this and make it work, but I'll 
> delay giving my somewhat clumsy "solution" until some of you have a chance to 
> find a more sensible approach, if you care to try.
>
> 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 Wed, Feb 12, 2020 at 9:19 PM Deepayan Sarkar  
> wrote:
>>
>> On Thu, Feb 13, 2020 at 10:39 AM Richard M. Heiberger  
>> wrote:
>> >
>> > It works as anticipated for me
>> >
>> > > xyplot(1 ~ 1,
>> > + main="The quick brown fox jumped\n over the lazy dog.")
>> > > xyplot(1 ~ 1,
>> > + main="The quick brown fox jumped over the lazy dog.")
>> >
>> > Something else you are doing is probably causing the difficulty.
>>
>> Yes, the necessary space should be automatically allocated. Details of
>> version / device might help diagnosing the problem.
>>
>> -Deepayan
>>
>> >
>> > Rich
>> >
>> > On Wed, Feb 12, 2020 at 11:59 PM Rolf Turner  
>> > wrote:
>> > >
>> > >
>> > > I'm trying to do an xyplot() with a longish main title that I'd like to
>> > > split into two lines, something like
>> > >
>> > >  xyplot(,
>> > > main="The quick brown fox jumped\n over the lazy dog.")
>> > >
>> > > When I do this I only get the last half, i.e. the "over the lazy dog."
>> > > bit, and the first half doesn't appear.
>> > >
>> > > In base graphics I'd handle this sort of thing by increasing the third
>> > > entry of the "mar" parameter.
>> > >
>> > > How can increase the space allocated for the title in lattice graphics?
>> > > I've done a substantial amount of Googling and can't find anything
>> > > helpful.  I've fiddled about with trellis.par.set() and cannot seem to
>> > > get any effect.
>> > >
>> > > Could someone please give my poor feeble brain some guidance?  Ta.
>> > >
>> > > cheers,
>> > >
>> > > Rolf Turner
>> > >
>> > > --
>> > > Honorary Research Fellow
>> > > 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

__
R-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] Increasing space for main title in a lattice (xyplot()) graphics.

2020-02-12 Thread Bert Gunter
OK. Now for a tougher problem: how to make the first line bold font and the
second line normal font (and/or different colors)?

My reading of the docs did not reveal how to do it, but I found a way using
a textGrob for the title (i.e. main ). But it's tricky, as the "obvious
solution" of using different y values for the lines caused lattice to
enlarge the title viewport too much, shrinking the graph panels so that
details were lost. I think I have found a way to avoid this and make it
work, but I'll delay giving my somewhat clumsy "solution" until some of you
have a chance to find a more sensible approach, if you care to try.

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 Wed, Feb 12, 2020 at 9:19 PM Deepayan Sarkar 
wrote:

> On Thu, Feb 13, 2020 at 10:39 AM Richard M. Heiberger 
> wrote:
> >
> > It works as anticipated for me
> >
> > > xyplot(1 ~ 1,
> > + main="The quick brown fox jumped\n over the lazy dog.")
> > > xyplot(1 ~ 1,
> > + main="The quick brown fox jumped over the lazy dog.")
> >
> > Something else you are doing is probably causing the difficulty.
>
> Yes, the necessary space should be automatically allocated. Details of
> version / device might help diagnosing the problem.
>
> -Deepayan
>
> >
> > Rich
> >
> > On Wed, Feb 12, 2020 at 11:59 PM Rolf Turner 
> wrote:
> > >
> > >
> > > I'm trying to do an xyplot() with a longish main title that I'd like to
> > > split into two lines, something like
> > >
> > >  xyplot(,
> > > main="The quick brown fox jumped\n over the lazy dog.")
> > >
> > > When I do this I only get the last half, i.e. the "over the lazy dog."
> > > bit, and the first half doesn't appear.
> > >
> > > In base graphics I'd handle this sort of thing by increasing the third
> > > entry of the "mar" parameter.
> > >
> > > How can increase the space allocated for the title in lattice graphics?
> > > I've done a substantial amount of Googling and can't find anything
> > > helpful.  I've fiddled about with trellis.par.set() and cannot seem to
> > > get any effect.
> > >
> > > Could someone please give my poor feeble brain some guidance?  Ta.
> > >
> > > cheers,
> > >
> > > Rolf Turner
> > >
> > > --
> > > Honorary Research Fellow
> > > 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-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.
>

[[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] Increasing space for main title in a lattice (xyplot()) graphics.

2020-02-12 Thread Deepayan Sarkar
On Thu, Feb 13, 2020 at 10:39 AM Richard M. Heiberger  wrote:
>
> It works as anticipated for me
>
> > xyplot(1 ~ 1,
> + main="The quick brown fox jumped\n over the lazy dog.")
> > xyplot(1 ~ 1,
> + main="The quick brown fox jumped over the lazy dog.")
>
> Something else you are doing is probably causing the difficulty.

Yes, the necessary space should be automatically allocated. Details of
version / device might help diagnosing the problem.

-Deepayan

>
> Rich
>
> On Wed, Feb 12, 2020 at 11:59 PM Rolf Turner  wrote:
> >
> >
> > I'm trying to do an xyplot() with a longish main title that I'd like to
> > split into two lines, something like
> >
> >  xyplot(,
> > main="The quick brown fox jumped\n over the lazy dog.")
> >
> > When I do this I only get the last half, i.e. the "over the lazy dog."
> > bit, and the first half doesn't appear.
> >
> > In base graphics I'd handle this sort of thing by increasing the third
> > entry of the "mar" parameter.
> >
> > How can increase the space allocated for the title in lattice graphics?
> > I've done a substantial amount of Googling and can't find anything
> > helpful.  I've fiddled about with trellis.par.set() and cannot seem to
> > get any effect.
> >
> > Could someone please give my poor feeble brain some guidance?  Ta.
> >
> > cheers,
> >
> > Rolf Turner
> >
> > --
> > Honorary Research Fellow
> > 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-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] Increasing space for main title in a lattice (xyplot()) graphics.

2020-02-12 Thread Richard M. Heiberger
It works as anticipated for me

> xyplot(1 ~ 1,
+ main="The quick brown fox jumped\n over the lazy dog.")
> xyplot(1 ~ 1,
+ main="The quick brown fox jumped over the lazy dog.")

Something else you are doing is probably causing the difficulty.

Rich

On Wed, Feb 12, 2020 at 11:59 PM Rolf Turner  wrote:
>
>
> I'm trying to do an xyplot() with a longish main title that I'd like to
> split into two lines, something like
>
>  xyplot(,
> main="The quick brown fox jumped\n over the lazy dog.")
>
> When I do this I only get the last half, i.e. the "over the lazy dog."
> bit, and the first half doesn't appear.
>
> In base graphics I'd handle this sort of thing by increasing the third
> entry of the "mar" parameter.
>
> How can increase the space allocated for the title in lattice graphics?
> I've done a substantial amount of Googling and can't find anything
> helpful.  I've fiddled about with trellis.par.set() and cannot seem to
> get any effect.
>
> Could someone please give my poor feeble brain some guidance?  Ta.
>
> cheers,
>
> Rolf Turner
>
> --
> Honorary Research Fellow
> 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-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] Increasing space for main title in a lattice (xyplot()) graphics.

2020-02-12 Thread Rolf Turner



I'm trying to do an xyplot() with a longish main title that I'd like to 
split into two lines, something like


xyplot(,
   main="The quick brown fox jumped\n over the lazy dog.")

When I do this I only get the last half, i.e. the "over the lazy dog."
bit, and the first half doesn't appear.

In base graphics I'd handle this sort of thing by increasing the third 
entry of the "mar" parameter.


How can increase the space allocated for the title in lattice graphics?
I've done a substantial amount of Googling and can't find anything 
helpful.  I've fiddled about with trellis.par.set() and cannot seem to

get any effect.

Could someone please give my poor feeble brain some guidance?  Ta.

cheers,

Rolf Turner

--
Honorary Research Fellow
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.


Re: [R] make check fails -- how to debug

2020-02-12 Thread Duncan Murdoch

On 12/02/2020 4:42 p.m., Ivan Krylov wrote:

On Wed, 12 Feb 2020 19:32:34 +
"Barris, Wes"  wrote:


I'm only trying to install the latest version on our servers for our
users.


Are you allowed to use EPEL? This seems to be the officialy supported
way of installing latest R on CentOS [1]. It might be a good idea to
ask in R-SIG-Fedora [2] instead of R-help, too.


Is this what I need to type?


The following command should more or less reproduce the test:

cd "$(mktemp -d)"

/usr/local/src/stats/R-3.6.2/CentOS/bin/R CMD build \
   --keep-empty-dirs /usr/local/src/stats/R-3.6.2/CentOS/tests/Pkgs/exSexpr

But the problem seems evident even without that.


Note: I've installed the (many) rpms for texlive so that pdflatex is
available.  Unfortunately, the same test continues to fail.  Here is
the latest log:


<...>


! LaTeX Error: File `inconsolata.sty' not found.


Not sure whether Inconsolata [3] is packaged for CentOS, but it seems
to be required to build the documentation. It might be possible to
disable the use of this font [4], but I don't understand enough LaTeX
to comment on it further.

Either way, people on R-SIG-Fedora should be able to provide better
help installing latest R on a CentOS server than me.


I just had a similar error on Ubuntu.  Inconsolata is not a standard 
TeXLive font, on Ubuntu you need to install texlive-fonts-extra to get it.


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] Aggregate individual level data to age categories

2020-02-12 Thread stefan.d...@gmail.com
Thank you!
This is exactly what I was looking for!
Cheers!


On Wed, Feb 12, 2020 at 11:29 PM Jim Lemon  wrote:
>
> Hi Stefan,
> How about this:
>
> sddf<-read.table(text="age x
> 45   1
> 45   2
> 46   1
> 47   3
> 47   3",
> header=TRUE)
> library(prettyR)
> sdtab<-xtab(age~x,sddf)
> sdtab$counts
>
> Jim
>
> On Thu, Feb 13, 2020 at 7:40 AM stefan.d...@gmail.com
>  wrote:
> >
> > Dear All,
> >
> > I have a seemingly standard problem to which I somehow I do  not find
> > a simple solution. I have individual level data where x is a
> > categorical variable with 3 categories which I would like to aggregate
> > by age.
> >
> > age x
> > 45   1
> > 45   2
> > 46   1
> > 47   3
> > 47   3
> >  and so on.
> >
> > It should after transformation look like that
> >
> > age x_1 x_2 x_3
> > 451 0   1
> > 461 0   0
> > 47 00   2
> >
> > Basically to calculate prevalences by age categories.
> >
> > Thanks for any pointers!
> >
> > Cheers!
> >
> > __
> > 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] Aggregate individual level data to age categories

2020-02-12 Thread Jim Lemon
Hi Stefan,
How about this:

sddf<-read.table(text="age x
45   1
45   2
46   1
47   3
47   3",
header=TRUE)
library(prettyR)
sdtab<-xtab(age~x,sddf)
sdtab$counts

Jim

On Thu, Feb 13, 2020 at 7:40 AM stefan.d...@gmail.com
 wrote:
>
> Dear All,
>
> I have a seemingly standard problem to which I somehow I do  not find
> a simple solution. I have individual level data where x is a
> categorical variable with 3 categories which I would like to aggregate
> by age.
>
> age x
> 45   1
> 45   2
> 46   1
> 47   3
> 47   3
>  and so on.
>
> It should after transformation look like that
>
> age x_1 x_2 x_3
> 451 0   1
> 461 0   0
> 47 00   2
>
> Basically to calculate prevalences by age categories.
>
> Thanks for any pointers!
>
> Cheers!
>
> __
> 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] Aggregate individual level data to age categories

2020-02-12 Thread stefan.d...@gmail.com
Thank you, this is already very helpful.

But how do I get it in the form
age  var_x=1  var_x=2  var_x=3
45 1  1 0
46  1  00

So it would be a data frame with 4 variables.

Cheers!

On Wed, Feb 12, 2020 at 10:25 PM William Dunlap  wrote:
>
> You didn't say how you wanted to use it as a data.frame, but here is one way
>
> d <- data.frame(
> check.names = FALSE,
> age = c(45L, 45L, 46L, 47L, 47L),
> x = c(1L, 2L, 1L, 3L, 3L))
> with(d, as.data.frame(table(age,x)))
>
> which gives:
>   age x Freq
> 1  45 11
> 2  46 11
> 3  47 10
> 4  45 21
> 5  46 20
> 6  47 20
> 7  45 30
> 8  46 30
> 9  47 32
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Wed, Feb 12, 2020 at 1:12 PM stefan.d...@gmail.com  
> wrote:
>>
>> well, if I think about, its actually a simple frequency table grouped
>> by age. but it should be usable a matrix or data frame.
>>
>> On Wed, Feb 12, 2020 at 9:48 PM  wrote:
>> >
>> > So a pivot table?
>> >
>> > On 12 Feb 2020 20:39, stefan.d...@gmail.com wrote:
>> >
>> > Dear All,
>> >
>> > I have a seemingly standard problem to which I somehow I do  not find
>> > a simple solution. I have individual level data where x is a
>> > categorical variable with 3 categories which I would like to aggregate
>> > by age.
>> >
>> > age x
>> > 45   1
>> > 45   2
>> > 46   1
>> > 47   3
>> > 47   3
>> > and so on.
>> >
>> > It should after transformation look like that
>> >
>> > age x_1 x_2 x_3
>> > 451 0   1
>> > 461 0   0
>> > 47 00   2
>> >
>> > Basically to calculate prevalences by age categories.
>> >
>> > Thanks for any pointers!
>> >
>> > Cheers!
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>> >
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

__
R-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] make check fails -- how to debug

2020-02-12 Thread Ivan Krylov
On Wed, 12 Feb 2020 19:32:34 +
"Barris, Wes"  wrote:

> I'm only trying to install the latest version on our servers for our
> users.

Are you allowed to use EPEL? This seems to be the officialy supported
way of installing latest R on CentOS [1]. It might be a good idea to
ask in R-SIG-Fedora [2] instead of R-help, too.

> Is this what I need to type?

The following command should more or less reproduce the test:

cd "$(mktemp -d)"

/usr/local/src/stats/R-3.6.2/CentOS/bin/R CMD build \
  --keep-empty-dirs /usr/local/src/stats/R-3.6.2/CentOS/tests/Pkgs/exSexpr

But the problem seems evident even without that.

> Note: I've installed the (many) rpms for texlive so that pdflatex is
> available.  Unfortunately, the same test continues to fail.  Here is
> the latest log:

<...>

> ! LaTeX Error: File `inconsolata.sty' not found.

Not sure whether Inconsolata [3] is packaged for CentOS, but it seems
to be required to build the documentation. It might be possible to
disable the use of this font [4], but I don't understand enough LaTeX
to comment on it further.

Either way, people on R-SIG-Fedora should be able to provide better
help installing latest R on a CentOS server than me.

-- 
Best regards,
Ivan

[1] https://cloud.r-project.org/bin/linux/redhat/README

[2] https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

[3] https://www.ctan.org/tex-archive/fonts/inconsolata/

[4] https://stackoverflow.com/a/34524358

__
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 individual level data to age categories

2020-02-12 Thread William Dunlap via R-help
You didn't say how you wanted to use it as a data.frame, but here is one way

d <- data.frame(
check.names = FALSE,
age = c(45L, 45L, 46L, 47L, 47L),
x = c(1L, 2L, 1L, 3L, 3L))
with(d, as.data.frame(table(age,x)))

which gives:
  age x Freq
1  45 11
2  46 11
3  47 10
4  45 21
5  46 20
6  47 20
7  45 30
8  46 30
9  47 32

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, Feb 12, 2020 at 1:12 PM stefan.d...@gmail.com 
wrote:

> well, if I think about, its actually a simple frequency table grouped
> by age. but it should be usable a matrix or data frame.
>
> On Wed, Feb 12, 2020 at 9:48 PM  wrote:
> >
> > So a pivot table?
> >
> > On 12 Feb 2020 20:39, stefan.d...@gmail.com wrote:
> >
> > Dear All,
> >
> > I have a seemingly standard problem to which I somehow I do  not find
> > a simple solution. I have individual level data where x is a
> > categorical variable with 3 categories which I would like to aggregate
> > by age.
> >
> > age x
> > 45   1
> > 45   2
> > 46   1
> > 47   3
> > 47   3
> > and so on.
> >
> > It should after transformation look like that
> >
> > age x_1 x_2 x_3
> > 451 0   1
> > 461 0   0
> > 47 00   2
> >
> > Basically to calculate prevalences by age categories.
> >
> > Thanks for any pointers!
> >
> > Cheers!
> >
> > __
> > 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.
>

[[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 individual level data to age categories

2020-02-12 Thread stefan.d...@gmail.com
well, if I think about, its actually a simple frequency table grouped
by age. but it should be usable a matrix or data frame.

On Wed, Feb 12, 2020 at 9:48 PM  wrote:
>
> So a pivot table?
>
> On 12 Feb 2020 20:39, stefan.d...@gmail.com wrote:
>
> Dear All,
>
> I have a seemingly standard problem to which I somehow I do  not find
> a simple solution. I have individual level data where x is a
> categorical variable with 3 categories which I would like to aggregate
> by age.
>
> age x
> 45   1
> 45   2
> 46   1
> 47   3
> 47   3
> and so on.
>
> It should after transformation look like that
>
> age x_1 x_2 x_3
> 451 0   1
> 461 0   0
> 47 00   2
>
> Basically to calculate prevalences by age categories.
>
> Thanks for any pointers!
>
> Cheers!
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

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


[R] Aggregate individual level data to age categories

2020-02-12 Thread stefan.d...@gmail.com
Dear All,

I have a seemingly standard problem to which I somehow I do  not find
a simple solution. I have individual level data where x is a
categorical variable with 3 categories which I would like to aggregate
by age.

age x
45   1
45   2
46   1
47   3
47   3
 and so on.

It should after transformation look like that

age x_1 x_2 x_3
451 0   1
461 0   0
47 00   2

Basically to calculate prevalences by age categories.

Thanks for any pointers!

Cheers!

__
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] make check fails -- how to debug

2020-02-12 Thread Barris, Wes
Thanks Ivan.

I would like to manually run the test you mentioned but I don't know how.  I'm 
not an R user.  I'm only trying to install the latest version on our servers 
for our users.  Is this what I need to type?

> pwd
/usr/local/src/stats/R-3.6.2/CentOS

./bin/R CMD ../tests/Pkgs/exSexpr

Note: I've installed the (many) rpms for texlive so that pdflatex is available. 
 Unfortunately, the same test continues to fail.  Here is the latest log:


R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> .R_LIBS <- function(libp = .libPaths()) { # (>> in utils?)
+ libp <- libp[! libp %in% .Library]
+ if(length(libp))
+ paste(libp, collapse = .Platform$path.sep)
+ else "" # character(0) is invalid for Sys.setenv()
+ }
> Sys.setenv(R_LIBS = .R_LIBS() # for build.pkg() & install.packages()
+  , R_BUILD_ENVIRON = "nothing" # avoid ~/.R/build.environ which might 
set R_LIBS
+  , R_ENVIRON = "none"
+  , R_PROFILE = "none"
+)
> 
> ## PR 1271  detach("package:base") crashes R.
> tools::assertError(detach("package:base"))
> 
> 
> ## invalid 'lib.loc'
> stopifnot(length(installed.packages("mgcv")) == 0)
> ## gave a low-level error message
> 
> 
> ## package.skeleton() with metadata-only code
> ## work in current (= ./tests/ directory):
> tmp <- tempfile()
> writeLines(c('setClass("foo", contains="numeric")',
+  'setMethod("show", "foo",',
+  '  function(object) cat("I am a \\"foo\\"\\n"))'),
+tmp)
> if(file.exists("myTst")) unlink("myTst", recursive=TRUE)
> package.skeleton("myTst", code_files = tmp)# with a file name warning
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Copying code files ...
Making help files ...
Done.
Further steps are described in './myTst/Read-and-delete-me'.
Warning message:
In package.skeleton("myTst", code_files = tmp) :
  Invalid file name(s) for R code in ./myTst/R:
  'file40a593b5a60'
 are now renamed to 'z.R'
> file.copy(tmp, (tm2 <- paste(tmp,".R", sep="")))
[1] TRUE
> unlink("myTst", recursive=TRUE)
> op <- options(warn=2) # *NO* "invalid file name" warning {failed in 2.7.[01]}:
> package.skeleton("myTst", code_files = tm2)
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Copying code files ...
Making help files ...
Done.
Further steps are described in './myTst/Read-and-delete-me'.
> options(op)
> ##_2_ only a class, no generics/methods:
> writeLines(c('setClass("DocLink",',
+  'representation(name="character",',
+  '   desc="character"))'), tmp)
> if(file.exists("myTst2")) unlink("myTst2", recursive=TRUE)
> package.skeleton("myTst2", code_files = tmp)
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Copying code files ...
Making help files ...
Done.
Further steps are described in './myTst2/Read-and-delete-me'.
Warning message:
In package.skeleton("myTst2", code_files = tmp) :
  Invalid file name(s) for R code in ./myTst2/R:
  'file40a593b5a60'
 are now renamed to 'z.R'
> ##- end_2_ # failed in R 2.11.0
> stopifnot(1 == grep("setClass",
+ readLines(list.files("myTst/R", full.names=TRUE))),
+ c("foo-class.Rd","show-methods.Rd") %in% list.files("myTst/man"))
> ## failed for several reasons in R < 2.7.0
> ##
> ## Part 2: -- build, install, load and "inspect" the package:
> build.pkg <- function(dir) {
+ stopifnot(dir.exists(dir), file.exists(DESC <- file.path(dir, 
"DESCRIPTION")))
+ pkgName <- sub("^[A-Za-z]+: ", "", grep("^Package: ", readLines(DESC), 
value=TRUE))
+ patt <- paste(pkgName, ".*tar\\.gz$", sep="_")
+ unlink(dir('.', pattern = patt))
+ Rcmd <- paste(shQuote(file.path(R.home("bin"), "R")), "CMD")
+ r <- system(paste(Rcmd, "build --keep-empty-dirs", shQuote(dir)),
+ intern = TRUE)
+ ## return name of tar file built
+ structure(dir('.', pattern = patt), log3 = r)
+ }
> build.pkg("myTst")

[1] "myTst_1.0.tar.gz"
attr(,"log3")
[1] "* checking for file 'myTst/DESCRIPTION' ... OK"   
[2] "* preparing 'myTst':" 
[3] "* checking DESCRIPTION meta-information ... OK"   
[4] "* installing the package to process help pages"   
[5] 

Re: [R] make check fails -- how to debug

2020-02-12 Thread Ivan Krylov
On Wed, 12 Feb 2020 14:20:55 +
"Barris, Wes"  wrote:

> I'm not sure exactly what part of this is the fatal error:

One of the tests is building the package contained in
tests/Pkgs/exSexpr. For some reason, R CMD build failed to produce a
tarball for this package. Try running it yourself and see if it
produces any errors. I don't know for sure whether not being able to
run pdflatex is a blocker when building a package.

-- 
Best regards,
Ivan

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


Re: [R-es] Añadir leyenda a un gráfico con eje secundario en ggplot

2020-02-12 Thread Álvaro Hernández Vicente
Hola, Raúl:

Lo de poner las líneas correspondientes lo tienes ya, solo que has 
escrito "nueva" en lugar de "actual" que es como has llamado a esa variable.

Y si quieres poner una leyenda para el color de la línea lo puedes hacer 
de dos formas: pasando el data.frame a formato largo ("actual" y 
"propuesta" en una misma variable) o bien añadiéndola tú manualmente. No 
está relacionada con tener un eje secundario.

En el primer caso puedes hacer:

resumen %>%
   pivot_longer(cols = actual:propuesta, names_to = "Variable", values_to = 
"Valor") %>%
   ggplot(aes(x = factor(ejex))) +
   geom_col(data = resumen, aes(y = peso), fill = "yellow", alpha = 0.5) +
   geom_line(aes(y = (Valor*10), color = Variable, group = Variable)) +
   scale_y_continuous(sec.axis = sec_axis(~./10), name = "") +
   labs(y = "")

Y para añadirla manualmente puedes hacer:

ggplot(resumen, aes(x = factor(ejex), group = 1)) +  geom_col(aes(y = 
peso), fill = "yellow", alpha = 0.5) +  geom_line(aes(y = actual*10, 
color = "Actual")) +  geom_line(aes(y = propuesta*10, color = 
"Propuesta")) +  scale_y_continuous(sec.axis = sec_axis(~./10), name = 
"") +  scale_color_manual(values = c("Actual" = "red", "Propuesta" = 
"blue"))

Un saludo
Álvaro

El 12/2/20 a las 14:55, Raúl Vaquerizo escribió:
> Hola,
>
> Me he dado cuenta que no soy capaz de añadir la leyenda a un gráfico 
> con eje secundario en ggplot2. Os paso un ejemplo reproducible para 
> ver si alguno puede ayudarme:
>
> ejex <- seq(1:20)
> peso <- rnorm(20,mean=1000,sd=300)
> actual <- rgamma(20,shape=seq(200,20, length.out = 20))
> propuesta <- actual + rnorm(20,3,3)
>
> resumen <- cbind.data.frame(ejex, peso, actual, propuesta)
>
> g2 <- ggplot(resumen, aes(x=factor(ejex))) +
>   geom_col(aes(y=peso),fill="yellow",alpha=0.5) +
>   geom_line(aes(y=actual*10), group=1, color="red") +
>   geom_line(aes(y=nueva*10), group=1, color="blue") +
>   scale_y_continuous(sec.axis = sec_axis(~./10), name="")
> g2
>
> Necesito poner las líneas correspondientes a las variables actual y 
> propuesta. Nada más, pero tras varios intentos, exabruptos, scales y 
> demás ggplot me está derrotando. Gracias.
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es

[[alternative HTML version deleted]]

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


Re: [R] make check fails -- how to debug

2020-02-12 Thread Barris, Wes
Thanks Ivan.  Here is the contents of reg-packages.Rout.fail.  I'm not sure 
exactly what part of this is the fatal error:



R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> .R_LIBS <- function(libp = .libPaths()) { # (>> in utils?)
+ libp <- libp[! libp %in% .Library]
+ if(length(libp))
+ paste(libp, collapse = .Platform$path.sep)
+ else "" # character(0) is invalid for Sys.setenv()
+ }
> Sys.setenv(R_LIBS = .R_LIBS() # for build.pkg() & install.packages()
+  , R_BUILD_ENVIRON = "nothing" # avoid ~/.R/build.environ which might 
set R_LIBS
+  , R_ENVIRON = "none"
+  , R_PROFILE = "none"
+)
> 
> ## PR 1271  detach("package:base") crashes R.
> tools::assertError(detach("package:base"))
> 
> 
> ## invalid 'lib.loc'
> stopifnot(length(installed.packages("mgcv")) == 0)
> ## gave a low-level error message
> 
> 
> ## package.skeleton() with metadata-only code
> ## work in current (= ./tests/ directory):
> tmp <- tempfile()
> writeLines(c('setClass("foo", contains="numeric")',
+  'setMethod("show", "foo",',
+  '  function(object) cat("I am a \\"foo\\"\\n"))'),
+tmp)
> if(file.exists("myTst")) unlink("myTst", recursive=TRUE)
> package.skeleton("myTst", code_files = tmp)# with a file name warning
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Copying code files ...
Making help files ...
Done.
Further steps are described in './myTst/Read-and-delete-me'.
Warning message:
In package.skeleton("myTst", code_files = tmp) :
  Invalid file name(s) for R code in ./myTst/R:
  'file62e012b0d16'
 are now renamed to 'z.R'
> file.copy(tmp, (tm2 <- paste(tmp,".R", sep="")))
[1] TRUE
> unlink("myTst", recursive=TRUE)
> op <- options(warn=2) # *NO* "invalid file name" warning {failed in 2.7.[01]}:
> package.skeleton("myTst", code_files = tm2)
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Copying code files ...
Making help files ...
Done.
Further steps are described in './myTst/Read-and-delete-me'.
> options(op)
> ##_2_ only a class, no generics/methods:
> writeLines(c('setClass("DocLink",',
+  'representation(name="character",',
+  '   desc="character"))'), tmp)
> if(file.exists("myTst2")) unlink("myTst2", recursive=TRUE)
> package.skeleton("myTst2", code_files = tmp)
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Copying code files ...
Making help files ...
Done.
Further steps are described in './myTst2/Read-and-delete-me'.
Warning message:
In package.skeleton("myTst2", code_files = tmp) :
  Invalid file name(s) for R code in ./myTst2/R:
  'file62e012b0d16'
 are now renamed to 'z.R'
> ##- end_2_ # failed in R 2.11.0
> stopifnot(1 == grep("setClass",
+ readLines(list.files("myTst/R", full.names=TRUE))),
+ c("foo-class.Rd","show-methods.Rd") %in% list.files("myTst/man"))
> ## failed for several reasons in R < 2.7.0
> ##
> ## Part 2: -- build, install, load and "inspect" the package:
> build.pkg <- function(dir) {
+ stopifnot(dir.exists(dir), file.exists(DESC <- file.path(dir, 
"DESCRIPTION")))
+ pkgName <- sub("^[A-Za-z]+: ", "", grep("^Package: ", readLines(DESC), 
value=TRUE))
+ patt <- paste(pkgName, ".*tar\\.gz$", sep="_")
+ unlink(dir('.', pattern = patt))
+ Rcmd <- paste(shQuote(file.path(R.home("bin"), "R")), "CMD")
+ r <- system(paste(Rcmd, "build --keep-empty-dirs", shQuote(dir)),
+ intern = TRUE)
+ ## return name of tar file built
+ structure(dir('.', pattern = patt), log3 = r)
+ }
> build.pkg("myTst")

[1] "myTst_1.0.tar.gz"
attr(,"log3")
[1] "* checking for file 'myTst/DESCRIPTION' ... OK"   
[2] "* preparing 'myTst':" 
[3] "* checking DESCRIPTION meta-information ... OK"   
[4] "* installing the package to process help pages"   
[5] "* saving partial Rd database" 
[6] "* checking for LF line-endings in source and make files and shell scripts"
[7] "* checking for empty or unneeded directories" 
[8] "* building 'myTst_1.0.tar.gz'"
> ## clean 

[R] Course: Zero-inflated models using R-INLA

2020-02-12 Thread Highland Statistics Ltd


We would like to announce the following statistics course.

Course: Introduction to zero-inflated models using R-INLA

Where and when: NAIT, Edmonton, Canada. 23 - 26 March 2020

Course website: http://highstat.com/index.php/courses-upcoming
Course flyer: 
http://highstat.com/Courses/Flyers/2020/Flyer2020_03NAIT_ZI.pdf

Kind regards,


Alain Zuur

-- 

Dr. Alain F. Zuur
Highland Statistics Ltd.
9 St Clair Wynd
AB41 6DZ Newburgh, UK
Email: highs...@highstat.com
URL: www.highstat.com


[[alternative HTML version deleted]]

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


Re: [R] make check fails -- how to debug

2020-02-12 Thread Ivan Krylov
On Tue, 11 Feb 2020 21:26:33 +
"Barris, Wes"  wrote:

> running code in '../../tests/reg-packages.R' ...make[3]: ***
> [reg-packages.Rout] Error 1

tests/Makefile.common has the following in the .R.Rout rule:

@$(ECHO) $(ECHO_N) "running code in '$<' ...$(ECHO_C)" > $@.log
@$(R) < $< > $@.fail 2>&1 || (cat $@.log && rm $@.log && exit 1)

> How can I troubleshoot this to find out what is wrong?

Take a look at tests/reg-packages.Rout.fail, it should contain all
output produced by tests/reg-packages.R when it ran.

-- 
Best regards,
Ivan

__
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] make check fails -- how to debug

2020-02-12 Thread Duncan Murdoch

On 11/02/2020 4:26 p.m., Barris, Wes wrote:

I am trying to build R-3.6.2 on a Linux system running CentOS 7.7.1908.  "make 
check" fails.  How can I troubleshoot this to find out what is wrong?

R_PAPERSIZE=letter
cd R-3.6.2
mkdir CentOS
../configure --with-x=no --enable-R-shlib
make
make check
.
.
.
running code in '../../tests/array-subset.R' ... OK
running code in '../../tests/reg-tests-1a.R' ... OK
running code in '../../tests/reg-tests-1b.R' ... OK
running code in '../../tests/reg-tests-1c.R' ... OK
running code in '../../tests/reg-tests-1d.R' ... OK
running code in '../../tests/reg-tests-2.R' ... OK
   comparing 'reg-tests-2.Rout' to '../../tests/reg-tests-2.Rout.save' ... OK
running code in '../../tests/reg-examples1.R' ... OK
running code in '../../tests/reg-examples2.R' ... OK
running code in '../../tests/reg-packages.R' ...make[3]: *** 
[reg-packages.Rout] Error 1
make[3]: Leaving directory `/usr/local/src/stats/R-3.6.2/CentOS/tests'
make[2]: *** [test-Reg] Error 2
make[2]: Leaving directory `/usr/local/src/stats/R-3.6.2/CentOS/tests'
make[1]: *** [test-all-basics] Error 1
make[1]: Leaving directory `/usr/local/src/stats/R-3.6.2/CentOS/tests'
make: *** [check] Error 2



At the end of that run, you'll see the log of the failed test in 
tests/reg-packages.Rout.fail (or some name a lot like that).  You'll 
have to figure out why it failed from that log.


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.