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 = "")
  1. name ← Ada

    1name <- "Ada"2message <- paste("Hello", name)
    values this stepAdaname
  2. message ← Hello Ada

    1name <- "Ada"2message <- paste("Hello", name)3cat(message, "\n", sep = "")
    values this stepHello AdamessageAdaname
  3. cat(message, " ", sep = "")

    2message <- paste("Hello", name)3cat(message, "\n", sep = "")
    outputHello Ada
    values this stepHello Adamessage

Build the Message

  1. name stores Ada.
  2. paste("Hello", name) combines the greeting and name.
  3. message stores Hello Ada.
  4. cat writes 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