Re: [R] Question about italics in legendg() - plotrix

2023-02-14 Thread Jim Lemon
Hi Nicole,
plotrix is intended to be modular, that is, it builds plots step by step.
This makes it easier to understand code that you haven't written or haven't
seen for a while. Here is an example showing how to change the font using
par():

library(plotrix)
plot(0,type="n",xlim=c(0,1),ylim=c(-1,0))
par(font=3)
legendg(0.115,-0.055,legend=c("Pan troglodytes","Macaca mulatta",
 "Saguinus oedipus","Lemur catta","Galago senegalensis"),
pch=list(c(15,0),c(16,1),c(17,2),c(18,5),c(19,10)),
 col=list(c("royalblue","skyblue1"),
 c("chocolate","gold"),c("deeppink","lightpink"),
 c("black","grey"),c("forestgreen","lightgreen")))
par(font=1)
legendg(0.45,-0.7,legend=c("Pan troglodytes","Macaca mulatta",
 "Saguinus oedipus","Lemur catta","Galago senegalensis"),
pch=list(c(15,0),c(16,1),c(17,2),c(18,5),c(19,10)),
 col=list(c("royalblue","skyblue1"),
 c("chocolate","gold"),c("deeppink","lightpink"),
 c("black","grey"),c("forestgreen","lightgreen")))

There are 4 or 5 preset font types built into R (normal, bold, italic,
bolditalic and maybe symbol). You can also change the base font using the
family= argument to par(), but that's quite a bit more complicated.

Jim

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

2023-02-14 Thread Dr. Brandon Guida via R-help
Hi all, 
I'm creating Venn's using ggVennDiagram and I can print the intersection tibble 
using the process_region_data() function but I cannot figure out how to print 
the components of each intersection (the lists of intersection elements)? Can 
anyone help me here? Ultimately I want to extract these to a csv.

Brandon

