Re: [R] annotation help in ggplot2

2019-09-20 Thread Moshiur Rahman
Thanks everyone especially Rishi to solve
this issue

Regards,

Moshichi

On Fri, Sep 20, 2019 at 22:26 Jeff Newmiller 
wrote:

> Using this list as a labor pool to procure code for generating
> publication-quality plots is abuse. Please read the Posting Guide and the
> documentation for the ggplot package or go pay someone offlist for their
> services.
>
> On September 20, 2019 4:15:18 AM PDT, Moshiur Rahman <
> mrahmankuf...@gmail.com> wrote:
> >Thanks a lot Rishi for your very cordial effort and great help. But
> >still I
> >need some help to improve it as the plot doesn't clearly depict which
> >female belongs to which family and this can be detected by drawing a
> >line
> >from 1-4 for F1, 5-8 for F2
> >
> >Another problem I can see that the position of MID (P1,2,3...) is not
> >looking well which are somehow noisy.
> >
> >Finally, can we drop the bars at the bottom of x-axis that I did
> >with scale_y_continuous?
> >
> >Please do me some favour to complete this plot which I need for a
> >publication.
> >
> >With kind regards,
> >
> >Moshi
> >
> >On Fri, Sep 20, 2019 at 7:45 PM ঋষি ( ऋषि / rIsHi )
> >
> >wrote:
> >
> >> Here is the solution inspired by this post
> >>
> >
> https://stackoverflow.com/questions/18165863/multirow-axis-labels-with-nested-grouping-variables
> >>
> >>
> >> > data$Female <-  factor(data$Female, levels =
> >> c("F1","F2","F3","F4","F5","F6","F7","F8","F9","F10"))
> >> >
> >>
>
> >ggplot(data,aes(x=family,y=offs.surv.perct,fill=treat))+geom_bar(stat="identity",
> >> position="dodge")+
> >>   geom_text(aes(label = MID),  angle=90)+
> >>   facet_wrap(~Female, strip.position = "bottom", scales =
> >"free_x",nrow=1)+
> >>   theme(panel.spacing = unit(0, "lines"),
> >> strip.background = element_blank(),
> >> strip.placement = "outside")
> >>
> >>
> >> On Fri, Sep 20, 2019 at 11:51 AM Moshiur Rahman
> >
> >> wrote:
> >>
> >>> Thanks Rishi,
> >>>
> >>> Please find attached the data herewith.
> >>>
> >>>
> >>>
> >>> On Fri, Sep 20, 2019 at 5:48 PM ঋষি ( ऋषि / rIsHi ) <
> >>> rishi.das...@gmail.com> wrote:
> >>>
>  There are no attached data .
> 
>  On Fri, Sep 20, 2019 at 11:40 AM Moshiur Rahman
> >
>  wrote:
> 
> > Dear ggplot2 experts,
> >
> > I'm struggling to make a plot having family id in x-axis and
> >female id
> > below that family id where each 4 families have a single female
> >id.
> >
> > I also need to add male id on top of each bar which I can do
> >before
> > grid.arrange, but fail after doing it. So, any suggestions?
> >
> > Please find below my codes and help me to complete it perfectly.
> > #data
> > data <- read.table("R-help_ggplot2.csv", header=TRUE, sep=",")
> > names(data)
> > #packages
> > library(ggplot2)
> > library(grid)
> > library(gridExtra)
> > library(scales)
> > library(ggpubr)
> > #plot codes
> > p1 =
> >
> >ggplot(data,aes(x=factor(family),y=offs.surv.perct,fill=factor(treat)))+
> > geom_bar(stat="identity", position="dodge")+
> > #facet_wrap(~ Female)+
> > geom_bar(stat="identity", position="dodge", colour="black",
> > show.legend= TRUE) + # show_guide = TRUE gives legend boarder
> > #geom_hline(yintercept=15, size=0.5, linetype = 2)+ ### middle
> >line
> > scale_fill_manual(values=c("grey", "white")) + # grey80 is
> >closer to
> > white than black
> > xlab("Family") +
> > ylab (expression(paste("Offspring survival rate (%)"))) +
> > #coord_cartesian(xlim=c(0,40), ylim=c(0,60), clip="off")+
> > scale_y_continuous(expand = c(0, 0), limits = c(0, 60))+
> > theme(legend.title = element_text(colour="black", size=12))+
> > theme(legend.text = element_text(colour="black", size=11))+
> > theme(legend.background = element_blank())+
> > theme(legend.key = element_blank())+
> > theme(legend.box.background = element_blank())+
> > theme(legend.key.size = unit(2, "mm"),legend.key.width =
> > unit(0.5,"cm"))+
> > theme(legend.position=c(0.05,0.9),legend.direction
> > ="vertical",legend.box = "vertical")+ # add legend on top
> > theme(panel.background = element_rect(fill = "transparent"))+
> > theme(axis.line = element_line(colour =
> > "black"),axis.text.x=element_text(size=10,
> > colour="black"),axis.text.y=element_text(size=10, colour="black"),
> > axis.title.y = element_text(size=12, colour =
> > "black",margin=margin(0,5,0,0)),
> > axis.title.x = element_blank(),
> > strip.text.x = element_blank(),# remove top level title
> >(high
> > and
> > low)
> > strip.background = element_blank(),# remove top level
> >background
> > panel.grid.major = element_blank(),# remove grid line
> >within the
> > plot
> > panel.grid.minor = element_blank(),
> > panel.border = element_blank())
> 

Re: [R] [SPAM] Re: The "--slave" option

2019-09-20 Thread Richard O'Keefe
Ah, *now* we're getting somewhere.  There is something that *can* be
done that's genuinely helpful.
>From the R(1) manual page:
   -q, --quiet
  Don't print startup message

   --silent
  Same as --quiet

   --slave
  Make R run as quietly as possible

It might have been better to use --nobanner instead of --quiet.  So perhaps

-q, --quiet
Don't print the startup message.  This is the only output that
is suppressed.

--silent
Same as --quiet.  Suppress the startup message only.

--slave
Make R run as quietly as possible.  This is for use when running R as a
subordinate process.  See "Introduction to Sub-Processes in R"
https://cran.r-project.org/web/packages/subprocess/vignettes/intro.html
for an example.

On Sat, 21 Sep 2019 at 02:29, Stephen Ellison  wrote:
>
> > Sure, it's a silly example, but it makes about as much sense as using
> > "slave" to mean "quiet".
> It doesn't. It's a set of options chosen for when R is called as a slave 
> process from a controlling process, and in that it is a reasonable 
> description of the circumstance.
>
> --quiet is a separate command line option with different effect.
>
>
>
>
> ***
> This email and any attachments are confidential. Any u...{{dropped:13}}

__
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] Creating a simple function

2019-09-20 Thread Rui Barradas

Hello,

Something like this?


ctab <- function(data) {
  gmodels::CrossTable(as.matrix(data), prop.chisq = FALSE, prop.c = 
FALSE, prop.t = FALSE, format = "SPSS")

}

mtcars %>% select(cyl, gear) %>% ctab()


Hope this helps,

Rui Barradas

Às 16:30 de 20/09/19, Zachary Lim escreveu:

Hi,

I'm trying to create a simple function that takes a dataframe as its only 
argument. I've been using gmodels::CrossTable, but it requires a lot of 
arguments, e.g.:

#this runs fine
CrossTable(data$col1, data$col2, prop.chisq = FALSE, prop.c = FALSE, prop.t = FALSE, 
format = "SPSS")

Moreover, I wanted to make it compatible with piping, so I decided to create 
the following function:

ctab <- function(data) {
   CrossTable(data[,1], data[,2], prop.chisq = FALSE, prop.c = FALSE, prop.t = FALSE, 
format = "SPSS")
}

When I try to use this function, however, I get the following error:

#this results in 'Error: Must use a vector in `[`, not an object of class 
matrix.'
data %>% select(col1, col2) %>% ctab()

I tried searching online but couldn't find much about that error (except for in 
specific and unrelated cases). Moreover, when I created a very simple dataset, 
it turns out there's no problem:

#this runs fine
data.frame(C1 = c('x','y','x','y'), C2 = c('a','a','b','b')) %>% ctab()


Is this a problem with my function or the data? If it's the data, why does 
directly calling CrossTable work?

Thanks!

Best,
Zach

