{
  "name": "How each tie rule ranks the tied values in c(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5), by R and Python function",
  "description": "Compares tie-handling rules for rank functions in base R, dplyr, data.table and SciPy. For each rule it lists the equivalent function documented by each package and the ranks given to the two tied 1s and the three tied 5s in the example vector from the R base manual. The ranks were derived by applying each documented rule to that vector; function equivalences come from the four package manuals.",
  "page": "https://casrai.org/guides/rank-in-r",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-17T20:51:59Z",
  "temporalCoverage": null,
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Tie rule",
      "unit": "",
      "description": ""
    },
    {
      "name": "Base R rank()",
      "unit": "",
      "description": ""
    },
    {
      "name": "dplyr",
      "unit": "",
      "description": ""
    },
    {
      "name": "data.table frank()",
      "unit": "",
      "description": ""
    },
    {
      "name": "SciPy rankdata()",
      "unit": "",
      "description": ""
    },
    {
      "name": "Ranks given to the two 1s",
      "unit": "",
      "description": ""
    },
    {
      "name": "Ranks given to the three 5s",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Tie rule": "average",
      "Base R rank()": "ties.method = \"average\" (default)",
      "dplyr": "none documented on the row_number page",
      "data.table frank()": "ties.method = \"average\" (default)",
      "SciPy rankdata()": "method='average' (default)",
      "Ranks given to the two 1s": "1.5, 1.5",
      "Ranks given to the three 5s": "8, 8, 8"
    },
    {
      "Tie rule": "min",
      "Base R rank()": "ties.method = \"min\"",
      "dplyr": "min_rank()",
      "data.table frank()": "ties.method = \"min\"",
      "SciPy rankdata()": "method='min'",
      "Ranks given to the two 1s": "1, 1",
      "Ranks given to the three 5s": "7, 7, 7"
    },
    {
      "Tie rule": "max",
      "Base R rank()": "ties.method = \"max\"",
      "dplyr": "none documented on the row_number page",
      "data.table frank()": "ties.method = \"max\"",
      "SciPy rankdata()": "method='max'",
      "Ranks given to the two 1s": "2, 2",
      "Ranks given to the three 5s": "9, 9, 9"
    },
    {
      "Tie rule": "dense",
      "Base R rank()": "none",
      "dplyr": "dense_rank()",
      "data.table frank()": "ties.method = \"dense\"",
      "SciPy rankdata()": "method='dense'",
      "Ranks given to the two 1s": "1, 1",
      "Ranks given to the three 5s": "5, 5, 5"
    },
    {
      "Tie rule": "first / ordinal",
      "Base R rank()": "ties.method = \"first\"",
      "dplyr": "row_number()",
      "data.table frank()": "ties.method = \"first\"",
      "SciPy rankdata()": "method='ordinal'",
      "Ranks given to the two 1s": "1, 2",
      "Ranks given to the three 5s": "7, 8, 9"
    },
    {
      "Tie rule": "last",
      "Base R rank()": "ties.method = \"last\"",
      "dplyr": "none documented on the row_number page",
      "data.table frank()": "ties.method = \"last\"",
      "SciPy rankdata()": "none",
      "Ranks given to the two 1s": "2, 1",
      "Ranks given to the three 5s": "9, 8, 7"
    }
  ],
  "sources": [
    {
      "title": "R base manual: rank",
      "url": "https://stat.ethz.ch/R-manual/R-devel/library/base/html/rank.html",
      "accessed": "2026-11-17"
    },
    {
      "title": "dplyr: row_number, min_rank, dense_rank",
      "url": "https://dplyr.tidyverse.org/reference/row_number.html",
      "accessed": "2026-11-17"
    },
    {
      "title": "data.table: frank",
      "url": "https://rdatatable.gitlab.io/data.table/reference/frank.html",
      "accessed": "2026-11-17"
    },
    {
      "title": "SciPy: scipy.stats.rankdata",
      "url": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rankdata.html",
      "accessed": "2026-11-17"
    }
  ]
}