[[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] latticeExtra: how to use doubleYScale when we want to keep the groups of every lattice graph

2023-02-14 Thread Laurent Rhelp

It is great !
I had not thought to use the value 0 for the variables style1 and 
style2. I did not well understand when reading the documentation.

Thank you
Laurent


Le 13/02/2023 à 19:04, Deepayan Sarkar a écrit :

On Mon, Feb 13, 2023 at 3:48 AM Laurent Rhelp  wrote:

Dear R-Help-list,

   I want to use the doubleYScale function from latticeExtra to overlap two
lattice graphs (cf. code below). The overlapping works but I lose the
groups of
every lattice, there are only two colors. Reading the documentation,
the arguments style1 and style2 give me the impression that it is not
possible to keep the groups of every lattice.

I'm mostly guessing from looking at the examples, but is this what you want?

gr_Gx_Tx <- latticeExtra::doubleYScale(gr_Gx, gr_Tx, style1 = 0, style2 = 0)

Best,
-Deepayan


Is there any possibility to keep the groups of every lattice graph with
the doubleYScale function ?

Or, might you give me some orientations to realize the graph keeping the
groups using the lattice package ?

Thank you

Best regards

Laurent

#-o<-->o-
library(lattice)
library(latticeExtra)
##
## creation of the first lattice graph gr_Gx with a group of two elements
##
lattice.par <- trellis.par.get()
my.superpose.line  <- lattice.par$superpose.line
my.superpose.line$col[1:2] <- c("black","red")
gr_Gx <- xyplot( value ~ time | region
, data = df.m
, subset = sensor %in% c("G2","G4")
, group = sensor
, type ="l"
, scales = list( y = list(log=10)
 , x = list(relation="free", axs =
"i", abbreviate=TRUE))
, yscale.components = yscale.components.log10ticks
, par.settings = list(
  superpose.line = my.superpose.line
)
)
print(gr_Gx)
##
## creation of the second lattice graph gr_Tx with a group of five elements
##
lattice.par <- trellis.par.get()
my.superpose.line  <- lattice.par$superpose.line
my.superpose.line$col[1:5] <- c(1,2,3,4,5)
gr_Tx <-  xyplot( value ~ time | region
 , group = sensor
 , subset = sensor %in% c("T1","T2","T3","T4","T5")
 , data= df.m
 , type = "l"
 , scales = list( x= list( axs = "i", relation = "free"
   , abbreviate = TRUE))
 , par.settings = list( superpose.line =
my.superpose.line )
)
print(gr_Tx)
##
## overlap the two lattice graphs
## We lost the groups of every lattice
##
gr_Gx_Tx <- latticeExtra::doubleYScale(gr_Gx, gr_Tx)
print(gr_Gx_Tx)

#o<-->o-

The data :

df.m <- structure(list(time = c(0.000250101089477539, 0.000250101089477539,
   0.000250101089477539, 0.000250101089477539, 0.000250101089477539,
   0.000250101089477539, 0.000250101089477539, 0.000500202178955078,
   0.000500202178955078, 0.000500202178955078, 0.000500202178955078,
   0.000500202178955078, 0.000500202178955078, 0.000500202178955078,
   0.000750064849853516, 0.000750064849853516, 0.000750064849853516,
   0.000750064849853516, 0.000750064849853516, 0.000750064849853516,
   0.000750064849853516, 0.00100016593933105, 0.00100016593933105,
   0.00100016593933105, 0.00100016593933105, 0.00100016593933105,
   0.00100016593933105, 0.00100016593933105, 0.00125002861022949,
   0.00125002861022949, 0.00125002861022949, 0.00125002861022949,
   0.00125002861022949, 0.00125002861022949, 0.00125002861022949,
   0.00150012969970703, 0.00150012969970703, 0.00150012969970703,
   0.00150012969970703, 0.00150012969970703, 0.00150012969970703,
   0.00150012969970703, 0.00175023078918457, 0.00175023078918457,
   0.00175023078918457, 0.00175023078918457, 0.00175023078918457,
   0.00175023078918457, 0.00175023078918457, 0.0029346008301,
   0.0029346008301, 0.0029346008301, 0.0029346008301,
   0.0029346008301, 0.0029346008301, 0.0029346008301,
   0.00225019454956055, 0.00225019454956055, 0.00225019454956055,
   0.00225019454956055, 0.00225019454956055, 0.00225019454956055,
   0.00225019454956055, 0.00250005722045898, 0.00250005722045898,
   0.00250005722045898, 0.00250005722045898, 0.00250005722045898,
   0.00250005722045898, 0.00250005722045898, 0.00275015830993652,
   0.00275015830993652, 0.00275015830993652, 0.00275015830993652,
   0.00275015830993652, 0.00275015830993652, 0.00275015830993652,
   0.0032098083496, 0.0032098083496, 0.0032098083496,
   0.0032098083496, 0.0032098083496, 0.0032098083496,
   0.0032098083496, 0.0032501220703125, 0.0032501220703125,
   0.0032501220703125, 0.0032501220703125, 0.0032501220703125,
0.0032501220703125,
   0.0032501220703125, 0.00350022315979004, 0.00350022315979004,
   0.00350022315

Re: [R] TRCUKING 4

2023-02-14 Thread Rui Barradas

Às 03:22 de 14/02/2023, Mohammad Shoushary escreveu:

Hi Guys,
If I have a question, what is the best way to ask or post?

On Tue, Nov 9, 2021 at 6:13 AM Rui Barradas  wrote:


Hello,

We can't really answer your question, we don't have access to the file.
But here are some questions/tips.

1. R is case sensitive, is it TRUCKING.RDtata or TRUCKING.Rdtata?
2. In a clean R session, is there any warning or error message after
running load("TRUCKING.Rdata")?
3. If not, what is the output of ls()? This will give you the objects in
the global environment and RData files may store many objects. Exactly
what was loaded?
4. I don't understand what do you mean by "trucking 4". Is it the name
of a data set you expect to be in that file? If the file with "4
carriers" was loaded, try running str(tablename) to see its structure.
(tablename is to be replaced by the table's actual name).


Hope this helps,

Rui Barradas


Às 16:19 de 07/11/21, Mohammad Shoushary escreveu:

Hi Guys,
I wonder how to opt trucking 4 once loading "TRUCKING" file.
I loaded: load("TRUCKING.Rdata")
but I  4 carrierneed the file that hass, any clue please? I appreciate it


Mohammad

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







Hello,

Start by reading the posting guide:

https://www.r-project.org/posting-guide.html

Here are some additional instructions:

https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Also, see if package reprex can be of help.

Hope this helps,

Rui  Barradas

__
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] Plotting prediction curves and CIs from GAM models

2023-02-14 Thread Adriaan de Jong
Dear List member,
My data are from 30 years of opportunistic counting of migratory Eurasian 
Curlew (Numenius arquata) during the core breeding season when the local 
population is supposed to be stable. My main objective is the trend in numbers 
over the years, but information about sighting efficiency over the days of 
season (DoS) and the time of the day (ToD) is also desired (they are not just 
nuisance variables). Observations were made while driving along the very same 
25 km road in rural northern Sweden. This driving was for everyday life 
purposes, not for the sake of this study, i.e. the data are virtually 
zero-cost, zero-effort and zero-emission. For each counting event (N=1020), I 
registered date, midpoint-time (5 AM - 9 PM) and observed number of curlews. 
The date was used to create variables Year (integer) and Day-of-Season 
(integer, May 1 = 1 to June 14, leap-year adjusted). The ToD variable was 
expressed as decimal hours (e.g. 8.15)  I chose to use GAM-family models to 
describe the Count vs Year, DoS and ToD relationship (subset listed below, full 
dataset available at request). A overdisp_fun check of the Poisson distribution 
GAMs showed that a shift to negative binomial distribution (.. nb()..) GAMs was 
appropriate.

Preliminary model selection favoured the following model (Total = count result):

mod1<-gam(Total~s(Year) +
   te(DoS,ToD, k=5),
   family=nb(),
   data=Trend1,
   method="ML")

The model explained 38.8% of overall deviance. Model check-ups (gam.check, 
qq.gam and overdisp_fun) were all satisfactory.

plot.gam(mod1) (and plot(mod1)) produced a s(Year)~Year curve with confidence 
interval lines and a ToD vs DoS "topography" plot with CI lines (PDF-copies 
attached). From what I understand, these curves/lines show estimated smoother 
and tensor values, respectively. These are useful plots for scientists, but not 
really what I want to present to non-academic ornithologists.

In the next step, I used

preddata<-predict.gam(newdata=Trend1, mod1, type="response")

to produce a predicted dataset for the same (original) data and

plot(preddata~Trend1$Year, xlab = "Year", ylab="Predicted Eurasian Curlew 
counts")

to visualize the trend in numbers over the study period (scatterplot attached).

Here is where my questions start.

1. How can I fit a GAM-type trendline in this graph and how can I add upper and 
lower CI-limits to this trendline? It's the complex GAM structure that confuses 
me. Are these model components in the model output somewhere? Will this 
trendline be "rinsed" from the effects of DoS and ToD? If not, how can I 
find/create one?

2. How can I produce a "topography"-plot of the predicted count numbers over 
ToD vs DoS, similar to the one for the tensor estimates produced by plot.gam?


Thanks in advance for any references, comments and suggestions.
Have a nice day,
Adriaan de Jong
Swedish University of Agricultural Sciences


Data structure

Year   DoS   ToD Total
1993 6  9.25   7
1993   1112.50   4
.
.
.
2022407.753
---
När du skickar e-post till SLU så innebär detta att SLU behandlar dina 
personuppgifter. För att läsa mer om hur detta går till, klicka här 

E-mailing SLU will result in SLU processing your personal data. For more 
information on how this is done, click here 



AskR1.pdf
Description: AskR1.pdf


AskR2.pdf
Description: AskR2.pdf


AskR3.pdf
Description: AskR3.pdf
__
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] Issue with Rmath standalone (dwilcox, pwilcox, qwilcox, rwilcox) with unif_rand()

2023-02-14 Thread Mark Clements via R-help
I may have found a bug in the Rmath standalone library when providing a 
user-defined random number generator (for context, I was investigating using 
Mersenne Twister with Rmath). The following C code does not compile using the 
Makefile:

// test_fails.c
#define MATHLIB_STANDALONE
#include 
#include 

double unif_rand(void) { return 0.5; }

int main() {
  printf("%f\n", runif(0, 1));
  printf("%f\n", pnorm(1.96, 0, 1, 1, 0));
  printf("%f\n", dwilcox(100, 10, 20, 0));
  return 0;
}

// Makefile
LIBRMATH_A = $(shell pkg-config --variable=libdir libRmath)/libRmath.a
test_fails:
  gcc -o test_fails test_fails.c ${LIBRMATH_A} -lm

The error is "multiple definition of `unif_rand'". The code compiles and runs 
correctly after commenting out either (a) the unif_rand function or (b) the 
call to dwilcox(). I found similar issues with pwilcox, qwilcox and rwilcox. 
Can anyone explain this behaviour, please?

Sincerely, Mark.


När du skickar e-post till Karolinska Institutet (KI) innebär detta att KI 
kommer att behandla dina personuppgifter. Här finns information om hur KI 
behandlar personuppgifter.


Sending email to Karolinska Institutet (KI) will result in KI processing your 
personal data. You can read more about KI’s processing of personal data 
here.
__
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.