如何创建一个空的 R 向量来添加新项目 [英] How to create an empty R vector to add new items

查看:56
本文介绍了如何创建一个空的 R 向量来添加新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Python 中使用 R,正如模块 Rpy2 提供的那样.我注意到 R 有非常方便的 [] 操作,您可以通过它提取特定的列或行.怎么用Python脚本实现这样的功能?

I want to use R in Python, as provided by the module Rpy2. I notice that R has very convenient [] operations by which you can extract the specific columns or lines. How could I achieve such a function by Python scripts?

我的想法是创建一个 R 向量并将那些想要的元素添加到这个向量中,以便最终的向量与 R 中的相同.我创建了一个 seq(),但似乎它有一个初始数字 1,所以最终结果总是从数字 1 开始,这不是我想要的.那么,有没有更好的方法来做到这一点?

My idea is to create an R vector and add those wanted elements into this vector so that the final vector is the same as that in R. I created a seq(), but it seems that it has an initial digit 1, so the final result would always start with the digit 1, which is not what I want. So, is there a better way to do this?

推荐答案

vec <- vector()

另见矢量帮助

?vector

这篇关于如何创建一个空的 R 向量来添加新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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