Tutorial: Common arithmetic functions. Common functions for operations on general data:
1, round () #四舍五入Example: X <-C (3.1416, 15.377, 269.7) round (x, 0) #保留整数位round (x, 2) #保留两位小数round (x,-1) #保留到十位
2, signif () #取有效数字 (with a valid number learned is not a meaning)Example: slightly
3, Trunc () #取整Floor () #向下取整 ceiling () #向上取整例: xx <-C (3.60, 12.47, -3.60, -12.47) trunc (xx) floor (xx) ceiling (XX)
4, LOGB (A, B) #以b为底的对数, omit B to indicate natural logarithmLog () #自然对数 log10 () #以10为底的常用对数例: LOGB (8, 2) log (8); LOGB (8) log10 (100); LOGB (100, 10)
5, sqrt () #平方根exp () #指数
6. Sin () #正弦cos () #余弦 tan () #正切 ASIN () #反正弦 ACOs () #反余弦 atan () #反正切 sinh () #双曲正弦 tanh () #双曲正切
7, nchar () #字符长度Example: XX <-' China is a great country ' nchar (XX)
8, substring () #取子字符串Example: substring (XX, 1, 5)
9, paste () #连接字符The syntax is: Paste (..., Sep = "", collapse = NULL) example 1:x <-' I '; Y <-' am '; Z <-' a '; D <-' student ' paste (x, Y, Z, D) example 2:paste (C (' x ', ' y '), 1:4, Sep = ') example 3:paste (' x ', 1:4, Sep = ', collapse = ' + ')
Introduction to the basics of R language