Re: [R] Style guide when using "R" in a title

2023-07-26 Thread Uwe Ligges




On 26.07.2023 23:48, Wadsworth, Spencer G [STAT] wrote:

Hello,

I am working on a small booklet to be used with an existing statistics textbook. The purpose of the 
booklet is to give worked through examples from the textbook using R code and it will be made 
publicly available with the textbook. The title of the booklet is "R Code Supplement for Basic 
Engineering Data Collection and Analysis by Vardeman and Jobe".  Someone with whom I'm working 
on the booklet said that the "R" in the title might need to follow a specific style guide 
given by the R-project. Is this accurate? Is there a particular font I should use?


You can simply write the title as is.

Best,
Uwe Ligges



Thanks,
Spencer

[[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] Style guide when using "R" in a title

2023-07-26 Thread Bert Gunter
https://www.r-project.org/logo/

Cheers,
Bert

On Wed, Jul 26, 2023 at 4:01 PM Wadsworth, Spencer G [STAT]
 wrote:
>
> Hello,
>
> I am working on a small booklet to be used with an existing statistics 
> textbook. The purpose of the booklet is to give worked through examples from 
> the textbook using R code and it will be made publicly available with the 
> textbook. The title of the booklet is "R Code Supplement for Basic 
> Engineering Data Collection and Analysis by Vardeman and Jobe".  Someone with 
> whom I'm working on the booklet said that the "R" in the title might need to 
> follow a specific style guide given by the R-project. Is this accurate? Is 
> there a particular font I should use?
>
> Thanks,
> Spencer
>
> [[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] Style guide when using "R" in a title

2023-07-26 Thread Wadsworth, Spencer G [STAT]
Hello,

I am working on a small booklet to be used with an existing statistics 
textbook. The purpose of the booklet is to give worked through examples from 
the textbook using R code and it will be made publicly available with the 
textbook. The title of the booklet is "R Code Supplement for Basic Engineering 
Data Collection and Analysis by Vardeman and Jobe".  Someone with whom I'm 
working on the booklet said that the "R" in the title might need to follow a 
specific style guide given by the R-project. Is this accurate? Is there a 
particular font I should use?

Thanks,
Spencer

[[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] Survival questions

2023-07-26 Thread Stats Student
Hi - I am using the survfit() function to produce Kaplan-Meier
survival curves for several different groups.

survfit (Surv() ~ cohort, data=d)

Everything works fine, but I'd like to do something different.

I have a 12 month survival curve (base) and I also have two survival
curves based on some experiment that only go out to 3 months. What I
would like to do is take the 3 month realized curves and apply the 3+
month hazard from the base curve to those.

1) is this a reasonable approach? (short of building a full-fledged model)
2) is there a standard way of doing this? I was going to read the
survival curves, calc the hazard (S(t) / S(t-1)), apply it to the
realized (short) curves. Related to that, from the survfit() object,
how do I read various curves specific to a particular cohort?
Everything appears to be concatenated together but I am guessing there
is some way to separate based on particular strata.

Thanks in advance.

__
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] Seeking Assistance: Plotting Sea Current Vectors in R

2023-07-26 Thread konstantinos christodoulou
Thank you Jim for your response. I will try it now and then let you know if
it works.

Kind regards,
Kostas

On Wed, Jul 26, 2023 at 1:59 AM Jim Lemon  wrote:

