Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • multiApply multiApply
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 7
    • Issues 7
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Computational Earth SciencesComputational Earth Sciences
  • multiApplymultiApply
  • Issues
  • #10
Closed
Open
Issue created Apr 02, 2020 by Nuria Pérez-Zanón@nperezMaintainer

'C_cor' not found when using cor() in Apply

As reported by @bertvs, Apply returns an error using 'cor' and 'cov' functions.

mod <- seq(1, 2 * 3)
obs  <- seq(1, 2 * 3)
dim(mod) <- c(dataset = 2, member = 3)
dim(obs) <- c(dataset = 2, member = 3)

outp <- Apply(data = list(x = obs, x = mod),
              target_dims = list(x = c("member"), y = c("member")),
              fun = cor)

Error in (function (x, y = NULL, use = "everything", method = c("pearson", : object 'C_cor' not found

To avoid it there are two options:

1.- Declare the function before using it

C_cor <- stats:::C_cor
outp <- Apply(data = list(x = obs, x = mod),
              target_dims = list(x = c("member"), y = c("member")),
              fun = cor)

2.- Define a function using cor:

outp <- Apply(data = list(x = obs, y = mod),
              target_dims = list(x = c("member"), y = c("member")),
              fun = function(x, y){cor(x, y)})

This last case is the one we can use in apply:

apply(mod, 1, function(x){cor(x, c(1,2,3))})

For now, I don't know any fix I can do in Apply code since I think this is a problem from cor function.

Suggestions and ideas are more than welcome.

Cheers,

Núria

Assignee
Assign to
Time tracking