Re: [R] Requesting solution for R package

2023-04-24 Thread Ivan Krylov
В Sat, 22 Apr 2023 07:44:11 +0900
Kasun Thalgaskotuwa  пишет:

> My research is based on dynamic causal modelling. Hence I am finding
> some R package which is useful for me.

There's a search system at

that yields a few useful results for your query, in particular the
"dlsem" package.

-- 
Best regards,
Ivan

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


Re: [R] [External Email] Requesting solution for R package

2023-04-24 Thread Christopher Ryan via R-help
I may not be understanding your question, or what you mean by "activate
this package," but in general terms, packages must first be installed, with

install.packages("thepackageIwant")

And then, for any given R session in which you want to use that package:

library(thepackageIwant)

My apologies if you already knew that and are encountering some other
difficulty. If so, providing further details will help.

--Chris Ryan

On Mon, Apr 24, 2023 at 12:58 PM Kasun Thalgaskotuwa <
thalgaskotuwa1...@gmail.com> wrote:

> Dear R team,
> I am struggling with one application of R. My research is based on dynamic
> causal modelling. Hence I am finding some R package which is useful for me.
> that is “dcm”. I want to activate this package to work with dcm, DCM
> functions( dynamic causal model). I kindly expect your help in this regard.
>
> Thank you
> Best regards
> Kasun
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Requesting solution for R package

2023-04-24 Thread Kasun Thalgaskotuwa
Dear R team,
I am struggling with one application of R. My research is based on dynamic
causal modelling. Hence I am finding some R package which is useful for me.
that is “dcm”. I want to activate this package to work with dcm, DCM
functions( dynamic causal model). I kindly expect your help in this regard.

Thank you
Best regards
Kasun

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

2023-04-24 Thread Göran Broström

Den 2023-04-24 kl. 15:14, skrev Ivan Krylov:

В Mon, 24 Apr 2023 15:07:50 +0200
Göran Broström  пишет:


First, you should only ever write a method if you own the generic
or the class.



I was stunned when I read it. I write methods all over the place for
generics like print, summary, plot, etc.


You most likely do that for your own classes. It's sufficient to own
either the generic or the class, though owning both wouldn't hurt.


Thanks, I see. I define a class when I write a method, so no problem. 
What Hadley meant was that I shouldn't rewrite print.lm, for instance.


Göran

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

2023-04-24 Thread Ivan Krylov
В Mon, 24 Apr 2023 15:07:50 +0200
Göran Broström  пишет:

>> First, you should only ever write a method if you own the generic 
>> or the class.

> I was stunned when I read it. I write methods all over the place for 
> generics like print, summary, plot, etc.

You most likely do that for your own classes. It's sufficient to own
either the generic or the class, though owning both wouldn't hurt.

-- 
Best regards,
Ivan

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


[R] Creating methods

2023-04-24 Thread Göran Broström
I am reading Hadley's "Advanced R", Section 13.4.3 
(https://adv-r.hadley.nz/s3.html). It starts



There are two wrinkles to be aware of when you create a new method:

First, you should only ever write a method if you own the generic 
or the class. R will allow you to define a method even if you don’t, but 
it is exceedingly bad manners. Instead, work with the author of either 
the generic or the class to add the method in their code.



I was stunned when I read it. I write methods all over the place for 
generics like print, summary, plot, etc.


So my question is: Do I "own" those generics, or am I just showing bad 
manners?


Thanks, Göran

__
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] Circular plot - polar plot code questions

2023-04-24 Thread Jim Lemon
Hi Bruce,
Reading your message, I get the idea that you want a radial.plot with
arcs to indicate "at least one bat is in this state'.This can be done
with an addition to the rp.type= argument. If you already have what
you want in this format, it may not be worth programming it. However,
if you want "how many bats are in this state":

m <- read.table(
 text="id T month P L
 10100
 20200
 30300
 41400
 51510
 61611
 70711
 80811
 90901
 1001000
 1101100
 1201200",
 header=TRUE)
 library(plotrix)
