Updated r script with new graph functions, slight improved!