编写一个Rint程序 [英] Writing a R lint program

查看:90
本文介绍了编写一个Rint程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在python中编程时,我发现使用pylint非常有用.但是,当我用R编程时,没有可比的东西.

When I program in python, I find using pylint very useful. However, when I program in R, there is nothing comparable.

作为一个小型项目,我认为尝试编写一个小型皮棉程序会很有趣.没什么特别的,类似于以下内容:

As a small side project, I thought it would be fun to try and write a small lint program. Nothing too fancy, something along the lines of:

  • 确保函数名称为驼峰式大小写
  • 平均功能长度
  • 检测未使用的变量
  • 间距.例如,用function(x=1, y=2)代替function(x=1,y=2)
  • Making sure function names are camel case
  • Average function length
  • Detecting unused variables
  • Spacing. For example, function(x=1, y=2) instead of function(x=1,y=2)

但是,我不确定如何入门(我已经开始浏览pylint源代码).

However, I'm unsure of how to get started (I have started to look through the pylint soure code).

我应该如何开始?是否有针对此类项目的标准编程技术?我应该考虑任何好的资源吗?

How should I get started? Are there standard programming techniques for this type of project? Any good resources that I should consider?

我想用R编写整个项目.

I would like to write the entire project in R.

推荐答案

看看R附带的软件包codetools.在

Take a look at package codetools that comes with R. Some details are found on the CRAN page for the package. The code in the package is run when you do R CMD check for example so can catch unused variables etc. That might get you started on that aspect of rlint.

要回答其他一些问题...我将开始编写完成一项任务的简单函数,例如将函数名称转换为驼峰式大小写.在构建大量小功能时,您可以将它们合并为一个有效的lint包装函数,同时允许用户/开发人员在不希望其表现完整功能的情况下灵活地调用特定功能.

To answer some of the other aspects... I'd start of writing simple functions that do one task, such as convert functions names to camel case. As you build up a body of small functions you can amalgamate them into a working lint wrapper function, whilst allowing users/developers flexibility to call the specific functions if they don't want the full lint behaviour.

这篇关于编写一个Rint程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