Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
I ICOADS R HOSTACE
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 7
    • Issues 7
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • brivas
  • ICOADS R HOSTACE
  • Issues
  • #1

Closed
Open
Created May 18, 2020 by Dave Berry@dybMaintainer

use of R bind in new_merge_ids_year

Iterative use of rbind (i.e. in a loop) leads to poor performance, recommend preallocating data frames and then filling.

Preallocate data frame

Line 399:

tr.add <- c()

replace with

   max_rows = nrow( mdata )
   tr.add <- data.frame( uid <- rep(NA_character_, max_rows), trk = rep(NA_integer_, max_rows), few = rep(NA_integer_, max_rows), 
        speed = rep(NA_real_, max_rows), course = rep(NA_real_, max_rows) )
   row_position <- 0

Fill

Line 461:

tr.add<-rbind(tr.add,data.frame(tr))

replace with

      tr.add[ row_position + 1:length(tr$uid) , ] <- data.frame( tr )
      row_position <- row_position + length(tr$uid)

and then at end of loop between lines 464 and 465 insert

tr.add <- tr.add[ 1:row_position, ]

I've only tested very briefly so the above needs checking fully.

Edited May 18, 2020 by Dave Berry
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking