editor 发表于 2013-3-22 15:28:26

R语言 求向量的模 如何操作呢?—R-China小编问题(35)

本帖最后由 editor 于 2013-5-25 11:27 编辑

向量求模,是数学中常做的操作。
有人问R语言是否有函数直接可以求模。
经过小编搜索,果然有专门函数进行此类操作。
用户需要先在这包onion,安装后就可以操作了
下面介绍例子

## S3 method for class 'onion':
Norm(z)
## S3 method for class 'onion':
Mod(z)
## S3 method for class 'onion':
Mod(z) <- value
## S3 method for class 'onion':
sign(x)

Arguments
x,zOnionic vector
valueA real vector

Examples

a <- roct(5)
Norm(a)
Mod(a)

感兴趣的朋友可以参考
http://rss.acs.unt.edu/Rdoc/library/onion/html/Norm.html

双陆回风 发表于 2014-5-17 21:13:50

直接sum(x*x)^0.5不就可以了么

R学习者 发表于 2015-1-22 11:53:31

sqrt(sum((a)^2)).......a为一向量

amelinda 发表于 2023-8-28 12:29:31

向量求模,是数学中常做的操作。
有人问R语言是否幸运飞艇走势图
                                                有函数直接可以求模。
经过小编搜索,果然有专门函数进行此类双色球开奖结果 操作。
用户需要先在这包onion,   澳洲幸运20稳赚技巧 安装后就可以操作了
下面介绍例子


页: [1]
查看完整版本: R语言 求向量的模 如何操作呢?—R-China小编问题(35)