问题标签 [rowname]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2053 浏览

r - 测试 data.frame 中现有的 row.names 和 col.names

是否有一个函数可以确定 data.frame 是否具有本机行名和列名或仅具有自动生成的 (1 2 3 4...) ?对于列名,“自动”意味着例如当您将“as.data.frame”应用于矩阵时..

对于行名,我想出了一个解决方法:

但是,对于列名,我不知道该怎么做。困难在于有时自动 col.names 以 V1 V2 等开头,有时以 X1.、X2..

编辑:为什么我问这个问题:我需要在一个更复杂的函数(有点类似于 PCA 的图形输出)中执行这个测试,如果存在,它将绘制行名和列名,如果不存在,它将创建更适合新名称。所以它应该适用于“任何”data.frame,没有实际名称的线索..

谢谢。

0 投票
2 回答
469 浏览

r - How to keep row names with running() function?

I would like to know how to keep the row names when using the running() function.

e.g. I'm applying a running correlation between two time series, and for me is very important keeping the row names because these are the Years of my time series.

This is an example:

and I get this

but I would like to keep the row names of my matrix, to have something like this in the row.names:

I have tried something like that, but doesn't work

some direction?

0 投票
9 回答
316233 浏览

r - 将行名转换为第一列

我有一个这样的数据框:

我想将行名转换为第一列。目前我使用这样的东西将行名作为第一列:

有没有一条线可以做到这一点?

0 投票
6 回答
140301 浏览

python - 删除熊猫中的索引名称

我有一个像这样的数据框:

如何index name foo从该数据框中删除?所需的输出是这样的:

0 投票
1 回答
2421 浏览

r - Plotting in R with Points = Levels or Rownames

I'm plotting mpg ~ wt in the R dataset mtcars and I want either the points replaced by the initial of the car model (rowname), or a legend with the rowname beside the points.

I don't know how to code for the first idea, and I get overlapping labels on the second. Is there a way of just labeling with the initial of the car model?

Stripped of colors, and other flourishes, here is the idea:

Sorry about the ugliness... BTW I tried with ggplot2... same sort of issues...

enter image description here

The idea behind the replacement of the points with rowname initial came from the paper on the topic of regression by Harold Henderson:

enter image description here

0 投票
0 回答
82 浏览

r - R,控制双精度后的小数到字符串

我有一个区域的海拔矩阵。我想data.frame用高程生成一个,colname = longitude,rowname = latitude。

原来的纬度是

但之后rownames(x) <- lat,它变成了,

里面的小数太多了,现在变成字符了,不能用round()小数减了。

谢谢你。

0 投票
1 回答
1233 浏览

r - 使用 row.just = "left 时 tableGrob 中的行名被截断

谁能解决为什么我会出现行名截止?它与字符串换行的长度无关。指定 row.just = "center" 不会切断行名称。

给我这个(抱歉缩放)

左对齐表格

而指定“中心”给了我这个

居中对齐的表格

有任何想法吗?

ps我不确定为什么图像是这样的,当我在绘图窗口中单击“缩放”时,它们是完整的表格,但保存/导出只会保存放大的版本......

0 投票
1 回答
570 浏览

r - 按行名访问数据框给了我 NA 而不是我期望的值

这是一个例子。normal 是一个数据框,其行名等于未指定年份的月份和日期(如 1 月 1 日的“-01-01”)。列出的统计数据是在一定范围内的年份。

为什么 R 不会在这里取行名的值,因为它们都是唯一的?

0 投票
1 回答
3651 浏览

r - 如何删除数据框中行名的前 n 个字符?R

我有一个看起来像这样的数据框:

第一列显示行名。

我需要的是删除所有行上的日期部分,例如(“Stock1”而不是“2010-11-04.Stock1”

我基本上需要这个函数的反面,它保留前 n 个字符而不是删除它们。

0 投票
1 回答
652 浏览

r - 在 xts 对象出现在 data.frame 行名之后,根据日期“n”行从 xts 对象中提取值

我感谢 akrun 提供下面的代码。它为我的问题提供了部分解决方案。

下面的代码获取预先指定范围内start_date的值。end_date

例如,我真正需要的是介于start_date + 5和之间的值end_date + 5

问题是我有交易日,因此不仅不包括周末,还包括假期等。例如,在某些情况下,+5 只产生 3 个值,因为其他 2 个是周末。因此,我想将上述任意日历日设为as.Date. 我需要该表中接下来的 5 个值,而不是接下来的 5 个日历日。