我正在尝试在我的操作中尽可能多地使用 dplyr。现在我有一个简单的向量,其中包含我想在colnames()data.table 中替换的字符串元素。
我阅读了一些帖子并尝试过,但无法理解它应该是什么样子。
我的代码
> head(tickerData)
AAK.ST.Open AAK.ST.High AAK.ST.Low AAK.ST.Close AAK.ST.Volume AAK.ST.Adjusted
2007-01-02 199.5 199.5 195.0 198.0 74400 159.54
2007-01-03 198.0 202.5 196.5 202.5 79100 163.17
2007-01-04 201.0 206.0 200.0 204.0 258500 164.38
2007-01-05 204.0 207.0 204.0 205.5 42100 165.59
2007-01-08 205.0 205.0 201.5 205.0 155300 165.18
2007-01-09 203.0 205.0 202.0 204.0 149000 164.38
> colName <- c('Open', 'High', 'Low', 'Close', 'Volume', 'Adj.Close')
> tickerData <- tickerData %>% ggplot2::fortify() %>%
+ # rename
+ rename(.dots = setNames(colName, 'new'))
Error: Arguments to rename must be unquoted variable names. Arguments .dots are not.
Run Code Online (Sandbox Code Playgroud)
在这种情况下,语法应该如何?
| 归档时间: |
|
| 查看次数: |
2821 次 |
| 最近记录: |