png("batstate.png",width=600)
kiteChart(t(m[,c("T","P","L")]),
 main="Bat state by month",
 xlab="Month",ylab="State",
 varlabels=c("Testiular enlargement","Pregnant","Lactatins"),
 timelabels=month.abb)
dev.off()

Jim

On Mon, Apr 24, 2023 at 7:22 PM Bruce Miller  wrote:
>
> Hi all...
> I assume there are a host of GGplot2 users out there.
> I have circular plot - polar plot code questions
> I needed to create circular – polar plots of reproductive status for
> bats.  I found a great sample of how to do this here:
> https://stackoverflow.com/questions/41081376/how-to-create-a-circular-plot-showing-monthly-presence-or-absence-using-radial-p
>
> I modified the sample code to meet the 3 data elements I am using the
> "raw data" table below with T=testes enlarge, P= Pregnant and L= Lactating.
>
> library(data.table)
>
>
> m <- fread("idTmonthPL
> 10100
> 20200
> 30300
> 41400
> 51510
> 61611
> 70711
> 80811
> 90901
> 1001000
> 1101100
> 1201200")
> # reshape from wide to long (as preferred by ggplot)
> ml <- melt(m, measure.vars = c("T", "P", "L"))
>
> # create factors to ensure desired order
> ml[, variable := factor(variable, levels = c("T", "P","L"))]
>
> ml[, fct_month := factor(month, levels = 1:12, labels = month.abb)]
> library(ggplot2)
> ggplot(ml[value != 0], aes(x = fct_month, y = variable,
> group = variable, colour = variable)) +
>geom_line(size = 3) +
>scale_y_discrete(expand = c(0, 1), breaks = NULL) +
>xlim(month.abb) +
>coord_polar() +
>theme_bw() + xlab(NULL) + ylab(NULL)
>
> This is creating a plot more or less as needed.  4 questions:
> 1 Do I even need the ID field? Seems not useful.
> 2 I assume the melt step can be avoided if my data is "Tidy" and long
> format at the start, correct?
> 3  How can I increase the weight of the month lines and labels
> 4  Where can I add color choices for the 3 variables in the plot? Simply
> adding an HTML color number to the “colour=variable” then plots the data
> and labeling one value as that color.
>
> Tnx all. The list is always educational on a daily basis.
> Cheers,
> Bat Dude
> [[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] Circular plot - polar plot code questions

2023-04-24 Thread Ebert,Timothy Aaron
1) If you do not need it do not plot it. However, also consider how others will 
use your content. Might it be a trivial piece of information for you, but a 
critical piece of information for someone trying to use your content. A meta 
analysis, or just wanting to try to relate your outcomes to the results from 
their experiment.

2) There would be no need of melt() if the data is already in the proper 
format. The long format is not always the right format, though more often than 
not it is the right format (at least in my field of study).

3) google search something like "x-axis line weight ggplot" or something like 
that. There are excellent online resources to answer focused questions like 
that.

4) This might help: 
https://www.datanovia.com/en/blog/ggplot-colors-best-tricks-you-will-love/



Tim

-Original Message-
From: R-help  On Behalf Of Bruce Miller
Sent: Sunday, April 23, 2023 1:19 PM
To: r-help@r-project.org
Subject: [R] Circular plot - polar plot code questions

[External Email]

Hi all...
I assume there are a host of GGplot2 users out there.
I have circular plot - polar plot code questions I needed to create circular - 
polar plots of reproductive status for bats.  I found a great sample of how to 
do this here:
https://stackoverflow.com/questions/41081376/how-to-create-a-circular-plot-showing-monthly-presence-or-absence-using-radial-p

I modified the sample code to meet the 3 data elements I am using the "raw 
data" table below with T=testes enlarge, P= Pregnant and L= Lactating.

library(data.table)


