Ok. Meanwhile i managed (with the help of How to define the subset operators for a S4 class?) to come up with (after some renaming):
setMethod(
f = "[",
signature="Intervals",
definition=function(x,i,j,...,drop=TRUE){
initialize(x, from=x@from[i], to=x@to[i], values = x@values[i])
}
)
Just if anyone is interested.. the show method looks like this.
setMethod(
f = "show",
signature="Intervals",
definition=function(object){
rownames <- sapply(seq_along(object@to),
function (i) paste(object@from[i], "--", object@to[i]))
df.show <- data.frame(object@values, row.names = rownames)
names(df.show) <- ifelse(length(names(object@values)) == 0,
"Values", names(object@values))
print (df.show)
}
)