如何在R中创建零长度的数字向量 [英] How to create a numeric vector of zero length in R

查看:82
本文介绍了如何在R中创建零长度的数字向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如何在 R 中创建一个数字零长度向量?

I wonder, how can I create a numeric zero-length vector in R?

推荐答案

如果你阅读了 vector (or numeric or logicalcharacterintegerdouble, 'raw' 或 complex 等)然后你会看到它们都有一个 length(或 length.out 参数,默认为 0

If you read the help for vector (or numeric or logical or character or integer or double, 'raw' or complex etc ) then you will see that they all have a length (or length.out argument which defaults to 0

因此

numeric()
logical()
character()
integer()
double()
raw()
complex() 
vector('numeric')
vector('character')
vector('integer')
vector('double')
vector('raw')
vector('complex')

所有返回适当原子模式的 0 长度向量.

All return 0 length vectors of the appropriate atomic modes.

# the following will also return objects with length 0
list()
expression()
vector('list')
vector('expression')

这篇关于如何在R中创建零长度的数字向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