UQRUG 5

meeting
modelling
revtools
uavrst
shiny
Overview: reprex, R 4.0 news
Questions: asymptotic regression model, revtools, uavRst, Shiny
Published

May 18, 2020

2020-05-18: UQRUG 5

We are meeting online again!

Today, we talk about whatever issues you might have, as well as reprex and R 4.0.

Attendees

Feel free to share your contact, specialty and questions here.

  • Steph (UQ Library), technology trainer, likes R and maps and Open Science.
    • Email (work): s.guillou@uq.edu.au ; Social (personal): mastodon
  • Paula
  • I am wondering if some could help me to do asymptotic regression model. Thank you!
  • Ruth - I have seen online a package called “revtools” for screening abstracts and titles of journals, would someone help me with the code (for future reference/projects)
  • … and 11 more R users!

reprex

The reprex website introduces what the reprex package is useful for, i.e. creating reproducible examples: https://reprex.tidyverse.org/

Share your reprex example here!

Steph’s:

# R 4.0 does not import strings as factors by default anymore!

# create a fake dataframe:
df <- data.frame(ID = LETTERS[1:10],
                 gender = sample(c("man", "woman", "enby", "other", "PNS"),
                                 10, replace = TRUE),
                 age = sample(1:100,
                              10, replace = TRUE))

# check class
class(df$gender)
#> [1] "character"

# summary() might be a bit less informative
summary(df)
#>       ID               gender               age       
#>  Length:10          Length:10          Min.   : 5.00  
#>  Class :character   Class :character   1st Qu.:18.00  
#>  Mode  :character   Mode  :character   Median :65.50  
#>                                        Mean   :56.00  
#>                                        3rd Qu.:91.75  
#>                                        Max.   :96.00

Created on 2020-05-18 by the reprex package (v0.3.0)

Topics discussed

  • New in R 4.0:
    • Improved default colour palette: https://developer.r-project.org/Blog/public/2019/11/21/a-new-palette-for-r/index.html
    • New StringsAsFactors default value set to FALSE: https://developer.r-project.org/Blog/public/2020/02/16/stringsasfactors/index.html
    • Matrices inherit the “array” class
  • reprex package for reproducible examples:
    • Official docs: https://reprex.tidyverse.org/
  • Shiny tutorials:
    • Tutorial: https://shiny.rstudio.com/tutorial/
  • Ruth was interested in revtools, which provides “tools for evidence synthesis”:
    • Website: https://revtools.net
    • Function documentation: https://cran.r-project.org/web/packages/revtools/revtools.pdf
  • Resources for learning R:
    • exercism: https://exercism.io
    • Upcoming 1.3 version of RStudio integrates learnr with a new “Tutorial” pane: https://rstudio.com/products/rstudio/download/preview-release-notes/
  • Patrick was interested in uavRst: Unmanned Aerial Vehicle Remote Sensing Toolbox (not on CRAN):
    • Website: https://gisma.github.io/uavRst/
    • It requires quite a few libraries!

Example code used during the meetup:

# R 4.0 updates

# does not import strings as factors by default anymore!

# create a fake dataframe:
df <- data.frame(ID = LETTERS[1:15],
                 gender = sample(c("man", "woman", "enby", "fluid", "other", "PNS"),
                                 15, replace = TRUE),
                 age = sample(1:100, 15, replace = TRUE),
                 score = sample(10:300, 15, replace = TRUE))

# check class
class(df$gender)

typeof(as.factor(df$gender))


# summary() might be a bit less informative
summary(df)

# default palette
plot(df$age, df$score, col = as.factor(df$gender))
# see the values
palette()

# class inheritance
class(diag(1))

# warning when joining datasets with different factor levels
# create two datasets:
df1 <- data.frame(name =  c("blah", "bloh"),
                  height = c(123, 234),
                  stringsAsFactors = TRUE)
df2 <- data.frame(name =  c("blah", "blih"),
                  weight = c(456, 678),
                  stringsAsFactors = TRUE)

# dplyr warns when joining by a key that does not share
# the exact same levels between the two tables
library(dplyr)
joined <- left_join(df1, df2)
# see that it converted to characters for safety
str(joined)
# see that original levels differ
df1$name
df2$name

# revtools
library(revtools)
# show all available data objects
data()

?revtools