{"action":"created","issue":{"url":"https://api.github.com/repos/forestgeo/fgeo.tool/issues/44","repository_url":"https://api.github.com/repos/forestgeo/fgeo.tool","labels_url":"https://api.github.com/repos/forestgeo/fgeo.tool/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/forestgeo/fgeo.tool/issues/44/comments","events_url":"https://api.github.com/repos/forestgeo/fgeo.tool/issues/44/events","html_url":"https://github.com/forestgeo/fgeo.tool/issues/44","id":337649675,"node_id":"MDU6SXNzdWUzMzc2NDk2NzU=","number":44,"title":"Write helpers to categorize data","user":{"login":"maurolepore","id":5856545,"node_id":"MDQ6VXNlcjU4NTY1NDU=","avatar_url":"https://avatars0.githubusercontent.com/u/5856545?v=4","gravatar_id":"","url":"https://api.github.com/users/maurolepore","html_url":"https://github.com/maurolepore","followers_url":"https://api.github.com/users/maurolepore/followers","following_url":"https://api.github.com/users/maurolepore/following{/other_user}","gists_url":"https://api.github.com/users/maurolepore/gists{/gist_id}","starred_url":"https://api.github.com/users/maurolepore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maurolepore/subscriptions","organizations_url":"https://api.github.com/users/maurolepore/orgs","repos_url":"https://api.github.com/users/maurolepore/repos","events_url":"https://api.github.com/users/maurolepore/events{/privacy}","received_events_url":"https://api.github.com/users/maurolepore/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-02T20:19:41Z","updated_at":"2018-07-02T20:19:42Z","closed_at":null,"author_association":"MEMBER","body":"_From @maurolepore on August 31, 2017 16:19_\n\nGabriel proposed to develop a friendly way to categorize (cut) numeric variables. Important ones include:\r\n\r\n* from dbh to size category.\r\n* from gx and gy to quadrat: see `add_quad()`.\r\n\r\n``` r\r\nsuppressPackageStartupMessages(library(fgeo))\r\nx <- tibble::tibble(gx = c(0, 50, 999.9, 1000), gy = gx/2)\r\nadd_quad(x)\r\n#> Gessing: plotdim = c(1000, 500)\r\n#>   * If guess is wrong, provide the correct argument `plotdim`\r\n#> # A tibble: 4 x 3\r\n#>      gx    gy quad \r\n#>   <dbl> <dbl> <chr>\r\n#> 1    0     0  0101 \r\n#> 2   50    25  0302 \r\n#> 3 1000.  500. 5025 \r\n#> 4 1000   500  NANA\r\nadd_quad(x, start = 0)\r\n#> Gessing: plotdim = c(1000, 500)\r\n#>   * If guess is wrong, provide the correct argument `plotdim`\r\n#> # A tibble: 4 x 3\r\n#>      gx    gy quad \r\n#>   <dbl> <dbl> <chr>\r\n#> 1    0     0  0000 \r\n#> 2   50    25  0201 \r\n#> 3 1000.  500. 4924 \r\n#> 4 1000   500  NANA\r\n```\r\n\r\nCreated on 2018-07-02 by the [reprex package](http://reprex.tidyverse.org) (v0.2.0).\n\n_Copied from original issue: forestgeo/fgeo.abundance#46_"},"comment":{"url":"https://api.github.com/repos/forestgeo/fgeo.tool/issues/comments/401921820","html_url":"https://github.com/forestgeo/fgeo.tool/issues/44#issuecomment-401921820","issue_url":"https://api.github.com/repos/forestgeo/fgeo.tool/issues/44","id":401921820,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTkyMTgyMA==","user":{"login":"maurolepore","id":5856545,"node_id":"MDQ6VXNlcjU4NTY1NDU=","avatar_url":"https://avatars0.githubusercontent.com/u/5856545?v=4","gravatar_id":"","url":"https://api.github.com/users/maurolepore","html_url":"https://github.com/maurolepore","followers_url":"https://api.github.com/users/maurolepore/followers","following_url":"https://api.github.com/users/maurolepore/following{/other_user}","gists_url":"https://api.github.com/users/maurolepore/gists{/gist_id}","starred_url":"https://api.github.com/users/maurolepore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maurolepore/subscriptions","organizations_url":"https://api.github.com/users/maurolepore/orgs","repos_url":"https://api.github.com/users/maurolepore/repos","events_url":"https://api.github.com/users/maurolepore/events{/privacy}","received_events_url":"https://api.github.com/users/maurolepore/received_events","type":"User","site_admin":false},"created_at":"2018-07-02T20:19:42Z","updated_at":"2018-07-02T20:19:42Z","author_association":"MEMBER","body":"_From @gabrielareto on August 31, 2017 21:5_\n\nvectorized function to add zeros to each position in character vectors\r\n\r\nadd_zeroes <- add_zeros <- function(x, min.n.char = 4)\r\n{\r\n  n.0s.missing <- pmax(0, min.n.char - nchar(x))\r\n  paste0(strrep(\"0\", n.0s.missing), x)\r\n}\r\n\r\nnote it doesn't work with a matrix, sanity checks required\r\n"}}
{"actor":{"display_login":"maurolepore"}}