Menu
Coddy logo textTech

Naming Conventions

Part of the Fundamentals section of Coddy's R journey — lesson 9 of 78.

R has specific rules for valid variable names. A variable name must start with a letter or a period not followed by a number, and can contain letters, numbers, periods (.), and underscores (_). However, it cannot start with a number or contain spaces.

Beyond the basic rules, following naming conventions makes your code much more readable and maintainable. Two popular styles are snake_case (using underscores between words like user_name) and camelCase (capitalizing the first letter of each word except the first, like userName). Choose one style and use it consistently throughout your code.

Most importantly, use descriptive names that clearly indicate what the variable contains. Instead of x or data1, use names like student_score or monthly_sales. This makes your code self-documenting and easier for others (and your future self) to understand.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals