# Create Location objects.
loc1 <- location("file-a", 1L, 2L, 3L, 4L)
loc2 <- location("file-a", 5L, 6L, 7L, 8L)
loc3 <- location("file-c", c(9L, 10L), c(11L, 12L), c(13L, 14L), c(15L, 16L))
is_location(loc1) ## TRUE
print(loc1)
print(loc2)
print(loc3)
# Combine Location objects.
# c() throws an error if they do not have the same path.
c(loc1, loc2)
# Location objects with different paths can be merged.
# This groups Location objects according to their paths
# and calls c() on each group. It returns a list.
merge_locations(loc1, loc2, loc3)
# The path of a Location object can be whatever fits the context.
# Below is an example that references text in a character vector
# bound to variable x in the global environment.
x <- "This is a string and it is held in memory for some purpose."
location("", 1L, 11L, 1L, 16L)
Run the code above in your browser using DataLab