Concept Flow - Character (string) type
Create character variable
Store text value
Use or print variable
End or reuse variable
This flow shows how a character (string) variable is created, stored, used, and then either ends or is reused.
name <- "Alice" print(name) name <- "Bob" print(name)
| Step | Action | Variable 'name' Value | Output |
|---|---|---|---|
| 1 | Assign 'Alice' to name | "Alice" | |
| 2 | Print name | "Alice" | [1] "Alice" |
| 3 | Assign 'Bob' to name | "Bob" | |
| 4 | Print name | "Bob" | [1] "Bob" |
| 5 | End of code | "Bob" |
| Variable | Start | After Step 1 | After Step 3 | Final |
|---|---|---|---|---|
| name | undefined | "Alice" | "Bob" | "Bob" |
Character (string) type in R: - Use quotes to create strings, e.g. name <- "Alice" - Strings are stored as text values - Print shows text with quotes and index - Variables can be reassigned new strings - Strings are used for text data