m <- matrix( 1:100, ncol=10)
colnames(m) <- paste("Col",1:10, sep="_")
left(m)
right(m)
# When no column names are present, they are added by default
colnames(m) <- NULL
left(m) #
colnames(left(m))
right(m)
colnames(right(m))
# Prevent addition of column numbers
left(m, add.col.nums = FALSE)
colnames(left(m, add.col.nums = FALSE))
right(m, add.col.nums = FALSE) # columns are labeled 1:6 ..
colnames(right(m, add.col.nums = FALSE)) # instead of 5:10
# Works for data frames too!
d <- data.frame(m)
left(d)
right(d)
# Use negative n to specify number of columns to omit
left(d, -3)
right(d, -3)
Run the code above in your browser using DataLab