R和独奏数据分析师的版本控制 [英] R and version control for the solo data analyst

查看:110
本文介绍了R和独奏数据分析师的版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多我尊重的数据分析师使用版本控制。
例如:



然而,我正在评估采用像git这样的版本控制系统是否值得。



简要概述
我是一位使用R来分析研究出版物数据的社会科学家。
我目前不生产R软件包。
我的一个项目的R代码通常包含几千行代码,用于数据输入,清理,操作,分析和输出生成。
出版物通常使用LaTeX编写。



关于版本控制,我已经看到很多好处,但它们似乎与独立数据分析师。


  • 备份:我已经有一个备份系统。

  • 分岔和倒带:我从来没有觉得需要这样做,
    ,但我可以看到它是如何有用的(例如,你正在准备多个基于相同数据集的
    期刊文章;您正在准备一份每月更新的报告
    等) b $ b
  • 合作: >大部分时间我都是
    自己分析数据,因此,
    无法获得版本控制的协作
    好​​处。



采用版本控制还有几个潜在的成本: b
$ b


  • 评估和学习版本控制系统
  • 复杂性可能会增加我当前的文件管理系统



然而,我仍然觉得我失去了一些东西。
有关版本控制的一般指南似乎更多地针对计算机科学家,而不是数据分析师。 因此,特别是涉及数据分析师在类似于上面列出的情况下:


  1. 版本控制是否值得付出努力?

  2. 采用版本控制的主要优点和缺点是什么?

  3. 什么是开始使用版本控制的好策略
    用于R数据分析(例如,示例,工作流程概念,软件,指南链接)?


解决方案

我觉得你的问题的答案是一个响亮的答案 - 管理文件的好处控制系统远远超过实施这样一个系统的成本。



我会尽力详细回复您提出的一些观点:



  • 备份:我已经有一个备份系统。
>