[[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] Loop With Dates

2019-09-20 Thread Rui Barradas

Hello,

Maybe I am not understanding but isn't this what you have asked in your 
previous question and my 2nd post (adapted) does?

If not, where does it fail?

Hope this helps,

Rui Barradas

Às 18:46 de 20/09/19, Phillip Heinrich escreveu:

With the data snippet below I’m trying to increment the “count” vector by one 
each time the date changes.

  Date count
1   2018-03-29 1
2   2018-03-29 1
3   2018-03-29 1
81  2018-03-30 1
82  2018-03-30 1
83  2018-03-30 1
165 2018-03-31 1
166 2018-03-31 1
167 2018-03-31 1
  
  
 >
  



I can get count to change when the date changes with the following code:

test2 <- transform(test2,
+   count = ifelse(Date == lag(Date,1),count,count+1))

test2

   Date count
1   2018-03-29NA
2   2018-03-29 1
3   2018-03-29 1
81  2018-03-30 2
82  2018-03-30 1
83  2018-03-30 1
165 2018-03-31 2
166 2018-03-31 1
167 2018-03-31 1
  
  


  



...but I want all three March 30 rows to have a count of 2 and the March 31 
rows to be equal to 3.  Any suggestions?

Thanks.
[[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] Loop With Dates

2019-09-20 Thread Ana PGG
Hi Phillip,

This can be done in several ways as most things in programming. Here is one 
posible solution:

dates <- c("2018-03-29", "2018-03-29", "2018-03-29", 
   "2018-03-30", "2018-03-30", "2018-03-30", 
   "2018-03-31", "2018-03-31", "2018-03-31")
dates <- as.data.frame(as.Date(dates))
library(zoo)
dates <- zoo(dates)
colnames(dates) <- "dates"
dates$lag <- lag(dates, -1, na.pad = TRUE)
dates[1, 2] <- dates[1, 1]
dates$count <- cumsum(!(dates$dates == dates$lag)) + 1
dates$lag <- NULL

> dates
  dates.object count
1 2018-03-29   1
2 2018-03-29   1
3 2018-03-29   1
4 2018-03-30   2
5 2018-03-30   2
6 2018-03-30   2
7 2018-03-31   3
8 2018-03-31   3
9 2018-03-31   3


De: Phillip Heinrich
Enviado: viernes, 20 de septiembre de 2019 19:47
Para: r-help
Asunto: [R] Loop With Dates

With the data snippet below I’m trying to increment the “count” vector by one 
each time the date changes.  

 Date count
1   2018-03-29 1
2   2018-03-29 1
3   2018-03-29 1
81  2018-03-30 1
82  2018-03-30 1
83  2018-03-30 1
165 2018-03-31 1
166 2018-03-31 1
167 2018-03-31 1
 
 
>  
 


I can get count to change when the date changes with the following code:

test2 <- transform(test2,
+   count = ifelse(Date == lag(Date,1),count,count+1))
> test2
  Date count
1   2018-03-29NA
2   2018-03-29 1
3   2018-03-29 1
81  2018-03-30 2
82  2018-03-30 1
83  2018-03-30 1
165 2018-03-31 2
166 2018-03-31 1
167 2018-03-31 1
 
 
   

 


...but I want all three March 30 rows to have a count of 2 and the March 31 
rows to be equal to 3.  Any suggestions?

Thanks.
[[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] Creating a simple function

2019-09-20 Thread Duncan Murdoch

On 20/09/2019 11:30 a.m., Zachary Lim wrote:

Hi,

I'm trying to create a simple function that takes a dataframe as its only 
argument. I've been using gmodels::CrossTable, but it requires a lot of 
arguments, e.g.:

#this runs fine
CrossTable(data$col1, data$col2, prop.chisq = FALSE, prop.c = FALSE, prop.t = FALSE, 
format = "SPSS")

Moreover, I wanted to make it compatible with piping, so I decided to create 
the following function:

ctab <- function(data) {
   CrossTable(data[,1], data[,2], prop.chisq = FALSE, prop.c = FALSE, prop.t = FALSE, 
format = "SPSS")
}

When I try to use this function, however, I get the following error:

#this results in 'Error: Must use a vector in `[`, not an object of class 
matrix.'
data %>% select(col1, col2) %>% ctab()

I tried searching online but couldn't find much about that error (except for in 
specific and unrelated cases). Moreover, when I created a very simple dataset, 
it turns out there's no problem:

#this runs fine
data.frame(C1 = c('x','y','x','y'), C2 = c('a','a','b','b')) %>% ctab()


Is this a problem with my function or the data? If it's the data, why does 
directly calling CrossTable work?


Presumably  data %>% select(col1, col2)  isn't giving you a dataframe. 
However, you haven't given us a reproducible example, so I can't tell 
you what it's doing.  But that's where you should look.


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.


[R] Loop With Dates

2019-09-20 Thread Phillip Heinrich
With the data snippet below I’m trying to increment the “count” vector by one 
each time the date changes.  

 Date count
1   2018-03-29 1
2   2018-03-29 1
3   2018-03-29 1
81  2018-03-30 1
82  2018-03-30 1
83  2018-03-30 1
165 2018-03-31 1
166 2018-03-31 1
167 2018-03-31 1
 
 
>  
 


I can get count to change when the date changes with the following code:

test2 <- transform(test2,
+   count = ifelse(Date == lag(Date,1),count,count+1))
> test2
  Date count
1   2018-03-29NA
2   2018-03-29 1
3   2018-03-29 1
81  2018-03-30 2
82  2018-03-30 1
83  2018-03-30 1
165 2018-03-31 2
166 2018-03-31 1
167 2018-03-31 1
 
 
   

 


...but I want all three March 30 rows to have a count of 2 and the March 31 
rows to be equal to 3.  Any suggestions?

Thanks.
[[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] Creating a simple function

2019-09-20 Thread Zachary Lim
Hi,

I'm trying to create a simple function that takes a dataframe as its only 
argument. I've been using gmodels::CrossTable, but it requires a lot of 
arguments, e.g.:

#this runs fine
CrossTable(data$col1, data$col2, prop.chisq = FALSE, prop.c = FALSE, prop.t = 
FALSE, format = "SPSS")

Moreover, I wanted to make it compatible with piping, so I decided to create 
the following function:

ctab <- function(data) {
  CrossTable(data[,1], data[,2], prop.chisq = FALSE, prop.c = FALSE, prop.t = 
FALSE, format = "SPSS")
}

When I try to use this function, however, I get the following error:

#this results in 'Error: Must use a vector in `[`, not an object of class 
matrix.'
data %>% select(col1, col2) %>% ctab()

I tried searching online but couldn't find much about that error (except for in 
specific and unrelated cases). Moreover, when I created a very simple dataset, 
it turns out there's no problem:

#this runs fine
data.frame(C1 = c('x','y','x','y'), C2 = c('a','a','b','b')) %>% ctab()


Is this a problem with my function or the data? If it's the data, why does 
directly calling CrossTable work?

Thanks!

Best,
Zach

[[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: [ESS] Issue with polymode installed from ELPA

2019-09-20 Thread Sparapani, Rodney via ESS-help


> Just to clarify that none of those requires is really needed unless you 
> install polymode and poly-xyz
> from the source and want to load from special locations. If installed from 
> melpa, everything
> (including file associations) should work out of the box. No configuration 
> needed whatsoever.
> Dependencies will be resolved automatically because elpa packages are already 
> in the path.

>  Vitalie

Hi Vitalie:

Well, I hate to burst your bubble.  But, I can assure you, that FOR ME polymode 
does absolutely
nothing if you do not require it.  And I just tested that again.  This problem 
is what inspired my bug
report (see below from 9/9) to which I received no advice ;o(

Thanks,

Rodney

Hi Gang:

I am stumped.  I tried to install polymode from ELPA into Vincent Goulet's
distro of Emacs and ESS (it no longer contains polymode sadly).
macOS 10.14.4 Mojave, Emacs version 26.2 and ESS version 18.10.2
The ELPA install seemed to go well.  My load-path starts with
("/Users/rsparapa/.emacs.d/elpa/poly-R-0.2"
"/Users/rsparapa/.emacs.d/elpa/poly-markdown-0.2"
"/Users/rsparapa/.emacs.d/elpa/markdown-mode-2.3"
"/Users/rsparapa/.emacs.d/elpa/poly-noweb-0.2"
"/Users/rsparapa/.emacs.d/elpa/polymode-0.2" ...
So, everything looks good.  But, I get errors when I put simple requires in
.emacs like (require 'polymode)
So, I hard-coded all of the paths, but this gets hairy since now I have to
hard-code all of the dependencies too ...
(require 'polymode-classes "~/.emacs.d/elpa/polymode-0.2/polymode-classes.el")
(require 'polymode-core "~/.emacs.d/elpa/polymode-0.2/polymode-core.el")
(require 'polymode-compat "~/.emacs.d/elpa/polymode-0.2/polymode-compat.el")
(require 'polymode-methods "~/.emacs.d/elpa/polymode-0.2/polymode-methods.el")
(require 'polymode-export "~/.emacs.d/elpa/polymode-0.2/polymode-export.el")
(require 'polymode-weave "~/.emacs.d/elpa/polymode-0.2/polymode-weave.el")
(require 'polymode-base "~/.emacs.d/elpa/polymode-0.2/polymode-base.el")
(require 'poly-lock "~/.emacs.d/elpa/polymode-0.2/poly-lock.el")
(require 'polymode "~/.emacs.d/elpa/polymode-0.2/polymode.el")
(require 'poly-noweb "~/.emacs.d/elpa/poly-noweb-0.2/poly-noweb.el")
(require 'poly-markdown "~/.emacs.d/elpa/poly-markdown-0.2/poly-markdown.el")
(require 'poly-R "~/.emacs.d/elpa/poly-R-0.2/poly-R.el")
Getting the order of the dependencies right was a pain as well.  However,
brute force fixed it!  But, I don't want to go through this ever again for
obvious reasons.  It took me over an hour for what is supposed to be a 5 or
10 minute install.  Does anyone have an idea of WTF is going wrong here?

Thanks,

Rodney





[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] ESS-help Digest, Vol 199, Issue 3

2019-09-20 Thread Braun, Michael via ESS-help
Understood.  I’m realtively new to emacs customization and lisp (mainly 
learning it to deal with these polymode issues), so I’m still experimenting 
with how it all fits together.  Thanks for pointing this out.




> On Sep 20, 2019, at 5:41 AM, Vitalie Spinu  wrote:
> 
> 
> > (add-to-list 'load-path "~/Library/Preferences/Aquamacs 
> > Emacs/Packages/lisp/")
> > (require 'ess-site)
> > (load "ess-autoloads")  ;; need to register Rnw files
> > (require ‘polymode) ;; version 2.0 now
> > (require 'poly-markdown)
> > (require 'poly-noweb)
> > (require 'poly-R)  ;;
> 
> 
> Just to clarify that none of those requires is really needed unless you 
> install polymode and poly-xyz from the source and want to load from special 
> locations. If installed from melpa, everything (including file associations) 
> should work out of the box. No configuration needed whatsoever. Dependencies 
> will be resolved automatically because elpa packages are already in the path. 
> 
>   Vitalie

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] [SPAM] Re: The "--slave" option

2019-09-20 Thread Stephen Ellison
> Sure, it's a silly example, but it makes about as much sense as using
> "slave" to mean "quiet". 
It doesn't. It's a set of options chosen for when R is called as a slave 
process from a controlling process, and in that it is a reasonable description 
of the circumstance.

--quiet is a separate command line option with different effect.




***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
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] annotation help in ggplot2

2019-09-20 Thread Jeff Newmiller
Using this list as a labor pool to procure code for generating 
publication-quality plots is abuse. Please read the Posting Guide and the 
documentation for the ggplot package or go pay someone offlist for their 
services.

On September 20, 2019 4:15:18 AM PDT, Moshiur Rahman  
wrote:
>Thanks a lot Rishi for your very cordial effort and great help. But
>still I
>need some help to improve it as the plot doesn't clearly depict which
>female belongs to which family and this can be detected by drawing a
>line
>from 1-4 for F1, 5-8 for F2
>
>Another problem I can see that the position of MID (P1,2,3...) is not
>looking well which are somehow noisy.
>
>Finally, can we drop the bars at the bottom of x-axis that I did
>with scale_y_continuous?
>
>Please do me some favour to complete this plot which I need for a
>publication.
>
>With kind regards,
>
>Moshi
>
>On Fri, Sep 20, 2019 at 7:45 PM ঋষি ( ऋषि / rIsHi )
>
>wrote:
>
>> Here is the solution inspired by this post
>>
>https://stackoverflow.com/questions/18165863/multirow-axis-labels-with-nested-grouping-variables
>>
>>
>> > data$Female <-  factor(data$Female, levels =
>> c("F1","F2","F3","F4","F5","F6","F7","F8","F9","F10"))
>> >
>>
>ggplot(data,aes(x=family,y=offs.surv.perct,fill=treat))+geom_bar(stat="identity",
>> position="dodge")+
>>   geom_text(aes(label = MID),  angle=90)+
>>   facet_wrap(~Female, strip.position = "bottom", scales =
>"free_x",nrow=1)+
>>   theme(panel.spacing = unit(0, "lines"),
>> strip.background = element_blank(),
>> strip.placement = "outside")
>>
>>
>> On Fri, Sep 20, 2019 at 11:51 AM Moshiur Rahman
>
>> wrote:
>>
>>> Thanks Rishi,
>>>
>>> Please find attached the data herewith.
>>>
>>>
>>>
>>> On Fri, Sep 20, 2019 at 5:48 PM ঋষি ( ऋषि / rIsHi ) <
>>> rishi.das...@gmail.com> wrote:
>>>
 There are no attached data .

 On Fri, Sep 20, 2019 at 11:40 AM Moshiur Rahman
>
 wrote:

> Dear ggplot2 experts,
>
> I'm struggling to make a plot having family id in x-axis and
>female id
> below that family id where each 4 families have a single female
>id.
>
> I also need to add male id on top of each bar which I can do
>before
> grid.arrange, but fail after doing it. So, any suggestions?
>
> Please find below my codes and help me to complete it perfectly.
> #data
> data <- read.table("R-help_ggplot2.csv", header=TRUE, sep=",")
> names(data)
> #packages
> library(ggplot2)
> library(grid)
> library(gridExtra)
> library(scales)
> library(ggpubr)
> #plot codes
> p1 =
>
>ggplot(data,aes(x=factor(family),y=offs.surv.perct,fill=factor(treat)))+
> geom_bar(stat="identity", position="dodge")+
> #facet_wrap(~ Female)+
> geom_bar(stat="identity", position="dodge", colour="black",
> show.legend= TRUE) + # show_guide = TRUE gives legend boarder
> #geom_hline(yintercept=15, size=0.5, linetype = 2)+ ### middle
>line
> scale_fill_manual(values=c("grey", "white")) + # grey80 is
>closer to
> white than black
> xlab("Family") +
> ylab (expression(paste("Offspring survival rate (%)"))) +
> #coord_cartesian(xlim=c(0,40), ylim=c(0,60), clip="off")+
> scale_y_continuous(expand = c(0, 0), limits = c(0, 60))+
> theme(legend.title = element_text(colour="black", size=12))+
> theme(legend.text = element_text(colour="black", size=11))+
> theme(legend.background = element_blank())+
> theme(legend.key = element_blank())+
> theme(legend.box.background = element_blank())+
> theme(legend.key.size = unit(2, "mm"),legend.key.width =
> unit(0.5,"cm"))+
> theme(legend.position=c(0.05,0.9),legend.direction
> ="vertical",legend.box = "vertical")+ # add legend on top
> theme(panel.background = element_rect(fill = "transparent"))+
> theme(axis.line = element_line(colour =
> "black"),axis.text.x=element_text(size=10,
> colour="black"),axis.text.y=element_text(size=10, colour="black"),
> axis.title.y = element_text(size=12, colour =
> "black",margin=margin(0,5,0,0)),
> axis.title.x = element_blank(),
> strip.text.x = element_blank(),# remove top level title
>(high
> and
> low)
> strip.background = element_blank(),# remove top level
>background
> panel.grid.major = element_blank(),# remove grid line
>within the
> plot
> panel.grid.minor = element_blank(),
> panel.border = element_blank())
> p1
>
> ### legend correction
> p2<- p1 + guides(fill = guide_legend(title="Fertilization
> group",keywidth =
> 1,keyheight = 1,
>  title.theme = element_text(size=12,
>colour
> =
> "black", angle = 0)))+
>   theme(legend.text = element_text(size = 12, colour = "black",
>angle =
> 0))
>
> p2
>
> ###plot margins
> 

Re: [R-es] ggplot con gradientes complejos

2019-09-20 Thread Emilio L. Cano
Mucho más. Si solo es necesario usar dos colores y no gradación, la solución es 
trivial.
Es posible que lo del color central dificulte la visualización, tendría que 
tener datos para probarlo.

Saludos,
Emilio

> El 20 sept 2019, a las 10:48, Carlos Ortega  
> escribió:
> 
> A mí sí que me parece más sencillo que editar el mapa... :-).
> 
> Gracias,
> Carlos.
> 
> El vie., 20 sept. 2019 a las 10:42, Manuel Mendoza 
> (mailto:mmend...@fulbrightmail.org>>) escribió:
> No sé muy bien, Carlos, como hacerlo, pero no parece más sencillo que lo de 
> multiplicar por 2 los positivos y después editar el mapa.
> 
> De lo que decías, Emilio, de cambiar el color del punto central creo que 
> haría más confusa la interpretación.
> 
> El vie., 20 sept. 2019 a las 10:33, Carlos Ortega ( >) escribió:
> Hola,
> 
> Una alternativa que suele funcionar es la de crear una columna adicional en 
> tu dataframe que dé cuenta del color dependiendo de los valores del resto de 
> las variables que tú decidas y utilizar este vector como valor para cada 
> punto, en vez de dejar que sea la función "scale_colour_gradient" la que 
> decida el color...
> 
> Gracias,
> Carlos.
> 
> El vie., 20 sept. 2019 a las 10:30, Manuel Mendoza 
> (mailto:mmend...@fulbrightmail.org>>) escribió:
> Gracias Emilio. Si, son asimétricos porque se mueven en rangos distintos.
> De hecho, miden cosas distintas, pero una muestra no puede ser positiva y
> negativa a la vez. Me planteo multiplicar las positivas por 2 y al editar
> el mapa corregirlo para que indique los valores reales. Eso funcionaría,
> pero son muchos mapas y quizás haya una función en ggplot que evite el
> problema directamente.
> Manuel
> 
> El vie., 20 sept. 2019 a las 7:38, Emilio L. Cano ( >)
> escribió:
> 
> > Hola Manuel,
> >
> > Ten en cuenta que la intensidad del color depende de la escala de la
> > variable. Limits = c(-200, 200) pone los que hay fuera con el color NA por
> > defecto (gris). No estoy seguro pero creo que si los positivos no se
> > distingue el color es porque es “casi blanco”, supongo que debido a que los
> > datos son muy asimétricos y los valores por debajo de -200 son muy grandes
> > en valor absoluto con respecto a los que hay por encima de 200. Y por
> > definición, es una escala de color que depende de la magnitud de la
> > variable.
> >
> > Tal vez puedas mejorar la visualización cambiando el color del punto
> > central (argumento “mid”), en vez de blanco, por algún tono de rojo
> > intermedio.
> >
> > Si esto no lo soluciona intenta pegar el ejemplo con un subconjunto de
> > datos con el que se pueda reproducir (es fácil con datapasta+reprex:
> > https://reprex.tidyverse.org/articles/articles/datapasta-reprex.html 
> > )
> >
> > Un saludo,
> > Emilio
> >
> > > El 19 sept 2019, a las 18:34, Manuel Mendoza  > > >
> > escribió:
> > >
> > > Muy buenas. Quiero hacer un mapa que me pinte en azul los valores
> > negativos
> > > y en rojo los positivos. Los negativos llegan hasta -400 y los positivos
> > > hasta 200. Si pongo  limits=c(-200, 200), me colorea bien los positivos
> > > (rojo), pero los negativos por debajo de -200 me los pone gris.  Si pongo
> > > limits=c(-400, 200), me colorea bien los negativos (azul), pero los
> > > positivos apenas se ven. Necesito que me pinte los azules como el
> > primero,
> > > y los azules como el segundo.
> > > Gracias
> > >
> > > Este es el código:
> > >   ggplot(legend=FALSE)+
> > >   theme(panel.background=element_blank())+
> > >   theme(panel.grid.major = element_blank())+
> > >   theme(panel.grid.minor = element_blank())+
> > >
> > > theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
> > >   theme(axis.ticks = element_blank()) + xlab("") + ylab("")+
> > >
> > > geom_point(data=SGData2,aes(x=lon,y=lat,color=Ch7085),shape=15,size=1.5)
> > +
> > >  * scale_colour_gradient2(limits=c(-400, 200),low =
> > > "blue",high="red",midpoint=0*,
> > >   guide="colourbar")+geom_path(data=world, aes(x=long,
> > > y=lat,group=group))+
> > >   labs(title =  "ch7085")
> > >
> > >   [[alternative HTML version deleted]]
> > >
> > > ___
> > > 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 
> 
> 
> 
> -- 
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es 

Re: [R] annotation help in ggplot2

2019-09-20 Thread ऋषि / rIsHi
Here is the solution inspired by this post
https://stackoverflow.com/questions/18165863/multirow-axis-labels-with-nested-grouping-variables


> data$Female <-  factor(data$Female, levels =
c("F1","F2","F3","F4","F5","F6","F7","F8","F9","F10"))
>
ggplot(data,aes(x=family,y=offs.surv.perct,fill=treat))+geom_bar(stat="identity",
position="dodge")+
  geom_text(aes(label = MID),  angle=90)+
  facet_wrap(~Female, strip.position = "bottom", scales = "free_x",nrow=1)+
  theme(panel.spacing = unit(0, "lines"),
strip.background = element_blank(),
strip.placement = "outside")


On Fri, Sep 20, 2019 at 11:51 AM Moshiur Rahman 
wrote:

> Thanks Rishi,
>
> Please find attached the data herewith.
>
>
>
> On Fri, Sep 20, 2019 at 5:48 PM ঋষি ( ऋषि / rIsHi ) <
> rishi.das...@gmail.com> wrote:
>
>> There are no attached data .
>>
>> On Fri, Sep 20, 2019 at 11:40 AM Moshiur Rahman 
>> wrote:
>>
>>> Dear ggplot2 experts,
>>>
>>> I'm struggling to make a plot having family id in x-axis and female id
>>> below that family id where each 4 families have a single female id.
>>>
>>> I also need to add male id on top of each bar which I can do before
>>> grid.arrange, but fail after doing it. So, any suggestions?
>>>
>>> Please find below my codes and help me to complete it perfectly.
>>> #data
>>> data <- read.table("R-help_ggplot2.csv", header=TRUE, sep=",")
>>> names(data)
>>> #packages
>>> library(ggplot2)
>>> library(grid)
>>> library(gridExtra)
>>> library(scales)
>>> library(ggpubr)
>>> #plot codes
>>> p1 =
>>> ggplot(data,aes(x=factor(family),y=offs.surv.perct,fill=factor(treat)))+
>>> geom_bar(stat="identity", position="dodge")+
>>> #facet_wrap(~ Female)+
>>> geom_bar(stat="identity", position="dodge", colour="black",
>>> show.legend= TRUE) + # show_guide = TRUE gives legend boarder
>>> #geom_hline(yintercept=15, size=0.5, linetype = 2)+ ### middle line
>>> scale_fill_manual(values=c("grey", "white")) + # grey80 is closer to
>>> white than black
>>> xlab("Family") +
>>> ylab (expression(paste("Offspring survival rate (%)"))) +
>>> #coord_cartesian(xlim=c(0,40), ylim=c(0,60), clip="off")+
>>> scale_y_continuous(expand = c(0, 0), limits = c(0, 60))+
>>> theme(legend.title = element_text(colour="black", size=12))+
>>> theme(legend.text = element_text(colour="black", size=11))+
>>> theme(legend.background = element_blank())+
>>> theme(legend.key = element_blank())+
>>> theme(legend.box.background = element_blank())+
>>> theme(legend.key.size = unit(2, "mm"),legend.key.width =
>>> unit(0.5,"cm"))+
>>> theme(legend.position=c(0.05,0.9),legend.direction
>>> ="vertical",legend.box = "vertical")+ # add legend on top
>>> theme(panel.background = element_rect(fill = "transparent"))+
>>> theme(axis.line = element_line(colour =
>>> "black"),axis.text.x=element_text(size=10,
>>> colour="black"),axis.text.y=element_text(size=10, colour="black"),
>>> axis.title.y = element_text(size=12, colour =
>>> "black",margin=margin(0,5,0,0)),
>>> axis.title.x = element_blank(),
>>> strip.text.x = element_blank(),# remove top level title (high and
>>> low)
>>> strip.background = element_blank(),# remove top level background
>>> panel.grid.major = element_blank(),# remove grid line within the
>>> plot
>>> panel.grid.minor = element_blank(),
>>> panel.border = element_blank())
>>> p1
>>>
>>> ### legend correction
>>> p2<- p1 + guides(fill = guide_legend(title="Fertilization
>>> group",keywidth =
>>> 1,keyheight = 1,
>>>  title.theme = element_text(size=12, colour =
>>> "black", angle = 0)))+
>>>   theme(legend.text = element_text(size = 12, colour = "black", angle =
>>> 0))
>>>
>>> p2
>>>
>>> ###plot margins
>>> p3<-p2+theme(plot.margin = unit(c(1,1,1.7,1), "lines"))
>>> p3
>>>
>>> #x-axis label
>>> p4<-grid.arrange(
>>>   p3,
>>>   bottom = textGrob(
>>> "Family and female number",
>>> gp = gpar(fontsize = 12, cex=1), #fontface = "bold",
>>> vjust = 0.5, hjust = 0.5,x = 0.52))
>>>
>>> # annotation (NOT WORKING)
>>> p5<-p4+annotate("text", label = "M1", x = 1, y = 25.03, fontface = 1,
>>> size=3,angle = 90)
>>> p5
>>> p6<-p5+annotate("text", label = "M2", x = 2, y = 18.37, fontface = 1,
>>> size=3,angle = 90)
>>> p6
>>> p7<-p6+annotate("text", label = "M3", x = 3, y = 21.7, fontface = 1,
>>> size=3,angle = 90)
>>> p7
>>> p8<-p7+annotate("text", label = "M1-2-3", x = 4, y = 19.1, fontface= 1,
>>> size=3,angle = 90)
>>> p8
>>> Fig1.1<-p8+annotate("segment", size=0.3, x=c(1,1,4),xend=c(1,4,4),
>>>  y= c(26,28,28), yend=c(28,28,21))+
>>>   annotate("text",x=2.45,y=29.5,fontface = 1, size=3,angle =
>>> 90,label=c("F1"))
>>>
>>> Fig1.1
>>>
>>> Please find attached also my data.
>>>
>>> Any assistance will be highly appreciated.
>>>
>>> Regards,
>>>
>>> Moshi
>>>
>>>
>>> JSPS Postdoctoral Fellow
>>> Laboratory of Population Biology
>>> Department of Marine 

Re: [R] annotation help in ggplot2

2019-09-20 Thread ऋषि / rIsHi
There are no attached data .

On Fri, Sep 20, 2019 at 11:40 AM Moshiur Rahman 
wrote:

> Dear ggplot2 experts,
>
> I'm struggling to make a plot having family id in x-axis and female id
> below that family id where each 4 families have a single female id.
>
> I also need to add male id on top of each bar which I can do before
> grid.arrange, but fail after doing it. So, any suggestions?
>
> Please find below my codes and help me to complete it perfectly.
> #data
> data <- read.table("R-help_ggplot2.csv", header=TRUE, sep=",")
> names(data)
> #packages
> library(ggplot2)
> library(grid)
> library(gridExtra)
> library(scales)
> library(ggpubr)
> #plot codes
> p1 =
> ggplot(data,aes(x=factor(family),y=offs.surv.perct,fill=factor(treat)))+
> geom_bar(stat="identity", position="dodge")+
> #facet_wrap(~ Female)+
> geom_bar(stat="identity", position="dodge", colour="black",
> show.legend= TRUE) + # show_guide = TRUE gives legend boarder
> #geom_hline(yintercept=15, size=0.5, linetype = 2)+ ### middle line
> scale_fill_manual(values=c("grey", "white")) + # grey80 is closer to
> white than black
> xlab("Family") +
> ylab (expression(paste("Offspring survival rate (%)"))) +
> #coord_cartesian(xlim=c(0,40), ylim=c(0,60), clip="off")+
> scale_y_continuous(expand = c(0, 0), limits = c(0, 60))+
> theme(legend.title = element_text(colour="black", size=12))+
> theme(legend.text = element_text(colour="black", size=11))+
> theme(legend.background = element_blank())+
> theme(legend.key = element_blank())+
> theme(legend.box.background = element_blank())+
> theme(legend.key.size = unit(2, "mm"),legend.key.width =
> unit(0.5,"cm"))+
> theme(legend.position=c(0.05,0.9),legend.direction
> ="vertical",legend.box = "vertical")+ # add legend on top
> theme(panel.background = element_rect(fill = "transparent"))+
> theme(axis.line = element_line(colour =
> "black"),axis.text.x=element_text(size=10,
> colour="black"),axis.text.y=element_text(size=10, colour="black"),
> axis.title.y = element_text(size=12, colour =
> "black",margin=margin(0,5,0,0)),
> axis.title.x = element_blank(),
> strip.text.x = element_blank(),# remove top level title (high and
> low)
> strip.background = element_blank(),# remove top level background
> panel.grid.major = element_blank(),# remove grid line within the
> plot
> panel.grid.minor = element_blank(),
> panel.border = element_blank())
> p1
>
> ### legend correction
> p2<- p1 + guides(fill = guide_legend(title="Fertilization group",keywidth =
> 1,keyheight = 1,
>  title.theme = element_text(size=12, colour =
> "black", angle = 0)))+
>   theme(legend.text = element_text(size = 12, colour = "black", angle = 0))
>
> p2
>
> ###plot margins
> p3<-p2+theme(plot.margin = unit(c(1,1,1.7,1), "lines"))
> p3
>
> #x-axis label
> p4<-grid.arrange(
>   p3,
>   bottom = textGrob(
> "Family and female number",
> gp = gpar(fontsize = 12, cex=1), #fontface = "bold",
> vjust = 0.5, hjust = 0.5,x = 0.52))
>
> # annotation (NOT WORKING)
> p5<-p4+annotate("text", label = "M1", x = 1, y = 25.03, fontface = 1,
> size=3,angle = 90)
> p5
> p6<-p5+annotate("text", label = "M2", x = 2, y = 18.37, fontface = 1,
> size=3,angle = 90)
> p6
> p7<-p6+annotate("text", label = "M3", x = 3, y = 21.7, fontface = 1,
> size=3,angle = 90)
> p7
> p8<-p7+annotate("text", label = "M1-2-3", x = 4, y = 19.1, fontface= 1,
> size=3,angle = 90)
> p8
> Fig1.1<-p8+annotate("segment", size=0.3, x=c(1,1,4),xend=c(1,4,4),
>  y= c(26,28,28), yend=c(28,28,21))+
>   annotate("text",x=2.45,y=29.5,fontface = 1, size=3,angle =
> 90,label=c("F1"))
>
> Fig1.1
>
> Please find attached also my data.
>
> Any assistance will be highly appreciated.
>
> Regards,
>
> Moshi
>
>
> JSPS Postdoctoral Fellow
> Laboratory of Population Biology
> Department of Marine Biosciences
> Graduate School of Marine Science and Technology
> Tokyo University of Marine Science and Technology
> 4-5-7 Konan, Minato-ku, Tokyo 108-8477, Japan
> Mobile: 050-6874-9072
> __
> 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.
>


-- 



With regards
Rishi Das Roy

[[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] annotation help in ggplot2

2019-09-20 Thread Moshiur Rahman
Thanks a lot Rishi for your very cordial effort and great help. But still I
need some help to improve it as the plot doesn't clearly depict which
female belongs to which family and this can be detected by drawing a line
from 1-4 for F1, 5-8 for F2

Another problem I can see that the position of MID (P1,2,3...) is not
looking well which are somehow noisy.

Finally, can we drop the bars at the bottom of x-axis that I did
with scale_y_continuous?

Please do me some favour to complete this plot which I need for a
publication.

With kind regards,

Moshi

On Fri, Sep 20, 2019 at 7:45 PM ঋষি ( ऋषि / rIsHi ) 
wrote:

> Here is the solution inspired by this post
> https://stackoverflow.com/questions/18165863/multirow-axis-labels-with-nested-grouping-variables
>
>
> > data$Female <-  factor(data$Female, levels =
> c("F1","F2","F3","F4","F5","F6","F7","F8","F9","F10"))
> >
> ggplot(data,aes(x=family,y=offs.surv.perct,fill=treat))+geom_bar(stat="identity",
> position="dodge")+
>   geom_text(aes(label = MID),  angle=90)+
>   facet_wrap(~Female, strip.position = "bottom", scales = "free_x",nrow=1)+
>   theme(panel.spacing = unit(0, "lines"),
> strip.background = element_blank(),
> strip.placement = "outside")
>
>
> On Fri, Sep 20, 2019 at 11:51 AM Moshiur Rahman 
> wrote:
>
>> Thanks Rishi,
>>
>> Please find attached the data herewith.
>>
>>
>>
>> On Fri, Sep 20, 2019 at 5:48 PM ঋষি ( ऋषि / rIsHi ) <
>> rishi.das...@gmail.com> wrote:
>>
>>> There are no attached data .
>>>
>>> On Fri, Sep 20, 2019 at 11:40 AM Moshiur Rahman 
>>> wrote:
>>>
 Dear ggplot2 experts,

 I'm struggling to make a plot having family id in x-axis and female id
 below that family id where each 4 families have a single female id.

 I also need to add male id on top of each bar which I can do before
 grid.arrange, but fail after doing it. So, any suggestions?

 Please find below my codes and help me to complete it perfectly.
 #data
 data <- read.table("R-help_ggplot2.csv", header=TRUE, sep=",")
 names(data)
 #packages
 library(ggplot2)
 library(grid)
 library(gridExtra)
 library(scales)
 library(ggpubr)
 #plot codes
 p1 =
 ggplot(data,aes(x=factor(family),y=offs.surv.perct,fill=factor(treat)))+
 geom_bar(stat="identity", position="dodge")+
 #facet_wrap(~ Female)+
 geom_bar(stat="identity", position="dodge", colour="black",
 show.legend= TRUE) + # show_guide = TRUE gives legend boarder
 #geom_hline(yintercept=15, size=0.5, linetype = 2)+ ### middle line
 scale_fill_manual(values=c("grey", "white")) + # grey80 is closer to
 white than black
 xlab("Family") +
 ylab (expression(paste("Offspring survival rate (%)"))) +
 #coord_cartesian(xlim=c(0,40), ylim=c(0,60), clip="off")+
 scale_y_continuous(expand = c(0, 0), limits = c(0, 60))+
 theme(legend.title = element_text(colour="black", size=12))+
 theme(legend.text = element_text(colour="black", size=11))+
 theme(legend.background = element_blank())+
 theme(legend.key = element_blank())+
 theme(legend.box.background = element_blank())+
 theme(legend.key.size = unit(2, "mm"),legend.key.width =
 unit(0.5,"cm"))+
 theme(legend.position=c(0.05,0.9),legend.direction
 ="vertical",legend.box = "vertical")+ # add legend on top
 theme(panel.background = element_rect(fill = "transparent"))+
 theme(axis.line = element_line(colour =
 "black"),axis.text.x=element_text(size=10,
 colour="black"),axis.text.y=element_text(size=10, colour="black"),
 axis.title.y = element_text(size=12, colour =
 "black",margin=margin(0,5,0,0)),
 axis.title.x = element_blank(),
 strip.text.x = element_blank(),# remove top level title (high
 and
 low)
 strip.background = element_blank(),# remove top level background
 panel.grid.major = element_blank(),# remove grid line within the
 plot
 panel.grid.minor = element_blank(),
 panel.border = element_blank())
 p1

 ### legend correction
 p2<- p1 + guides(fill = guide_legend(title="Fertilization
 group",keywidth =
 1,keyheight = 1,
  title.theme = element_text(size=12, colour
 =
 "black", angle = 0)))+
   theme(legend.text = element_text(size = 12, colour = "black", angle =
 0))

 p2

 ###plot margins
 p3<-p2+theme(plot.margin = unit(c(1,1,1.7,1), "lines"))
 p3

 #x-axis label
 p4<-grid.arrange(
   p3,
   bottom = textGrob(
 "Family and female number",
 gp = gpar(fontsize = 12, cex=1), #fontface = "bold",
 vjust = 0.5, hjust = 0.5,x = 0.52))

 # annotation (NOT WORKING)
 p5<-p4+annotate("text", label = "M1", x = 1, y = 25.03, fontface = 1,
 size=3,angle = 90)
 p5
 

Re: [R] [SPAM] Re: The "--slave" option

2019-09-20 Thread Benjamin Lang
Hi Richard,

Sure, it's a silly example, but it makes about as much sense as using
"slave" to mean "quiet". Also, there is no "--master" option so it's not
exactly the master/slave terminology here either.

My only point is that I think it's very distasteful to give such a
needlessly awful name to an option in what has become a very broadly used
piece of software. It would be good to update it, I think.

If anyone knows how to actually pass this on to the R
developers/contributors, please let me know.

Thanks,
Ben

On Fri, 20 Sep 2019 at 05:14, Richard O'Keefe  wrote:

> Nobody would use "stentorian" as an alternative to "verbose" because they
> mean very different things.
>   "verbose" means "using many words"
>   "stentorian" means "talking very loudly, like Stentor, whose voice was
> as powerful
>   as fifty voices of other men".
> You can be verbose while talking in a whisper.
> You can be stentorian while being laconic.
>
> If you don't like the word "slave", the option "--silent" is there for you
> to use.
>
> The "master-slave" design pattern is in hundreds of books (although I note
> that
> Erlang uses different terminology).  Your car has a master hydraulic
> cylinder and
> slave cylinders.  The analogy is pervasive in technology.  See a very
> short list
> at https://en.wikipedia.org/wiki/Master/slave_(technology)
> which ends with "Global Language Monitor
>  found the term
> "master/slave" to be the most
> egregious example of political correctness
>  in 2004, and named
> it the most politically
> incorrect term of that year."
>
> The one thing "slave" does not mean in technology is any kind of human
> being.
>
> On Thu, 19 Sep 2019 at 21:51, Benjamin Lang  wrote:
>
>> Dear Richard,
>>
>> Thank you, that’s interesting. There is also something called an
>> “etymological fallacy”. I think current usage is more useful here than the
>> “science of truth”, i.e. the Ancient Greek idea that the (sometimes
>> inferred) derivation of a word allows us to grasp “the truth of it”.
>>
>> In current usage, a “server” is someone who brings you dishes in a
>> restaurant. A “client” is a customer. A “slave” is a human being forced to
>> perform work under duress and considered nothing more than a machine, say a
>> dishwasher or a tractor. And in some regions, this echoes on and is
>> offensive and hurtful to some.
>>
>> A new user, wanting to reduce output from R, would probably reach for
>> “-q” or “—quiet”. This makes sense in the same way that “—stentorian” is
>> not a good alternative to “—verbose”.
>>
>> Best,
>> Ben
>>
>> On 19 Sep 2019, at 10:55, Richard O'Keefe  wrote:
>>
>> One of my grandfathers was from Croatia.  Guess what the word "slave" is
>> derived
>> from?  That's right, Slavs.  This goes back to the 9th century.  And then
>> of course
>> my grandfather's people were enslaved by the Ottoman empire, which was
>> only defeated
>> a little over a hundred years ago.  My other grandfather was from the
>> British isles,
>> where to this day followers of the same prophet are enslaving people like
>> me
>> (except for being female).  So I'm sorry, but I'm not impressed.
>>
>> How many computers are "servers"?  There's that whole client-server thing.
>> Guess what "server" comes from?  That's right, the Latin word "servus",
>> which
>> means guess what?  You got it again: "slave".  Are we to abolish the word
>> "server"?  What about the word "client"?  Ah, that's part of the
>> client-patron
>> system from Rome, so what about the patriarchy, eh?
>>
>> We are dealing with something called "the genetic fallacy".
>> "The genetic *fallacy* (also known as the *fallacy of origins* ...)
>>  is a *fallacy* of irrelevance that is based solely on someone's
>>  or something's history, *origin*, or source rather than its
>>  current meaning or context."  (Wikipedia.)
>>
>> Context matters.
>>
>>
>>
>> On Thu, 19 Sep 2019 at 17:10, Abby Spurdle  wrote:
>>
>>> > Personally I much prefer backwards compatibility to political
>>> correctness.
>>>
>>> I agree with Rolf, here.
>>> And as someone that's planning to write a Linux Terminal Emulator, in
>>> the medium-term future, I *strongly* defend this approach.
>>>
>>> And to the original poster.
>>> Haven't you seen The Matrix?
>>> (Second best movie ever, after the Shawshank Redemption).
>>>
>>> I would prefer the technology to be my slave, than I be a
>>> prisoner/slave to the technology.
>>>
>>> __
>>> 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 

Re: [ESS] ESS-help Digest, Vol 199, Issue 3

2019-09-20 Thread Vitalie Spinu via ESS-help
> (add-to-list 'load-path "~/Library/Preferences/Aquamacs
Emacs/Packages/lisp/")
> (require 'ess-site)
> (load "ess-autoloads")  ;; need to register Rnw files
> (require ‘polymode) ;; version 2.0 now
> (require 'poly-markdown)
> (require 'poly-noweb)
> (require 'poly-R)  ;;


Just to clarify that none of those requires is really needed unless you
install polymode and poly-xyz from the source and want to load from special
locations. If installed from melpa, everything (including file
associations) should work out of the box. No configuration needed
whatsoever. Dependencies will be resolved automatically because elpa
packages are already in the path.

  Vitalie

[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] [SPAM] Re: The "--slave" option

2019-09-20 Thread Richard O'Keefe
Not being a jerk is a good thing.
Unthinking political correctness is not the same thing at all.
The point has already been made that the relationship between
a "master" process or cylinder and a "slave" one is intrinsically
a dominance relation where the "master" tells the "slave" what to
do.  No amount of mucking around with audible or written words
will affect the *meaning*.  Even boss/worker is uncomfortably
close to master/slave and is going to trigger anyone who is
triggered by words rather than actual oppression (such as having
someone hostile attempt to control your speech, and intrinsically
oppressive act which presumes that the would-be controller has
some sort of *right* to dominate the potential controllee).

If we ever hear of someone using R who is or was a slave, we'll
ask for *their* opinion on the matter.

It has also been noted that euphemisms erode surprisingly quickly.
In my daughters' generation, the euphemism "toilet" for the jakes
is being replaced by "bathroom" -- with the result that I never
know which room they're going too, we have to use the ridiculous
"bathroom bathroom" to indicate the place where you wash yourself --
and I'm sure another term for the necessary house will be along
soon.  In fact, we're already starting to say "wharepaku" (Foh-
Re-Pah-Koo) for clarity.  Dear knows what that will be replaced
by.  So shunning the word "slave" is not only ineffective, it
won't even be ineffective for long; whatever replaces it will
itself be the target of cries of "being a jerk".

The really annoying thing about this is that it does nothing whatsoever
to improve the actual condition of any living person.

As for NULL, NA, and NaN, you really cannot blame R for NaN.
S existed before IEEE arithmetic, and it's not *that* hard to
keep NULL and NA apart.  length(NULL) is 0.  There is literally
nothing there.  It's what c() gives you.  length(NA) is 1. There is
a place for something but it was missing or undefined.
IEEE arithmetic introduced NaN, which means "there should be something
here but your calculation went wrong, the *mathematical* result might
be defined but this machine cannot compute it."
Frankly, IEEE arithmetic made a lot of things simpler, but a lot of
other things more complicated.  You should see what it did to
floating-point comparison in C.

As for the syntax of S, it comes from the same organisation as C.
Having used GLIM, GENSTSTAT, SPSS, and BASIS (don't ask), S was a
revelation that statistics environments did not have to be arcane.

As for the documentation of R, it's pretty much the best of any open
source programming/statistics tool I've used, and most impressively,
has a huge library of packages whose authors have also produced
comparatively good documentation, but the standards of free software.

Run time error messages?  Yes, they could be improved.  Quite a bit.
You've probably heard about the famous Multics error message.  One
day, on startup at a Multics site, the machine wrote
   Hodie natus est radici frater.
You probably haven't heard about the Burroughs B6700 ESPOL compiler.
One of its error messages was
   IF YOU KNOW WHAT THIS MEANS, IMPLEMENT IT.
It's an open source project.  If you think an error message could be
improved, you can patch your copy and send the patch to the maintainer.
The following sentence was written by a biostatistician:
"Help files are frequently more than a little obscure."
That was written about a commercial package, not R.

SPSS costs NZD 156/month for one user, or about NZD 1871/year.
SAS prices are scary.  I don't know what the licence terms for the
free-as-in-beer "University Edition" are; since I'm no longer at a
university I suspect I wouldn't qualify.
I rather liked GLIM, but it's dead, and the syntax was idiosyncratic.
I also rather liked GENSTAT, but when you look for the price and are
invited to "ask for a quote", my "I-can't-afford-this" alarm goes off.
Plus the pages I viewed are for Windows only.

Thing is, for the price of one year for one user on one machine,
you could fund quite a bit of error message improvement for R.

As for slavery and the Bible, what's translated "slavery" in the OT is
not the "chattel slavery" that was practiced in the 19th century.
Slavery was banned in England by William the Conqueror, of all
people, and the first "official" ban on slavery by any religion that I
ever heard of was when the Vatican ruled that the native
inhabitants of the Americas could not be made slaves.  Many of
the Abolitionists derived their opposition to chattel slavery from
the Bible.  The practice of African slavery was, as a matter of
history, learned from another religion entirely, whose prophet
bought and sold black slaves himself.

Serfdom is close to slavery.  ("Serf" comes from "servus".)
http://www.scottishmining.co.uk/429.html
describes the way salt-workers and colliers were bound to the
land in Scotland, so that 'And thus it came about that the nineteenth century
had dawned before it could be said in 

Re: [R] annotation help in ggplot2

2019-09-20 Thread Moshiur Rahman
Thanks Rishi,

Please find attached the data herewith.



On Fri, Sep 20, 2019 at 5:48 PM ঋষি ( ऋषि / rIsHi ) 
wrote:

> There are no attached data .
>
> On Fri, Sep 20, 2019 at 11:40 AM Moshiur Rahman 
> wrote:
>
>> Dear ggplot2 experts,
>>
>> I'm struggling to make a plot having family id in x-axis and female id
>> below that family id where each 4 families have a single female id.
>>
>> I also need to add male id on top of each bar which I can do before
>> grid.arrange, but fail after doing it. So, any suggestions?
>>
>> Please find below my codes and help me to complete it perfectly.
>> #data
>> data <- read.table("R-help_ggplot2.csv", header=TRUE, sep=",")
>> names(data)
>> #packages
>> library(ggplot2)
>> library(grid)
>> library(gridExtra)
>> library(scales)
>> library(ggpubr)
>> #plot codes
>> p1 =
>> ggplot(data,aes(x=factor(family),y=offs.surv.perct,fill=factor(treat)))+
>> geom_bar(stat="identity", position="dodge")+
>> #facet_wrap(~ Female)+
>> geom_bar(stat="identity", position="dodge", colour="black",
>> show.legend= TRUE) + # show_guide = TRUE gives legend boarder
>> #geom_hline(yintercept=15, size=0.5, linetype = 2)+ ### middle line
>> scale_fill_manual(values=c("grey", "white")) + # grey80 is closer to
>> white than black
>> xlab("Family") +
>> ylab (expression(paste("Offspring survival rate (%)"))) +
>> #coord_cartesian(xlim=c(0,40), ylim=c(0,60), clip="off")+
>> scale_y_continuous(expand = c(0, 0), limits = c(0, 60))+
>> theme(legend.title = element_text(colour="black", size=12))+
>> theme(legend.text = element_text(colour="black", size=11))+
>> theme(legend.background = element_blank())+
>> theme(legend.key = element_blank())+
>> theme(legend.box.background = element_blank())+
>> theme(legend.key.size = unit(2, "mm"),legend.key.width =
>> unit(0.5,"cm"))+
>> theme(legend.position=c(0.05,0.9),legend.direction
>> ="vertical",legend.box = "vertical")+ # add legend on top
>> theme(panel.background = element_rect(fill = "transparent"))+
>> theme(axis.line = element_line(colour =
>> "black"),axis.text.x=element_text(size=10,
>> colour="black"),axis.text.y=element_text(size=10, colour="black"),
>> axis.title.y = element_text(size=12, colour =
>> "black",margin=margin(0,5,0,0)),
>> axis.title.x = element_blank(),
>> strip.text.x = element_blank(),# remove top level title (high and
>> low)
>> strip.background = element_blank(),# remove top level background
>> panel.grid.major = element_blank(),# remove grid line within the
>> plot
>> panel.grid.minor = element_blank(),
>> panel.border = element_blank())
>> p1
>>
>> ### legend correction
>> p2<- p1 + guides(fill = guide_legend(title="Fertilization group",keywidth
>> =
>> 1,keyheight = 1,
>>  title.theme = element_text(size=12, colour =
>> "black", angle = 0)))+
>>   theme(legend.text = element_text(size = 12, colour = "black", angle =
>> 0))
>>
>> p2
>>
>> ###plot margins
>> p3<-p2+theme(plot.margin = unit(c(1,1,1.7,1), "lines"))
>> p3
>>
>> #x-axis label
>> p4<-grid.arrange(
>>   p3,
>>   bottom = textGrob(
>> "Family and female number",
>> gp = gpar(fontsize = 12, cex=1), #fontface = "bold",
>> vjust = 0.5, hjust = 0.5,x = 0.52))
>>
>> # annotation (NOT WORKING)
>> p5<-p4+annotate("text", label = "M1", x = 1, y = 25.03, fontface = 1,
>> size=3,angle = 90)
>> p5
>> p6<-p5+annotate("text", label = "M2", x = 2, y = 18.37, fontface = 1,
>> size=3,angle = 90)
>> p6
>> p7<-p6+annotate("text", label = "M3", x = 3, y = 21.7, fontface = 1,
>> size=3,angle = 90)
>> p7
>> p8<-p7+annotate("text", label = "M1-2-3", x = 4, y = 19.1, fontface= 1,
>> size=3,angle = 90)
>> p8
>> Fig1.1<-p8+annotate("segment", size=0.3, x=c(1,1,4),xend=c(1,4,4),
>>  y= c(26,28,28), yend=c(28,28,21))+
>>   annotate("text",x=2.45,y=29.5,fontface = 1, size=3,angle =
>> 90,label=c("F1"))
>>
>> Fig1.1
>>
>> Please find attached also my data.
>>
>> Any assistance will be highly appreciated.
>>
>> Regards,
>>
>> Moshi
>>
>>
>> JSPS Postdoctoral Fellow
>> Laboratory of Population Biology
>> Department of Marine Biosciences
>> Graduate School of Marine Science and Technology
>> Tokyo University of Marine Science and Technology
>> 4-5-7 Konan, Minato-ku, Tokyo 108-8477, Japan
>> Mobile: 050-6874-9072
>> __
>> 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.
>>
>
>
> --
>
>
>
> With regards
> Rishi Das Roy
>


-- 
Md. Moshiur Rahman, PhD

JSPS Postdoctoral Fellow
Laboratory of Population Biology
Department of Marine Biosciences
Graduate School of Marine Science and Technology
Tokyo University of Marine Science and Technology
4-5-7 Konan, 

Re: [R-es] ggplot con gradientes complejos

2019-09-20 Thread Manuel Mendoza
No sé muy bien, Carlos, como hacerlo, pero no parece más sencillo que lo de
multiplicar por 2 los positivos y después editar el mapa.

De lo que decías, Emilio, de cambiar el color del punto central creo que
haría más confusa la interpretación.

El vie., 20 sept. 2019 a las 10:33, Carlos Ortega ()
escribió:

> Hola,
>
> Una alternativa que suele funcionar es la de crear una columna adicional
> en tu dataframe que dé cuenta del color dependiendo de los valores del
> resto de las variables que tú decidas y utilizar este vector como valor
> para cada punto, en vez de dejar que sea la función "scale_colour_gradient"
> la que decida el color...
>
> Gracias,
> Carlos.
>
> El vie., 20 sept. 2019 a las 10:30, Manuel Mendoza (<
> mmend...@fulbrightmail.org>) escribió:
>
>> Gracias Emilio. Si, son asimétricos porque se mueven en rangos distintos.
>> De hecho, miden cosas distintas, pero una muestra no puede ser positiva y
>> negativa a la vez. Me planteo multiplicar las positivas por 2 y al editar
>> el mapa corregirlo para que indique los valores reales. Eso funcionaría,
>> pero son muchos mapas y quizás haya una función en ggplot que evite el
>> problema directamente.
>> Manuel
>>
>> El vie., 20 sept. 2019 a las 7:38, Emilio L. Cano (<
>> emilopezc...@gmail.com>)
>> escribió:
>>
>> > Hola Manuel,
>> >
>> > Ten en cuenta que la intensidad del color depende de la escala de la
>> > variable. Limits = c(-200, 200) pone los que hay fuera con el color NA
>> por
>> > defecto (gris). No estoy seguro pero creo que si los positivos no se
>> > distingue el color es porque es “casi blanco”, supongo que debido a que
>> los
>> > datos son muy asimétricos y los valores por debajo de -200 son muy
>> grandes
>> > en valor absoluto con respecto a los que hay por encima de 200. Y por
>> > definición, es una escala de color que depende de la magnitud de la
>> > variable.
>> >
>> > Tal vez puedas mejorar la visualización cambiando el color del punto
>> > central (argumento “mid”), en vez de blanco, por algún tono de rojo
>> > intermedio.
>> >
>> > Si esto no lo soluciona intenta pegar el ejemplo con un subconjunto de
>> > datos con el que se pueda reproducir (es fácil con datapasta+reprex:
>> > https://reprex.tidyverse.org/articles/articles/datapasta-reprex.html)
>> >
>> > Un saludo,
>> > Emilio
>> >
>> > > El 19 sept 2019, a las 18:34, Manuel Mendoza <
>> mmend...@fulbrightmail.org>
>> > escribió:
>> > >
>> > > Muy buenas. Quiero hacer un mapa que me pinte en azul los valores
>> > negativos
>> > > y en rojo los positivos. Los negativos llegan hasta -400 y los
>> positivos
>> > > hasta 200. Si pongo  limits=c(-200, 200), me colorea bien los
>> positivos
>> > > (rojo), pero los negativos por debajo de -200 me los pone gris.  Si
>> pongo
>> > > limits=c(-400, 200), me colorea bien los negativos (azul), pero los
>> > > positivos apenas se ven. Necesito que me pinte los azules como el
>> > primero,
>> > > y los azules como el segundo.
>> > > Gracias
>> > >
>> > > Este es el código:
>> > >   ggplot(legend=FALSE)+
>> > >   theme(panel.background=element_blank())+
>> > >   theme(panel.grid.major = element_blank())+
>> > >   theme(panel.grid.minor = element_blank())+
>> > >
>> > > theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
>> > >   theme(axis.ticks = element_blank()) + xlab("") +
>> ylab("")+
>> > >
>> > >
>> geom_point(data=SGData2,aes(x=lon,y=lat,color=Ch7085),shape=15,size=1.5)
>> > +
>> > >  * scale_colour_gradient2(limits=c(-400, 200),low =
>> > > "blue",high="red",midpoint=0*,
>> > >   guide="colourbar")+geom_path(data=world, aes(x=long,
>> > > y=lat,group=group))+
>> > >   labs(title =  "ch7085")
>> > >
>> > >   [[alternative HTML version deleted]]
>> > >
>> > > ___
>> > > 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
>>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.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-es] ggplot con gradientes complejos

2019-09-20 Thread Carlos Ortega
A mí sí que me parece más sencillo que editar el mapa... :-).

Gracias,
Carlos.

El vie., 20 sept. 2019 a las 10:42, Manuel Mendoza (<
mmend...@fulbrightmail.org>) escribió:

> No sé muy bien, Carlos, como hacerlo, pero no parece más sencillo que lo
> de multiplicar por 2 los positivos y después editar el mapa.
>
> De lo que decías, Emilio, de cambiar el color del punto central creo que
> haría más confusa la interpretación.
>
> El vie., 20 sept. 2019 a las 10:33, Carlos Ortega (<
> c...@qualityexcellence.es>) escribió:
>
>> Hola,
>>
>> Una alternativa que suele funcionar es la de crear una columna adicional
>> en tu dataframe que dé cuenta del color dependiendo de los valores del
>> resto de las variables que tú decidas y utilizar este vector como valor
>> para cada punto, en vez de dejar que sea la función "scale_colour_gradient"
>> la que decida el color...
>>
>> Gracias,
>> Carlos.
>>
>> El vie., 20 sept. 2019 a las 10:30, Manuel Mendoza (<
>> mmend...@fulbrightmail.org>) escribió:
>>
>>> Gracias Emilio. Si, son asimétricos porque se mueven en rangos distintos.
>>> De hecho, miden cosas distintas, pero una muestra no puede ser positiva y
>>> negativa a la vez. Me planteo multiplicar las positivas por 2 y al editar
>>> el mapa corregirlo para que indique los valores reales. Eso funcionaría,
>>> pero son muchos mapas y quizás haya una función en ggplot que evite el
>>> problema directamente.
>>> Manuel
>>>
>>> El vie., 20 sept. 2019 a las 7:38, Emilio L. Cano (<
>>> emilopezc...@gmail.com>)
>>> escribió:
>>>
>>> > Hola Manuel,
>>> >
>>> > Ten en cuenta que la intensidad del color depende de la escala de la
>>> > variable. Limits = c(-200, 200) pone los que hay fuera con el color NA
>>> por
>>> > defecto (gris). No estoy seguro pero creo que si los positivos no se
>>> > distingue el color es porque es “casi blanco”, supongo que debido a
>>> que los
>>> > datos son muy asimétricos y los valores por debajo de -200 son muy
>>> grandes
>>> > en valor absoluto con respecto a los que hay por encima de 200. Y por
>>> > definición, es una escala de color que depende de la magnitud de la
>>> > variable.
>>> >
>>> > Tal vez puedas mejorar la visualización cambiando el color del punto
>>> > central (argumento “mid”), en vez de blanco, por algún tono de rojo
>>> > intermedio.
>>> >
>>> > Si esto no lo soluciona intenta pegar el ejemplo con un subconjunto de
>>> > datos con el que se pueda reproducir (es fácil con datapasta+reprex:
>>> > https://reprex.tidyverse.org/articles/articles/datapasta-reprex.html)
>>> >
>>> > Un saludo,
>>> > Emilio
>>> >
>>> > > El 19 sept 2019, a las 18:34, Manuel Mendoza <
>>> mmend...@fulbrightmail.org>
>>> > escribió:
>>> > >
>>> > > Muy buenas. Quiero hacer un mapa que me pinte en azul los valores
>>> > negativos
>>> > > y en rojo los positivos. Los negativos llegan hasta -400 y los
>>> positivos
>>> > > hasta 200. Si pongo  limits=c(-200, 200), me colorea bien los
>>> positivos
>>> > > (rojo), pero los negativos por debajo de -200 me los pone gris.  Si
>>> pongo
>>> > > limits=c(-400, 200), me colorea bien los negativos (azul), pero los
>>> > > positivos apenas se ven. Necesito que me pinte los azules como el
>>> > primero,
>>> > > y los azules como el segundo.
>>> > > Gracias
>>> > >
>>> > > Este es el código:
>>> > >   ggplot(legend=FALSE)+
>>> > >   theme(panel.background=element_blank())+
>>> > >   theme(panel.grid.major = element_blank())+
>>> > >   theme(panel.grid.minor = element_blank())+
>>> > >
>>> > > theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
>>> > >   theme(axis.ticks = element_blank()) + xlab("") +
>>> ylab("")+
>>> > >
>>> > >
>>> geom_point(data=SGData2,aes(x=lon,y=lat,color=Ch7085),shape=15,size=1.5)
>>> > +
>>> > >  * scale_colour_gradient2(limits=c(-400, 200),low =
>>> > > "blue",high="red",midpoint=0*,
>>> > >   guide="colourbar")+geom_path(data=world, aes(x=long,
>>> > > y=lat,group=group))+
>>> > >   labs(title =  "ch7085")
>>> > >
>>> > >   [[alternative HTML version deleted]]
>>> > >
>>> > > ___
>>> > > 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
>>>
>>
>>
>> --
>> Saludos,
>> Carlos Ortega
>> www.qualityexcellence.es
>>
>

-- 
Saludos,
Carlos Ortega
www.qualityexcellence.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


[R] annotation help in ggplot2

2019-09-20 Thread Moshiur Rahman
Dear ggplot2 experts,

I'm struggling to make a plot having family id in x-axis and female id
below that family id where each 4 families have a single female id.

I also need to add male id on top of each bar which I can do before
grid.arrange, but fail after doing it. So, any suggestions?

Please find below my codes and help me to complete it perfectly.
#data
data <- read.table("R-help_ggplot2.csv", header=TRUE, sep=",")
names(data)
#packages
library(ggplot2)
library(grid)
library(gridExtra)
library(scales)
library(ggpubr)
#plot codes
p1 =
ggplot(data,aes(x=factor(family),y=offs.surv.perct,fill=factor(treat)))+
geom_bar(stat="identity", position="dodge")+
#facet_wrap(~ Female)+
geom_bar(stat="identity", position="dodge", colour="black",
show.legend= TRUE) + # show_guide = TRUE gives legend boarder
#geom_hline(yintercept=15, size=0.5, linetype = 2)+ ### middle line
scale_fill_manual(values=c("grey", "white")) + # grey80 is closer to
white than black
xlab("Family") +
ylab (expression(paste("Offspring survival rate (%)"))) +
#coord_cartesian(xlim=c(0,40), ylim=c(0,60), clip="off")+
scale_y_continuous(expand = c(0, 0), limits = c(0, 60))+
theme(legend.title = element_text(colour="black", size=12))+
theme(legend.text = element_text(colour="black", size=11))+
theme(legend.background = element_blank())+
theme(legend.key = element_blank())+
theme(legend.box.background = element_blank())+
theme(legend.key.size = unit(2, "mm"),legend.key.width =
unit(0.5,"cm"))+
theme(legend.position=c(0.05,0.9),legend.direction
="vertical",legend.box = "vertical")+ # add legend on top
theme(panel.background = element_rect(fill = "transparent"))+
theme(axis.line = element_line(colour =
"black"),axis.text.x=element_text(size=10,
colour="black"),axis.text.y=element_text(size=10, colour="black"),
axis.title.y = element_text(size=12, colour =
"black",margin=margin(0,5,0,0)),
axis.title.x = element_blank(),
strip.text.x = element_blank(),# remove top level title (high and
low)
strip.background = element_blank(),# remove top level background
panel.grid.major = element_blank(),# remove grid line within the
plot
panel.grid.minor = element_blank(),
panel.border = element_blank())
p1

### legend correction
p2<- p1 + guides(fill = guide_legend(title="Fertilization group",keywidth =
1,keyheight = 1,
 title.theme = element_text(size=12, colour =
"black", angle = 0)))+
  theme(legend.text = element_text(size = 12, colour = "black", angle = 0))

p2

###plot margins
p3<-p2+theme(plot.margin = unit(c(1,1,1.7,1), "lines"))
p3

#x-axis label
p4<-grid.arrange(
  p3,
  bottom = textGrob(
"Family and female number",
gp = gpar(fontsize = 12, cex=1), #fontface = "bold",
vjust = 0.5, hjust = 0.5,x = 0.52))

# annotation (NOT WORKING)
p5<-p4+annotate("text", label = "M1", x = 1, y = 25.03, fontface = 1,
size=3,angle = 90)
p5
p6<-p5+annotate("text", label = "M2", x = 2, y = 18.37, fontface = 1,
size=3,angle = 90)
p6
p7<-p6+annotate("text", label = "M3", x = 3, y = 21.7, fontface = 1,
size=3,angle = 90)
p7
p8<-p7+annotate("text", label = "M1-2-3", x = 4, y = 19.1, fontface= 1,
size=3,angle = 90)
p8
Fig1.1<-p8+annotate("segment", size=0.3, x=c(1,1,4),xend=c(1,4,4),
 y= c(26,28,28), yend=c(28,28,21))+
  annotate("text",x=2.45,y=29.5,fontface = 1, size=3,angle =
90,label=c("F1"))

Fig1.1

Please find attached also my data.

Any assistance will be highly appreciated.

Regards,

Moshi


JSPS Postdoctoral Fellow
Laboratory of Population Biology
Department of Marine Biosciences
Graduate School of Marine Science and Technology
Tokyo University of Marine Science and Technology
4-5-7 Konan, Minato-ku, Tokyo 108-8477, Japan
Mobile: 050-6874-9072
__
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] ggplot con gradientes complejos

2019-09-20 Thread Carlos Ortega
Hola,

Una alternativa que suele funcionar es la de crear una columna adicional en
tu dataframe que dé cuenta del color dependiendo de los valores del resto
de las variables que tú decidas y utilizar este vector como valor para cada
punto, en vez de dejar que sea la función "scale_colour_gradient" la que
decida el color...

Gracias,
Carlos.

El vie., 20 sept. 2019 a las 10:30, Manuel Mendoza (<
mmend...@fulbrightmail.org>) escribió:

> Gracias Emilio. Si, son asimétricos porque se mueven en rangos distintos.
> De hecho, miden cosas distintas, pero una muestra no puede ser positiva y
> negativa a la vez. Me planteo multiplicar las positivas por 2 y al editar
> el mapa corregirlo para que indique los valores reales. Eso funcionaría,
> pero son muchos mapas y quizás haya una función en ggplot que evite el
> problema directamente.
> Manuel
>
> El vie., 20 sept. 2019 a las 7:38, Emilio L. Cano ( >)
> escribió:
>
> > Hola Manuel,
> >
> > Ten en cuenta que la intensidad del color depende de la escala de la
> > variable. Limits = c(-200, 200) pone los que hay fuera con el color NA
> por
> > defecto (gris). No estoy seguro pero creo que si los positivos no se
> > distingue el color es porque es “casi blanco”, supongo que debido a que
> los
> > datos son muy asimétricos y los valores por debajo de -200 son muy
> grandes
> > en valor absoluto con respecto a los que hay por encima de 200. Y por
> > definición, es una escala de color que depende de la magnitud de la
> > variable.
> >
> > Tal vez puedas mejorar la visualización cambiando el color del punto
> > central (argumento “mid”), en vez de blanco, por algún tono de rojo
> > intermedio.
> >
> > Si esto no lo soluciona intenta pegar el ejemplo con un subconjunto de
> > datos con el que se pueda reproducir (es fácil con datapasta+reprex:
> > https://reprex.tidyverse.org/articles/articles/datapasta-reprex.html)
> >
> > Un saludo,
> > Emilio
> >
> > > El 19 sept 2019, a las 18:34, Manuel Mendoza <
> mmend...@fulbrightmail.org>
> > escribió:
> > >
> > > Muy buenas. Quiero hacer un mapa que me pinte en azul los valores
> > negativos
> > > y en rojo los positivos. Los negativos llegan hasta -400 y los
> positivos
> > > hasta 200. Si pongo  limits=c(-200, 200), me colorea bien los positivos
> > > (rojo), pero los negativos por debajo de -200 me los pone gris.  Si
> pongo
> > > limits=c(-400, 200), me colorea bien los negativos (azul), pero los
> > > positivos apenas se ven. Necesito que me pinte los azules como el
> > primero,
> > > y los azules como el segundo.
> > > Gracias
> > >
> > > Este es el código:
> > >   ggplot(legend=FALSE)+
> > >   theme(panel.background=element_blank())+
> > >   theme(panel.grid.major = element_blank())+
> > >   theme(panel.grid.minor = element_blank())+
> > >
> > > theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
> > >   theme(axis.ticks = element_blank()) + xlab("") +
> ylab("")+
> > >
> > >
> geom_point(data=SGData2,aes(x=lon,y=lat,color=Ch7085),shape=15,size=1.5)
> > +
> > >  * scale_colour_gradient2(limits=c(-400, 200),low =
> > > "blue",high="red",midpoint=0*,
> > >   guide="colourbar")+geom_path(data=world, aes(x=long,
> > > y=lat,group=group))+
> > >   labs(title =  "ch7085")
> > >
> > >   [[alternative HTML version deleted]]
> > >
> > > ___
> > > 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
>


-- 
Saludos,
Carlos Ortega
www.qualityexcellence.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-es] ggplot con gradientes complejos

2019-09-20 Thread Manuel Mendoza
Gracias Emilio. Si, son asimétricos porque se mueven en rangos distintos.
De hecho, miden cosas distintas, pero una muestra no puede ser positiva y
negativa a la vez. Me planteo multiplicar las positivas por 2 y al editar
el mapa corregirlo para que indique los valores reales. Eso funcionaría,
pero son muchos mapas y quizás haya una función en ggplot que evite el
problema directamente.
Manuel

El vie., 20 sept. 2019 a las 7:38, Emilio L. Cano ()
escribió:

> Hola Manuel,
>
> Ten en cuenta que la intensidad del color depende de la escala de la
> variable. Limits = c(-200, 200) pone los que hay fuera con el color NA por
> defecto (gris). No estoy seguro pero creo que si los positivos no se
> distingue el color es porque es “casi blanco”, supongo que debido a que los
> datos son muy asimétricos y los valores por debajo de -200 son muy grandes
> en valor absoluto con respecto a los que hay por encima de 200. Y por
> definición, es una escala de color que depende de la magnitud de la
> variable.
>
> Tal vez puedas mejorar la visualización cambiando el color del punto
> central (argumento “mid”), en vez de blanco, por algún tono de rojo
> intermedio.
>
> Si esto no lo soluciona intenta pegar el ejemplo con un subconjunto de
> datos con el que se pueda reproducir (es fácil con datapasta+reprex:
> https://reprex.tidyverse.org/articles/articles/datapasta-reprex.html)
>
> Un saludo,
> Emilio
>
> > El 19 sept 2019, a las 18:34, Manuel Mendoza 
> escribió:
> >
> > Muy buenas. Quiero hacer un mapa que me pinte en azul los valores
> negativos
> > y en rojo los positivos. Los negativos llegan hasta -400 y los positivos
> > hasta 200. Si pongo  limits=c(-200, 200), me colorea bien los positivos
> > (rojo), pero los negativos por debajo de -200 me los pone gris.  Si pongo
> > limits=c(-400, 200), me colorea bien los negativos (azul), pero los
> > positivos apenas se ven. Necesito que me pinte los azules como el
> primero,
> > y los azules como el segundo.
> > Gracias
> >
> > Este es el código:
> >   ggplot(legend=FALSE)+
> >   theme(panel.background=element_blank())+
> >   theme(panel.grid.major = element_blank())+
> >   theme(panel.grid.minor = element_blank())+
> >
> > theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
> >   theme(axis.ticks = element_blank()) + xlab("") + ylab("")+
> >
> > geom_point(data=SGData2,aes(x=lon,y=lat,color=Ch7085),shape=15,size=1.5)
> +
> >  * scale_colour_gradient2(limits=c(-400, 200),low =
> > "blue",high="red",midpoint=0*,
> >   guide="colourbar")+geom_path(data=world, aes(x=long,
> > y=lat,group=group))+
> >   labs(title =  "ch7085")
> >
> >   [[alternative HTML version deleted]]
> >
> > ___
> > 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] [SPAM] Re: The "--slave" option

2019-09-20 Thread Benjamin Lang
Hi Roy,

Thank you, I’m sorry — I couldn’t resist fitting in a little dig there because 
that’s one of my main frustrations with actually using R, and to me it seemed 
to make some sort of sense because I was complaining about backwardness in a 
way (so a steep learning curve seemed to fit in). The error messages are so 
cryptic that I wonder how anyone ever used R before Google (e.g. 
https://stackoverflow.com/questions/27350636/r-argument-is-of-length-zero-in-if-statement).

I’m a bit appalled 50% of the responses think correctness and not being a jerk 
to some fraction of people is a bad thing and trigger warnings have been 
brought up (in a funny way). I should have done my research and noticed —quiet 
is indeed an existing option, though.

If I had an R-related wish, it would be that “—slave” becomes “-Q” in the 
documentation and is silently maintained for compatibility.

My original post came out of watching “12 Years A Slave” and if you haven’t, I 
recommend it. The powerlessness and ultra-grating injustice and the irony of 
slavery being easily justified by the Bible while abolition is not is an 
experience.

Thanks,
Ben

P.S. Do any R developers actually read this?

> On 19 Sep 2019, at 22:12, Roy Mendelssohn - NOAA Federal 
>  wrote:
> 
> Hi Ben:
> 
> Without commenting one way or another on your point,  your initial post 
> seemed a lot like trolling because of:
> 
>> Let me reiterate that it is 2019, i.e. "The Future", rather than 1970 when
>> R was presumably developed, based on its atrocious syntax, documentation
>> and usability (I think I only need to say "NaN", "NULL", and "NA").
>> 
> 
> You are certainly welcome to your opinions about R,  but these comments are 
> totally aside from what I assume is your main point,  and because of this my 
> first reaction was don't feed the trolls.
> 
> My $0.02.
> 
> -Roy
> 
>> On Sep 19, 2019, at 2:51 AM, Benjamin Lang  wrote:
>> 
>> Dear Richard,
>> 
>> Thank you, that’s interesting. There is also something called an 
>> “etymological fallacy”. I think current usage is more useful here than the 
>> “science of truth”, i.e. the Ancient Greek idea that the (sometimes 
>> inferred) derivation of a word allows us to grasp “the truth of it”. 
>> 
>> In current usage, a “server” is someone who brings you dishes in a 
>> restaurant. A “client” is a customer. A “slave” is a human being forced to 
>> perform work under duress and considered nothing more than a machine, say a 
>> dishwasher or a tractor. And in some regions, this echoes on and is 
>> offensive and hurtful to some.
>> 
>> A new user, wanting to reduce output from R, would probably reach for “-q” 
>> or “—quiet”. This makes sense in the same way that “—stentorian” is not a 
>> good alternative to “—verbose”. 
>> 
>> Best,
>> Ben
>> 
>>> On 19 Sep 2019, at 10:55, Richard O'Keefe  wrote:
>>> 
>>> One of my grandfathers was from Croatia.  Guess what the word "slave" is 
>>> derived
>>> from?  That's right, Slavs.  This goes back to the 9th century.  And then 
>>> of course
>>> my grandfather's people were enslaved by the Ottoman empire, which was only 
>>> defeated
>>> a little over a hundred years ago.  My other grandfather was from the 
>>> British isles,
>>> where to this day followers of the same prophet are enslaving people like me
>>> (except for being female).  So I'm sorry, but I'm not impressed.
>>> 
>>> How many computers are "servers"?  There's that whole client-server thing.
>>> Guess what "server" comes from?  That's right, the Latin word "servus", 
>>> which
>>> means guess what?  You got it again: "slave".  Are we to abolish the word
>>> "server"?  What about the word "client"?  Ah, that's part of the 
>>> client-patron
>>> system from Rome, so what about the patriarchy, eh?
>>> 
>>> We are dealing with something called "the genetic fallacy".
>>> "The genetic fallacy (also known as the fallacy of origins ...)
>>> is a fallacy of irrelevance that is based solely on someone's
>>> or something's history, origin, or source rather than its
>>> current meaning or context."  (Wikipedia.)
>>> 
>>> Context matters.
>>> 
>>> 
>>> 
> On Thu, 19 Sep 2019 at 17:10, Abby Spurdle  wrote:
> Personally I much prefer backwards compatibility to political correctness.
 
 I agree with Rolf, here.
 And as someone that's planning to write a Linux Terminal Emulator, in
 the medium-term future, I *strongly* defend this approach.
 
 And to the original poster.
 Haven't you seen The Matrix?
 (Second best movie ever, after the Shawshank Redemption).
 
 I would prefer the technology to be my slave, than I be a
 prisoner/slave to the technology.
 
 __
 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, 

Re: [R] The "--slave" option

2019-09-20 Thread Francesco Ariis
On Fri, Sep 20, 2019 at 03:14:44PM +1200, Richard O'Keefe wrote:
> The one thing "slave" does not mean in technology is any kind of human
> being.

At risk of repeating what someone else said, we are most likely
not dealing with a human but with a "supernatural being, often
represented as of diminutive size, but sometimes as a giant, and
fabled to inhabit caves, hills, and like places", as from
exhibit A

On Wed, Sep 18, 2019 at 08:00:00AM +0200, Benjamin Lang wrote:
> Let me reiterate that it is 2019, i.e. "The Future", rather than 1970 when
> R was presumably developed, based on its atrocious syntax, documentation
> and usability (I think I only need to say "NaN", "NULL", and "NA").

I suggest not to fatten such a magical creature!

__
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] Help

2019-09-20 Thread Jeff Newmiller
Wrong mailing list. Read the Posting Guide. And use plain-text format to avoid 
us seeing something different than you intended.

On September 19, 2019 7:06:23 AM PDT, "s.rezaalavian--- via R-help" 
 wrote:
>Hello,
>
>I' have just tried to submit a package to CRAN which has a Bioconductor
>dependency. I import "GeneticsPed" in my package but
> when installing it, have this error:
>
>ERROR: dependency 'GeneticsPed' is not available for package 'LRQMM'
>* removing 'C:/Users/.../LRQMM'.
>
>or this check: 
>https://cran.um.ac.ir/web/checks/check_results_LRQMM.html
>
>I tried "biocViews " in description file with empty form, but not been
>succeed.
>
>How can i solving this problem?
>
>Thanks,
>
>Sayyed Reza Alavian
>   [[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.

-- 
Sent from my phone. Please excuse my brevity.

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