STAT545-UBC / Discussion

Public discussion
37 stars 20 forks source link

Function not found in my R package and not in namespace #532

Open JasmineLib opened 5 years ago

JasmineLib commented 5 years ago

Hey class! I'm really at a loss for what is happening. I am trying to add a function to the R package "powers" for hw07, but it seems that it won't recognize the function I am trying to add. One thing to note, is that in the NAMESPACE file, this function does not show up, although I have exported it (see below).

I've tried restarting R, but beyond this, I have no idea why this function is not being added to the NAMESPACE and/or not being recognized.

This is the code I have:

'#' Apply a useful root

'

'

'@param x the vector for which you want the root

'@param y the integer root that you want to take (ie square root = 2, cube root = 3, etc)

'@param plot_it Display a plot of \code{x} vs the output? Use logical.

' \code{FALSE} by default.

'

'@return A vector that is the:

' \itemize{

' \item root (for \code{root})

'}

' of \code{x}.

'

'

'@rdname root

'@export

root <- function(x, y, plot_it = FALSE) pow(x, a=1/y, plot_it=plot_it)

JasmineLib commented 5 years ago
screen shot 2018-11-13 at 7 20 09 am

Maybe this is a hint - the warning that comes up after checking the package, though after several searches about what this means, I'm still unsure how to fix my issue.

MalcolmNSB commented 5 years ago

Not sure if this is helpful or not, but if you check your auto-generated root.Rd file, do you see \usage{ root(x,y) }? If so then I think this file is being written with the wrong \usage{} somehow, since I as far as I understand about R package documentation, it is looking for \usage{ root(x,y,plot_it) } and doesn't find it.