{"id":14068381,"url":"https://github.com/r-lib/sloop","last_synced_at":"2025-04-04T12:10:25.819Z","repository":{"id":17211970,"uuid":"81364032","full_name":"r-lib/sloop","owner":"r-lib","description":"S language OOP ⛵️","archived":false,"fork":false,"pushed_at":"2024-10-21T13:38:42.000Z","size":1948,"stargazers_count":103,"open_issues_count":7,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-27T04:51:30.647Z","etag":null,"topics":["r","r6","s3","s4"],"latest_commit_sha":null,"homepage":"https://sloop.r-lib.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-lib.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-08T18:50:26.000Z","updated_at":"2025-03-22T11:18:39.000Z","dependencies_parsed_at":"2024-06-21T19:24:09.713Z","dependency_job_id":"05c31dc2-3ef7-4d2f-9f27-5000e5e293dc","html_url":"https://github.com/r-lib/sloop","commit_stats":{"total_commits":74,"total_committers":3,"mean_commits":"24.666666666666668","dds":"0.027027027027026973","last_synced_commit":"0838334631aa45ffcd5bfb6bf69738a44fac49a0"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fsloop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fsloop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fsloop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fsloop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/sloop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174407,"owners_count":20896076,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["r","r6","s3","s4"],"created_at":"2024-08-13T07:06:08.038Z","updated_at":"2025-04-04T12:10:25.801Z","avatar_url":"https://github.com/r-lib.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\"\n)\n```\n\n# sloop \u003ca href=\"https://sloop.r-lib.org\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" alt=\"sloop website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/sloop)](https://cran.r-project.org/package=sloop)\n[![R-CMD-check](https://github.com/r-lib/sloop/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/sloop/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/sloop/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/sloop?branch=main)\n\u003c!-- badges: end --\u003e\n\nThe goal of sloop is to provide tools to help you interactively explore and understand object oriented programming in R, particularly with S3.\n\nPlease note that unlike other [r-lib](https://github.com/r-lib) packages, sloop only works with R 3.3 and later.\n\n## Installation\n\nYou can install sloop from github with:\n\n```{r gh-installation, eval = FALSE}\n# install.packages(\"pak\")\npak::pak(\"r-lib/sloop\")\n```\n\n## Usage\n\n```{r setup}\nlibrary(sloop)\n```\n\nsloop provides a variety of tools for understanding how S3 works. The most useful is probably `s3_dispatch()`. Given a function call, it shows the set of methods that are considered, found, and actually called:\n\n```{r}\ns3_dispatch(print(Sys.time()))\n```\n\nTo the best of my ability it covers all the details of S3 method dispatch including group generics, internal generics, implicit classes, and use of `NextMethod()` (indicated by `-\u003e`):\n\n```{r}\n# Implicit class\nx \u003c- matrix(1:6, nrow = 2)\ns3_dispatch(print(x))\n\n# Internal generic \nlength.numeric \u003c- function(x) 10\ns3_dispatch(length(x))\n\ns3_dispatch(length(structure(x, class = \"numeric\")))\n\n# NextMethod\ns3_dispatch(Sys.Date()[1])\n\n# group generic + NextMethod()\ns3_dispatch(sum(Sys.Date()))\n```\n\nIt also provides tools for determing what type of function or object you're dealing with:\n\n```{r}\nftype(t)\nftype(t.test)\nftype(t.data.frame)\n\notype(1:10)\notype(mtcars)\notype(R6::R6Class()$new())\n```\n\nAnd for retrieving the methods associated with a generic or class:\n\n```{r}\ns3_methods_class(\"factor\")\n\ns3_methods_generic(\"summary\")\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fsloop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Fsloop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fsloop/lists"}