1

I modified an R-Package (gbp) for college and some functions only work if I load them manually.

I tried putting all functions in one script and creating one script for each function. I wrote all functions in the namespace file (export ("function")). I also tried to create one package for each function, but none of it worked.

testfunction1 <- function (sn)
  {
    it <- sn[["it"]]
    it <- it[, list(oid = get("oid"), otid = get("otid"), bid = get("bid"),
                id = get("sku"), x = get("x"), y = get("y"),
                z = get("z"), l = get("l"), d = get("d"),
                h = get("h"), w = get("w"))]
}

For example, when trying to execute this function, it says "object 'oid' not found". sn is a list which I give to the function and sn$it contains all those referred columns("oid", "otid", "bid", ...).

There were several errors, but anything worked fine when I loaded each function manually, so I think the problem is something general.

I would appreciate any help.

Edit: I solved the errors step by step by changing each operation which led to an error. But I still don't know why there are functions which only work when loaded manually but not when integrated in my package.

AlexWue
  • 11
  • 2
  • Yikes, why are you using `get()` here? How exactly are you manually loading a function? Are you running `library()` on your function? I'm not sure I understand exactly what you are doing. Having some sort of [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick May 17 '19 at 17:03
  • The get() was already in the gbp package. I removed this and the error was gone. Yes, I loaded my package with library() and the function was found, but didnt work properly. – AlexWue May 18 '19 at 12:13

0 Answers0