m <- fread("idTmonthPL
10100
20200
30300
41400
51510
61611
70711
80811
90901
1001000
1101100
1201200")
# reshape from wide to long (as preferred by ggplot) ml <- melt(m, measure.vars 
= c("T", "P", "L"))

# create factors to ensure desired order ml[, variable := factor(variable, 
levels = c("T", "P","L"))]

ml[, fct_month := factor(month, levels = 1:12, labels = month.abb)]
library(ggplot2)
ggplot(ml[value != 0], aes(x = fct_month, y = variable,
group = variable, colour = variable)) +
   geom_line(size = 3) +
   scale_y_discrete(expand = c(0, 1), breaks = NULL) +
   xlim(month.abb) +
   coord_polar() +
   theme_bw() + xlab(NULL) + ylab(NULL)

This is creating a plot more or less as needed.  4 questions:
1 Do I even need the ID field? Seems not useful.
2 I assume the melt step can be avoided if my data is "Tidy" and long format at 
the start, correct?
3  How can I increase the weight of the month lines and labels
4  Where can I add color choices for the 3 variables in the plot? Simply adding 
an HTML color number to the "colour=variable" then plots the data and labeling 
one value as that color.

Tnx all. The list is always educational on a daily basis.
Cheers,
Bat Dude
[[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.


[R] Circular plot - polar plot code questions

2023-04-24 Thread Bruce Miller
Hi all...
I assume there are a host of GGplot2 users out there.
I have circular plot - polar plot code questions
I needed to create circular – polar plots of reproductive status for 
bats.  I found a great sample of how to do this here:
https://stackoverflow.com/questions/41081376/how-to-create-a-circular-plot-showing-monthly-presence-or-absence-using-radial-p

I modified the sample code to meet the 3 data elements I am using the 
"raw data" table below with T=testes enlarge, P= Pregnant and L= Lactating.

library(data.table)


m <- fread("id    T    month    P    L
1    0    1    0    0
2    0    2    0    0
3    0    3    0    0
4    1    4    0    0
5    1    5    1    0
6    1    6    1    1
7    0    7    1    1
8    0    8    1    1
9    0    9    0    1
10    0    10    0    0
11    0    11    0    0
12    0    12    0    0")
# reshape from wide to long (as preferred by ggplot)
ml <- melt(m, measure.vars = c("T", "P", "L"))

# create factors to ensure desired order
ml[, variable := factor(variable, levels = c("T", "P","L"))]

ml[, fct_month := factor(month, levels = 1:12, labels = month.abb)]
library(ggplot2)
ggplot(ml[value != 0], aes(x = fct_month, y = variable,
    group = variable, colour = variable)) +
   geom_line(size = 3) +
   scale_y_discrete(expand = c(0, 1), breaks = NULL) +
   xlim(month.abb) +
   coord_polar() +
   theme_bw() + xlab(NULL) + ylab(NULL)

This is creating a plot more or less as needed.  4 questions:
1 Do I even need the ID field? Seems not useful.
2 I assume the melt step can be avoided if my data is "Tidy" and long 
format at the start, correct?
3  How can I increase the weight of the month lines and labels
4  Where can I add color choices for the 3 variables in the plot? Simply 
adding an HTML color number to the “colour=variable” then plots the data 
and labeling one value as that color.

Tnx all. The list is always educational on a daily basis.
Cheers,
Bat Dude
[[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 with bootstrap sampling with rms package in R

2023-04-24 Thread Munveer Thind via R-help
Hi all,

I appreciate any help that can be offered and don’t mind sending a fee to 
anyone that can help. 

I am a physician and am writing a paper to be submitted to a medical journal 
and am performing bootstrap internal validation by the Harrell method using the 
R package called rms. It’s a multi variable logistic regression model. I have 
done the 1000 sample bootstrap and generated Dxy which I have converted to AUC. 
But I also want to illustrate with a histogram of all the 1000 AUC values 
generated from the training AUC from each bootstrap model. 

Reaching out for help with this, thanks in advance. 

Best,

Munveer

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