{"id":18247071,"url":"https://github.com/badbye/rpro","last_synced_at":"2025-04-08T19:35:28.417Z","repository":{"id":66176014,"uuid":"51134135","full_name":"badbye/rpro","owner":"badbye","description":"Run R Function in Terminal Quickly","archived":false,"fork":false,"pushed_at":"2016-02-06T10:56:28.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T15:17:19.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/badbye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-05T08:08:02.000Z","updated_at":"2017-05-01T17:15:25.000Z","dependencies_parsed_at":"2023-02-21T16:45:23.688Z","dependency_job_id":null,"html_url":"https://github.com/badbye/rpro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frpro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frpro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frpro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frpro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badbye","download_url":"https://codeload.github.com/badbye/rpro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247913014,"owners_count":21017081,"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":[],"created_at":"2024-11-05T09:28:55.896Z","updated_at":"2025-04-08T19:35:28.396Z","avatar_url":"https://github.com/badbye.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rpro\nRun R function in terminal quickly\n\n\n## Install\n\nInstall from github:\n```R\ndevtools::install_github('badbye/rpro')\n```\n\nAdd environment PATH(Run in terminal):\n\n### OS \u0026 Linux\n\n(1) Find the path of package `rpro`\n\n```shell\nRscript -e 'library(rpro);cat(path.package(\"rpro\"), \"bin\", sep = \"/\")'\n```\n\n(2) Add in PATH\n\n```shell\necho \"paste path in step 1\" \u003e\u003e ~/.bashrc\n```\n\n### Windows\nThis package is written purely by R, so it supports Windows(Im sure). However, I do not know how to add PTAH since I do not use Windows a long time ago (~_~). Welcome to contribute!\n\n## Usage\nAfter install `rpro` and add the environment path, you can run `rpro` as a command in the terminal directly.\n\n### list\n`rpro list` lists all the functions defined in the files that in your current folder. In default, it just shows the functions whose name starts with *run*.\n\n### run\n`rpro list` may show you some functions, then you can use `rpro run function_name` to run the corresponding function.\n\n\n### Example\n\nSave the follwing codes in `test.R`.\n\n```R\noptions(encoding = 'GBK')\n\n# download web page\nrun_ip \u003c- function(url, ...){\n  if (is.null(url)){\n    return(cat('NO url\\n'))\n  }\n  res = readLines(url, ...)\n  return(cat(res, '\\n'))\n}\n\n# parse command line parameters\nrun_arg \u003c- function(...){\n  argvs = list(...)\n  arg_name = names(argvs)\n  if (length(arg_name) == 0){\n    return(message('No parameter offered.'))\n  }\n  arg_val = sapply(arg_name, function(x) argvs[[x]])\n  msg = sprintf('Paramter name: %-*s; Parameter value: %s',\n                max(nchar(arg_name)), arg_name, arg_val)\n  cat(msg, sep = '\\n')\n}\n```\n\n```shell\nrpro list\n# Search files match: [*.R$]; Search funcitons match: [^run]\n# ----\u003e 1: test.R::run_arg\n# ----\u003e 2: test.R::run_scrapy\n\n# return the address of your IP\nrpro run test.R::run_ip -url http://ip.ws.126.net/ipquery  \n```\n\nIn default, `rpro run` will add a `help` argument for the function(if you do not offer any parameters). So it is always recommended to prepare more arguments in your function(`...` in the script refers to more arguments).\n\n```shell\nrpro run test.R::run_arg\n# Paramter name: help; Parameter value: 0\n```\n\n```shell\nrpro run test.R::run_arg -arg1 rpro -arg2 123 -arg3 third\n# Paramter name: arg1; Parameter value: rpro\n# Paramter name: arg2; Parameter value: 123\n# Paramter name: arg3; Parameter value: third\n```\n\n## TODO\n(1) logging \u0026 email?\n\n(2) configuration file to store parameters?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbye%2Frpro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadbye%2Frpro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbye%2Frpro/lists"}