inst/snippet/vectors02.R

u <- c(first = 1, second = 2, third = 3)
u                                # names are displayed in output
names(u)                         # show just the names
u["second"]                      # access by name
names(u) <- c("one", "two", "three") # change the names
names(u)[2] <- "TWO"             # change just one name
u
u["first"]                       # old names gone now
setNames(u, c("a", "b", "c"))    # new object is named
u                                # u remains unchanged

Try the fastR2 package in your browser

Any scripts or data that you put into this service are public.

fastR2 documentation built on Nov. 9, 2023, 9:06 a.m.