public static Margins fromExp(SEXP exp) {
if(!(exp instanceof Vector)) {
throw new IllegalArgumentException("vector required");
}
Vector vector = (Vector)exp;
if(exp.length() != 4) {
throw new IllegalArgumentException("vector of length 4 required");
}
return new Margins(
vector.getElementAsDouble(0),
vector.getElementAsDouble(1),
vector.getElementAsDouble(2),
vector.getElementAsDouble(3));
}