Can't find documentation for r function in newly created package

Hi,

creating my first ever R package.
Here is my simple function.R file:

#' title applies BT font and colour schemes to ggplot2 plots
#'
#' description This function overrides the theme function from ggplot2 and makes it specific to BT brand colour scheme and fonts
#' param axis.text.size  axis text size for both x and y axis
#' param legend.title.text.size plot Legend title size
#' param plot.title.text.size plot title text size
#' param legend.position plot legend position i.e. top, bottom etc.
#' param axis.title.size axis title text size
#' export
#' seealso \code{\link[ggplot2]{theme}}
#' examples \dontrun{
#' ggplot2()+
#' theme_BT()
#' }
theme_BT <- function (axis.text.size = 12,legend.title.text.size =17,plot.title.text.size=20,legend.position="top",axis.title.size =14 ) {

  theme(plot.background = element_blank(),
        panel.background = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.position = legend.position,
        axis.title.y = element_text(family = "BT Font", face="bold", size=axis.title.size),
        axis.title.x = element_text(family = "BT Font", face="bold", size=axis.title.size),
        axis.text.y=element_text(family = "BT Font",size=axis.text.size, face = "bold"),
        axis.text.x=element_text(family = "BT Font",size=axis.text.size, face = "bold"),
        axis.ticks.x=element_blank(),
        axis.ticks.y=element_blank(),
        strip.background =element_rect(fill="#666666"),
        # strip.text = element_text(colour = 'white'),
        plot.title = element_text(family = "BT Font", face="bold", size=plot.title.text.size, hjust=0),
        strip.text.x = element_text(family = "BT Font",size = axis.title.size, face = "bold",colour = "white",lineheight=3),
        strip.text.y = element_text(family = "BT Font",size = axis.title.size, face = "bold",colour = "white"),
        legend.text=element_text(family = "BT Font",size=text.size,face = "bold"),
        legend.title = element_text(family = "BT Font",size=legend.title.text.size,face = "bold"))

}

(had to remove @ sign above coz it wont let me post and treating it as if i am mentioning a community user)and here is the DESCRIPTION file:

Package: textsummary
Type: Package
Title: Text Summaries Functions
Version: 0.1.0
Date: 2018-08-01
Author: Fahad Usman
Maintainer: Fahad Usman <fahad.usman@bt.com>
Description: This package contains useful functions to generate textual data summaries. You can create plots for top 10 single, double and three words plots. Perform LDA modelling. Create summary plots for group variable or a group variable by different segments of another group variable.
License: GPL-2
Encoding: UTF-8
LazyData: true
Imports:
        ggplot2, 
        janitor,
        textstem,
        sentimentr,
        pluralize,
        textclean,
        magrittr,
        tidyverse,
        lda,
        lubridate,
        scales,
        tidytext,
        stringr,
        devtools,
Suggests:
        knitr
RoxygenNote: 6.1.0

RStudio build fails because it cant find devtools. when I did devtools::document() it worked and generated NAMESPACE

# Generated by roxygen2: do not edit by hand

export(theme_BT)

and theme_BT.RD which looks like this:

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/textfunc.R
\name{theme_BT}
\alias{theme_BT}
\title{applies BT font and colour schemes to ggplot2 plots}
\usage{
theme_BT(axis.text.size = 12, legend.title.text.size = 17,
  plot.title.text.size = 20, legend.position = "top",
  axis.title.size = 14)
}
\arguments{
\item{axis.text.size}{axis text size for both x and y axis}

\item{legend.title.text.size}{plot Legend title size}

\item{plot.title.text.size}{plot title text size}

\item{legend.position}{plot legend position i.e. top, bottom etc.}

\item{axis.title.size}{axis title text size}
}
\description{
This function overrides the theme function from ggplot2 and makes it specific to BT brand colour scheme and fonts
}
\examples{
\dontrun{
ggplot2()+
theme_BT()
}
}
\seealso{
\code{\link[ggplot2]{theme}}
}

I can attach the new package using library(textsummary) but it can't find help for the function?
I can also access the theme_BT function. but it also fails to load theme function from ggplot2.

What am I missing?

First thing first - please, format your code as code. For that, you need to put your code into backticks like so:

```
your_code_here
```

This will make it MUCH easier to see what you are trying to do and provide help

1 Like

oops. sorry, used to stackoverflow ticks. please check out again

1 Like

what happens if you type help(p = "textsummary") in console? Can you see your function there?
To me, your Rd file looks OK, so not sure what is the problem.

RStudio build fails because it cant find devtools. when I did devtools::document() it worked

Your package project has the help document, but my guess is the package in your library doesn't because you never replaced it. If the build failed, the package wasn't "bundled," and your installed version is an older one without the help file.