codes for general R usage