Comments (11)
@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.
Actually, Hadley has already set up a page for the style: http://adv-r.had.co.nz/Style.html
from rcourse.
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.
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.
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.
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.
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.
@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.
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.
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.
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)
- Update final project rubric HOT 5
- Update prerequisites in the syllabus
- Change 'project setup' assignment if we're not making GitHub mandatory HOT 2
- Project submission format HOT 2
- Project start - action items HOT 1
- Assignment 8 HOT 3
- End-of-year thoughts HOT 1
- Add MIT license HOT 1
- Get our course listed on tidyverse blog?
- Update version number after tidying and upload next DOI
- Add DOIs to release notes HOT 2
- JOSE Review Comments HOT 3
- First 2019 instructor meeting
- A few assignment a lecture fixes
- Lecture and package removal for 2019
- Lecture Improvements
- Projects and such
- Organize images and data
- Improvements for 2020
- Switch from Travis CI to GitHub Actions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rcourse.