Code Monkey home page Code Monkey logo

Comments (3)

cosimameyer avatar cosimameyer commented on July 28, 2024

Thanks for the suggestion, @drmowinckels :)

We created the function to work with one base path for multiple outputs. Coming from a social sciences background, you might want to generate overview tables for multiple subsets of your data set. Creating a file path upfront in the script and adding the file_path object in the overview_latex function (thanks so much for suggesting the new name, I love it! 🥰 ) allows us to avoid path copying.

file_path <- 'some/file_path/'

overview_latex(
   obj = overview_table1,
   path = file_path,
   file = 'plot1.tex'
)

overview_latex(
   obj = overview_table2,
   path = file_path,
   file = 'plot2.tex'
)    

An alternative that I can think of, on the top of my head, would be to rewrite the function as follows:

file_path <- 'some/file_path/'

overview_latex(
   obj = overview_table1,
   path = paste0(file_path, 'plot1.tex')
)

overview_latex(
   obj = overview_table2,
   path = paste0(file_path, 'plot2.tex')
)    

I agree that it makes it shorter, but I'm not sure if it makes it cleaner. But I'm curious what you think 😊

from overviewr.

drmowinckels avatar drmowinckels commented on July 28, 2024

I think there are pros and cons for each, and having created a package that does indeed take a folder as a destination I understand what you are thinking. I too am from social science (psychology), so I totally get where you are coming from.

At the same time, I think a folder makes sense if the function it self creates multiple files. But if a single call to the function creates a single file, then giving the full (or relative) path makes more sense. And then its up to the user to do as you do.

Think of how other writing functions work, where they take a single path for a single file. write.table, readr::write_tsv, etc. We are used to having to provide a single path for a single function call already. As a user, if I were just writing a single file, I'd find it strange to provide both a path and destination folder, I'd for sure do it incorrectly at the first try because of this. From an R point of view, I think a single path makes sense.

That being said. I am not going to force a change on this at all, I merely wanted a discussion around it, as I found it odd. It is not a big deal at all, and if you are happy with it, then go for it. If you, after reading this comment, still want to keep it as is, then you can close the comment, and I'll finish my review.

from overviewr.

cosimameyer avatar cosimameyer commented on July 28, 2024

Thanks for your response and for sharing your thoughts. We find the reasoning very convincing and highly appreciate getting an outside perspective on our package's functionality :)
We changed the argument from file and path to a single argument file_path in PR #30 and #32 :)

from overviewr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.