Coder Social home page Coder Social logo

Comments (11)

lwjohnst86 avatar lwjohnst86 commented on June 2, 2024

@joelostblom I 100% agree with you regarding the periods. snake_case for functions/objects and CamelCase for variables is what I use and recommend. Others such as Hadley also use this style. Let's stick with that. Maybe we create our own reference for the students, based on the Google style guide but slightly modified?

from rcourse.

lwjohnst86 avatar lwjohnst86 commented on June 2, 2024

Actually, Hadley has already set up a page for the style: http://adv-r.had.co.nz/Style.html

from rcourse.

joelostblom avatar joelostblom commented on June 2, 2024

Yes, that one looks like a briefer version of the content I linked previously, isn't it?

According to those guidelines, snake_case is used pretty much everywhere, including variable names:

Variable and function names should use only lowercase letters, numbers, and _.

I didn't find anything for column names in the tidyverse style guide, but in the examples, such as for mutate, snake_case is used.

from rcourse.

lwjohnst86 avatar lwjohnst86 commented on June 2, 2024

Aaah, of course there is an entire book format website on this... again through the tidyverse.. see here: http://style.tidyverse.org/index.html

from rcourse.

lwjohnst86 avatar lwjohnst86 commented on June 2, 2024

It doesn't include column variable naming though... I think that might have to do with the fact that for many datasets, the column names are already set up and it would be a hassle to rename alllll of them (if it's a big dataset).

We could make a reference to it in the lectures and say try to use CamelCase for data variable names.

from rcourse.

joelostblom avatar joelostblom commented on June 2, 2024

Haha yes @lwjohnst86, you essentially posted what I said in my comment above! =) snake_case is used for column names in the tidyverse documentation.

from rcourse.

lwjohnst86 avatar lwjohnst86 commented on June 2, 2024

Ohh, jeez, wow, sorry, I kept looking at the wrong website when you linked that style guide.... drrrrrrrrrrrup... haha oops, sorry bout that.

As for snake case with column names... I don't like that at all... A brief google search seems to show that naming conventions for database column names are pretty varied... I'd say use CamelCase for data variables, to separate it from functions and object variable names. Thoughts?

from rcourse.

lwjohnst86 avatar lwjohnst86 commented on June 2, 2024

@joelostblom I just wanted to imitate you that's all... You know what they say about imitation right? "Imitation is the sincerest/highest form of flattery" 😜

from rcourse.

joelostblom avatar joelostblom commented on June 2, 2024

Haha, I thought they said that stealing was the highest form of flattery... gotta check my wallet before I leave the next coders meeting!

I largely agree regarding column names. I actually switched from underscores to using upper CamelCase myself with column names in pandas and seaborn, although many of the example data sets there use underscores. My main reason for this is that it looks better when displaying the data as a table, and also as the default axis labels when plotting (although I would change any axis labels from "PascalCase" to "Pascal case" before publishing anyways...).

However, I have recently started looking a bit at SQL, where there seems to be good reasons to prefer lowercase with underscores. Mostly because variable names are case insensitive unless quoted, and I would not want to keep quoting column names for no good reason. I also read something on that with Windows there might be additional problems, because some SQL implementation (I think MySQL) converts column names to lower case by default, so any case variation would be lost (not sure about source credibility).

Looking at examples from the documentation of major packages and programs that I have used at least somewhat briefly, all of them use snake_case for column names. These include

  • pandas
  • seaborn
  • tidyverse
  • data.table
  • PostgreSQL
  • MySQL

So, although most of them don't make stylistic recommendations, not a single one uses any form of camel case... Hmmmm... I might just have convinced myself to switch back to underscores...

What do you think? Which are your reasons for using PascalCase? I think of you as a die hard dplyr/Hadley fan, so I am curious to why you are not following his conventions here =) Is it from some old lingering SASS convention? 😱

What I do know for sure is that I prefer column names to be singular and not contain whitespaces.

from rcourse.

linamnt avatar linamnt commented on June 2, 2024

Okay so maybe for the assignment,once we decide, we should say to include a blurb about the style we're going to expect students to use?

from rcourse.

lwjohnst86 avatar lwjohnst86 commented on June 2, 2024

Hmm, regarding PascalCase vs snake_case... @joelostblom Your arguments convince me as well... Plus I just read this blog that says camel/pascal case is slower to read... OK, snake case it is.. Unless there are strong arguments against.

from rcourse.

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.