“`r
qty <- c(12, 6, 2, 25)
rate <- c(60, 75, 140, 35)
amount <- qty * rate # whole vectors at once, like an Excel column formula
df <- data.frame(item = c("Notebook", "Pens", "Stapler", "Folder"), qty, rate, amount)
df[df$amount > 500, ] # rows where amount > 500
df$item # one column
str(df); summary(df)
“`
<- assigns (like =). c() combines values into a vector. Indexing starts at 1, not 0.
💡 Most R functions work on whole vectors, so you rarely need loops. Think ‘column formula’, not ‘cell by cell’.
Code for this course follows standard, current syntax; we test JavaScript and PowerShell scripts before publishing, and R/Java/Rust examples are kept to core language features. Tell us if anything fails on your setup.