Values and Vectors
Hello
Text Values
R scripts assign names to values, combine text, and write results. This replay shows a string moving through paste into output.
Program
Play the script to watch name flow into message, then print as plain text.
hello.R
Replay: real traced execution (multi-file project)
name <- "Ada"
message <- paste("Hello", name)
cat(message, "\n", sep = "")
name ← Ada
1name <- "Ada"2message <- paste("Hello", name)values this stepAdanamemessage ← Hello Ada
1name <- "Ada"2message <- paste("Hello", name)3cat(message, "\n", sep = "")values this stepHello AdamessageAdanamecat(message, " ", sep = "")
2message <- paste("Hello", name)3cat(message, "\n", sep = "")outputHello Adavalues this stepHello Adamessage
Build the Message
namestoresAda.paste("Hello", name)combines the greeting and name.messagestoresHello Ada.catwrites the text without extra vector formatting. | Name | Message | | --- | --- | |Ada|Hello Ada|
assignment
`<-` binds a value to a name in the current R environment.
paste
`paste` combines values into one character vector.
cat
`cat` writes text without R's printed vector prefix.
Exercise: hello.R
Assign a name, build a greeting with paste, and print the message with cat