Character Data Type
Part of the Fundamentals section of Coddy's R journey — lesson 6 of 78.
The character data type is R's way of storing text information. In other programming languages, this is often called a "string," but R uses the term "character."
The character data type is used to store any text, whether it's a single word, a sentence, or even just a single letter. To create a character variable, you enclose your text in double quotes <strong>“”</strong> and use the assignment operator you've already learned:
name <- "Alice"
message <- "Welcome to R programming"The double quotes tell R that everything inside should be treated as text, not as code. This means you can store names, addresses, descriptions, or any other textual information in character variables.
Challenge
EasyCreate a character variable called greeting that stores the message "Hello, John!" Then display the greeting using the print() function.
Try it yourself
# TODO: Write your code here
# Display the greeting
print(greeting)This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Operators Part 2
Logical Operators (AND, OR)Logical Operators Part 2 (NOT)Recap - Simple LogicVectorized Logic Part 1Vectorized Logic Part 22Variables and Data Types
Numeric Data TypeInteger Data TypeCharacter Data TypeLogical Data TypeChecking Data TypesNaming ConventionsMissing Values: NARecap - Variable Creation8Loops
For LoopWhile LoopBreakNext (Continue)Recap - FactorialSequence Generation (seq, :)Nested LoopsRecap - Dynamic Input3Operators Part 1
Arithmetic OperatorsInteger Division and ModuloAssignment OperatorsRecap - Simple MathComparison Operators6Basic IO
Print OutputCat for OutputOutput With VariablesReading Input with readline()Type Conversion BasicsRecap - Age CalculatorRecap - True or False9Functions
Declaring a FunctionFunction ArgumentsReturn ValuesRecap - Sigma FunctionRecap - Validation FunctionDefault Parameter Values