> Hi Kostas,
> The function vectorField in the plotrix package may do what you want.
> See the example.
>
> Jim
>
> On Tue, Jul 25, 2023 at 9:30 PM konstantinos christodoulou
>  wrote:
> >
> > Dear Rcommunity,
> >
> > I hope this email finds you well. I am writing to seek your assistance
> with
> > a data visualization problem I am facing while working with R.
> >
> > Problem Description:
> >
> > I have a dataframe named "df" containing the following columns:
> > "longitude", "latitude", "sea_currents_mag", and
> "sea_currents_direction".
> > The dataframe includes sea current estimations, with information about
> > magnitude (m/s) and direction (degrees) at various longitude and latitude
> > coordinates. The study domain covers the Eastern Mediterranean Sea (23E
> to
> > 36W) and extends from 31S to 37N. It is important to note that the
> > longitude and latitude coordinates are not evenly spaced across the
> domain.
> >
> > Objective: I am seeking guidance on how to create a plot that visualizes
> > the sea current vectors (arrows) at each coordinate. Additionally, if
> > possible, I would like the borders of the surrounding countries to be
> > included in the plot to provide geographic context.
> >
> > Specific Requests:
> >
> >1. Help with plotting sea current vectors (arrows) based on
> >"sea_currents_mag" and "sea_currents_direction" at each corresponding
> >longitude and latitude coordinate.
> >2. Assistance with including the borders of the surrounding countries
> in
> >the plot to provide geographic context.
> >
> > I would highly appreciate any advice, code examples, or packages that
> could
> > assist me in achieving this visualization goal.
> >
> > Thank you very much for taking the time to read my email, and I look
> > forward to any assistance you can provide.
> >
> > Best regards,
> > Kostas
> >
> > [[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] plotly

2023-07-26 Thread Kimmo Elo
Hi,

ke, 2023-07-26 kello 02:04 +, Thomas Subia via R-help kirjoitti:
> Question 1:How can I save the plotly graph with a specific graph
> size?Using ggsave, one can define the height, width and unit of
> measure, is there something similar in plotly?Since I am creating the
> same gauge plot but with different data, I'd like all the resulting
> graphs to have the same size. I've googled this but to no avail,

Maybe this: plotly_IMAGE

See ?plotly_IMAGE for details, especially 'height' and 'width' should
be of interest for you.

> Question 2:How can I adjust the tick marks of the gauge? Ideally the
> tick marks should be set at seq(0,9600,1200)

Try this (notice 'tickvals' in gauge/axis:

--- snip ---

plot_ly(
domain = list(x = c(0, .5), y = c(0,0.5)),
value = 319,
title = list(text = "Example\n4,800 Target",font=t),
type = "indicator",
mode = "gauge+number+delta",
number = list(valueformat = "%.2f",font=t5), 
delta = list(reference = 4800, valueformat = "%.2f",font=t3),
gauge = list(
axis = list(range = list(NULL, 9600), 
tickformat = "%d",
tickvals = seq(0,9600,1200),
tickfont = list(size = 12, face="bold",family =
"Arial")),
bar = list(color = "black"),
steps = list(
list(range = seq(0, 4800,1200), color = 'AAFF00'),
list(range = seq(4800, 9600,1200), color = 'ffb2b2')),
threshold = list(
line = list(color = "black", width = 8),
thickness = 0.75,
value = 4800)))

--- snip ---

HTH,

Kimmo

__
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] Downloading a directory of text files into R

2023-07-26 Thread Bob Green

Rui,

Many thanks for  your reply and coding, I was not 
expecting so much work was required. It worked perfectly.


The only thing I needed to do, was create a Temp file in the Documents folder.

Thanks again,


Bob

At 03:52 PM 7/26/2023, Rui Barradas wrote:

Às 23:06 de 25/07/2023, Bob Green escreveu:

Hello,
I am seeking advice as to how I can download 
the 833 files from this site:"http://home.brisnet.org.au/~bgreen/Data/;

I want to be able to download them to perform a textual analysis.
If the 833 files, which are in a Directory with 
two subfolders were on my computer I could read 
them through readtext. Using readtext I get the error:

 > x = readtext("http://home.brisnet.org.au/~bgreen/Data/*;)
Error in download_remote(file, ignore_missing, cache, verbosity) :
 Â  Remote URL does not end in known 
extension. Please download the file manually.

 > x = readtext("http://home.brisnet.org.au/~bgreen/Data/Dir/()")
Error in download_remote(file, ignore_missing, cache, verbosity) :
 Â  Remote URL does not end in known 
extension. Please download the file manually.

Any suggestions are appreciated.
Bob
__
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,

The following code downloads all files in the posted link.



suppressPackageStartupMessages({
  library(rvest)
})

# destination directory, change this at will
dest_dir <- "~/Temp"

# first get the two subfolders from the Data webpage
link <- "http://home.brisnet.org.au/~bgreen/Data/;
page <- read_html(link)
page %>%
  html_elements("a") %>%
  html_text() %>%
  grep("/$", ., value = TRUE) -> sub_folder

# create relevant disk sub-directories, if
# they do not exist yet
for(subf in sub_folder) {
  d <- file.path(dest_dir, subf)
  if(!dir.exists(d)) {
success <- dir.create(d)
msg <- paste("created directory", d, "-", success)
message(msg)
  }
}

# prepare to download the files
dest_dir <- file.path(dest_dir, sub_folder)
source_url <- paste0(link, sub_folder)

success <- mapply(\(src, dest) {
  # read each Data subfolder
  # and get the file names therein
  # then lapply 'download.file' to each filename
  pg <- read_html(src)
  pg %>%
html_elements("a") %>%
html_text() %>%
grep("\\.txt$", ., value = TRUE) %>%
lapply(\(x) {
  s <- paste0(src, x)
  d <- file.path(dest, x)
  tryCatch(
download.file(url = s, destfile = d),
warning = function(w) w,
error = function(e) e
  )
})
}, source_url, dest_dir)

lengths(success)
# http://home.brisnet.org.au/~bgreen/Data/Hanson1/
#   84
# http://home.brisnet.org.au/~bgreen/Data/Hanson2/
#  749

# matches the question's number
sum(lengths(success))
# [1] 833



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.