是的,我也是。但是,有些问题需要考虑依赖通用备份系统来适当地跟踪重要和与你的工作有关的活动文件。在性能方面:


  • 您的备份系统以什么时间间隔拍摄快照?

  • 建立快照需要多长时间?

  • 在拍摄快照时是否需要镜像整个硬盘,还是只能备份刚刚收到重要更新的两个文件?

  • 您的备份系统能够精确地向您显示您的文本文件中从一个备份到另一个备份的更改情况吗? >最重要的是:


    • 备份保存了多少个位置?它们与您的计算机位于相同的物理位置吗?

    • 从备份系统恢复指定版本的单个文件有多容易?

    • ul>

      例如,使用Mac并使用Time Machine备份到我的计算机中的另一个硬盘驱动器。 Time Machine非常适合恢复奇怪文件或恢复我的系统,如果事情搞砸了。然而,它并没有什么需要我的重要工作来信任:


      • 备份时,Time Machine具有对需要相当长时间的整个硬盘进行映像。如果我继续工作,则无法保证我的文件将在我启动备份的状态下被捕获。我还可以在第一次备份完成之前达到另一个要保存的点。

      • 我的Time Machine备份保存到的硬盘位于我的机器 - 这使得我的数据容易遭受盗窃,火灾和其他灾难。 使用像Git这样的版本控制系统,我可以毫不费力地启动特定文件的备份,请求在文本编辑器中进行保存 - 并且文件被瞬间成像并存储。此外,Git是分布式的,因此我工作的每台计算机都有一个完整的版本库。



        这相当于让我的作品在四台不同的计算机上映射 - 上帝的行为可能会破坏我的文件和数据,在这一点上,我可能不会太在意。



        • 分叉和倒带:我从来没有觉得需要这样做,但我可以看到它是如何有用的(例如,您准备基于相同数据集的多篇期刊文章;正在准备一份每月更新的报告等)

        作为独奏者,我没有叉这么多。然而,通过倒带选项节省的时间已经多次为我学习版本控制系统的投资回报了一把。你说你从来没有觉得有必要这样做 - 但是在你当前的备份系统下倒退任何文件真的是一个无痛,可行的选择吗?



        有时,报告只是看



        • 合作:大多数当时我是
          自己分析数据,因此,我
          不会获得版本控制的协作
          好​​处。


        是的,但是如果您最终与其他人合作完成项目,您会学到一个可能证明不可或缺的工具。



        • 评估和学习版本控制系统的时间

        不要太担心这件事。版本控制系统就像编程语言一样 - 它们有几个关键概念需要学习,其余的只是语法上的糖。基本上,你学习的第一个版本控制系统需要投入大部分时间切换到另一个版本,只需要学习新系统如何表达关键概念。

        然后去做!



        • 复杂度可能会增加我当前的文件管理系统
        • $您是否有一个文件夹,比如项目,其中包含所有文件夹与您的数据分析活动相关的文件夹和文件?如果是这样,那么对它进行版本控制会使文件系统的复杂性正好 0 。如果你的项目散布着你的计算机 - 那么你应该在应用版本控制之前集中它们,这将最终降低管理文件的复杂性,这就是为什么我们有一个文档



          1. 版本控制值得付出努力吗?
          2. >


          是!它给你一个巨大的撤销按钮,并允许你轻松地将工作从机器转移到机器,而不用担心丢失USB驱动器等事情。

          2采用版本控制的主要优点和缺点是什么?


        唯一我能想到的是文件大小略有增加 - 但现代版本控制系统可以通过压缩和选择性保存完成绝对令人惊叹的事情,所以这非常不切实际。

        一个很好的策略来开始使用R进行数据分析的版本控制(例如,示例,工作流程的想法,软件,指南链接)?



        <保留在版本控制下生成数据或报告的文件,要有选择性。如果您正在使用类似于 Sweave 的东西,请保存您的 .Rnw 文件而不是 .tex 从它们生成的文件。存储原始数据如果重新获取会很痛苦。如果可能的话,编写和存储获取数据的脚本,以及另一个清理或修改数据的脚本,而不是存储对原始数据的更改。



        至于学习版本控制系统,我强烈推荐Git和本指南



        这些网站还提供了一些与使用Git执行特定操作相关的漂亮提示和技巧: p> http://www.gitready.com/


      • http://progit.org/blog.html



      Many data analysts that I respect use version control. For example:

      However, I'm evaluating whether adopting a version control system such as git would be worthwhile.

      A brief overview: I'm a social scientist who uses R to analyse data for research publications. I don't currently produce R packages. My R code for a project typically includes a few thousand lines of code for data input, cleaning, manipulation, analyses, and output generation. Publications are typically written using LaTeX.

      With regards to version control there are many benefits which I have read about, yet they seem to be less relevant to the solo data analyst.

      • Backup: I have a backup system already in place.
      • Forking and rewinding: I've never felt the need to do this, but I can see how it could be useful (e.g., you are preparing multiple journal articles based on the same dataset; you are preparing a report that is updated monthly, etc)
      • Collaboration: Most of the time I am analysing data myself, thus, I wouldn't get the collaboration benefits of version control.

      There are also several potential costs involved with adopting version control:

      • Time to evaluate and learn a version control system
      • A possible increase in complexity over my current file management system

      However, I still have the feeling that I'm missing something. General guides on version control seem to be addressed more towards computer scientists than data analysts.

      Thus, specifically in relation to data analysts in circumstances similar to those listed above:

      1. Is version control worth the effort?
      2. What are the main pros and cons of adopting version control?
      3. What is a good strategy for getting started with version control for data analysis with R (e.g., examples, workflow ideas, software, links to guides)?

      解决方案

      I feel the answer to your question is a resounding yes- the benefits of managing your files with a version control system far outweigh the costs of implementing such a system.

      I will try to respond in detail to some of the points you raised:

      • Backup: I have a backup system already in place.

      Yes, and so do I. However, there are some questions to consider regarding the appropriateness of relying on a general purpose backup system to adequately track important and active files relating to your work. On the performance side:

      • At what interval does your backup system take snapshots?
      • How long does it take to build a snapshot?
      • Does it have to image your entire hard drive when taking a snapshot, or could it be easily told to just back up two files that just received critical updates?
      • Can your backup system show you, with pinpoint accuracy, what changed in your text files from one backup to the next?

      And most importantly:

      • How many locations are the backups saved in? Are they in the same physical location as your computer?
      • How easy is it to restore a given version of a single file from your backup system?

      For example, have a Mac and use Time Machine to backup to another hard drive in my computer. Time Machine is great for recovering the odd file or restoring my system if things get messed up. However it simply doesn't have what it takes to be trusted with my important work:

      • When backing up, Time Machine has to image the whole hard drive which takes a considerable amount of time. If I continue working, there is no guarantee that my file will be captured in the state that it was when I initiated the backup. I also may reach another point I would like to save before the first backup finishes.

      • The hard drive to which my Time Machine backups are saved is located in my machine- this makes my data vulnerable to theft, fire and other disasters.

      With a version control system like Git, I can initiate a backup of specific files with no more effort that requesting a save in a text editor- and the file is imaged and stored instantaneously. Furthermore, Git is distributed so each computer that I work at has a full copy of the repository.

      This amounts to having my work mirrored across four different computers- nothing short of an act of god could destroy my files and data, at which point I probably wouldn't care too much anyway.

      • Forking and rewinding: I've never felt the need to do this, but I can see how it could be useful (e.g., you are preparing multiple journal articles based on the same dataset; you are preparing a report that is updated monthly, etc)

      As a soloist, I don't fork that much either. However, the time I have saved by having the option to rewind has single-handedly paid back my investment in learning a version control system many, many times. You say you have never felt the need to do this- but has rewinding any file under your current backup system really been a painless, feasible option?

      Sometimes the report just looked better 45 minutes, an hour or two days ago.

      • Collaboration: Most of the time I am analysing data myself, thus, I wouldn't get the collaboration benefits of version control.

      Yes, but you would learn a tool that may prove to be indispensable if you do end up collaborating with others on a project.

      • Time to evaluate and learn a version control system

      Don't worry too much about this. Version control systems are like programming languages- they have a few key concepts that need to be learned and the rest is just syntactic sugar. Basically, the first version control system you learn will require investing the most time- switching to another one just requires learning how the new system expresses key concepts.

      Pick a popular system and go for it!

      • A possible increase in complexity over my current file management system

      Do you have one folder, say Projects that contains all the folders and files related to your data analysis activities? If so then slapping version control on it is going to increase the complexity of your file system by exactly 0. If your projects are strewn about your computer- then you should centralize them before applying version control and this will end up decreasing the complexity of managing your files- that's why we have a Documents folder after all.

      1. Is version control worth the effort?

      Yes! It gives you a huge undo button and allows you to easily transfer work from machine to machine without worrying about things like losing your USB drive.

      2 What are the main pros and cons of adopting version control?

      The only con I can think of is a slight increase in file size- but modern version control systems can do absolutely amazing things with compression and selective saving so this is pretty much a moot point.

      3 What is a good strategy for getting started with version control for data analysis with R (e.g., examples, workflow ideas, software, links to guides)?

      Keep files that generate data or reports under version control, be selective. If you are using something like Sweave, store your .Rnw files and not the .tex files that get produced from them. Store raw data if it would be a pain to re-acquire. If possible, write and store a script that acquires your data and another that cleans or modifies it rather than storing changes to raw data.

      As for learning a version control system, I highly recommend Git and this guide to it.

      These websites also have some nice tips and tricks related to performing specific actions with Git:

      这篇关于R和独奏数据分析师的版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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