compare with JS code in Fig, R libraries in table