working R package; still need to edit C code