小编aya*_*all的帖子

base::assign(".ptime", proc.time(), pos = "CheckExEnv") 使用 devtools::check 时出错

我正在使用 R CMD 检查我的包devtools::check,我遇到了相同的ERROR(见下文)讨论here。我试着按照那里的建议去做:我在我的代码中添加了一个#'@export之前的标签,我还添加了. 但是我仍然得到同样的错误。#'@exampleprep.Rexport(prep)NAMESPACE

有谁知道我该如何解决这个问题?

任何帮助将不胜感激

阿亚拉

* checking R/sysdata.rda ... OK
* checking examples ... ERROR
Running examples in 'prepdat-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: prep
> ### Title: Aggregate Long Format Data According to Grouping Variables and
> ###   Generate a Number of Measures for Each Cell in the Aggregated Data
> ###   for …
Run Code Online (Sandbox Code Playgroud)

cmd r devtools

5
推荐指数
1
解决办法
1033
查看次数

paste()函数和变量的排序级别

我在以下数据框中有两列,每列根据特定顺序具有级别:

head(x1)
  soa congruency
1 200          9
2 102          2
3  68          1
4  68          9
5  34          9
6  68          9

head(levels(x1$soa))
[1] "34"  "68"  "102" "200"

head(levels(x1$congruency))
[1] "1" "2" "9
Run Code Online (Sandbox Code Playgroud)

我希望能够粘贴两列,以便新变量的级别为:

"34_1""34_2""34_9""68_1""68_2""68_9"等......

但是,如果我执行以下操作:

x2 <- paste(x1$soa, x1$congruency, sep = "_")
Run Code Online (Sandbox Code Playgroud)

我得到的水平是:

x2 <- factor(x2)

class(x2)
[1] "factor"

levels(x2)
[1] "102_1" "102_2" "102_9" "200_1" "200_2" "200_9" "34_1"  "34_2"  "34_9" 
[10] "68_1"  "68_2"  "68_9" 
Run Code Online (Sandbox Code Playgroud)

我知道在粘贴列后我可以更改级别的顺序.但是我希望能够对列进行排序,以便在粘贴它之后,我不需要更改级别的顺序.有没有办法可以做到这一点?例如,我尝试使用order()函数命令x1(我正确地做了),然后粘贴两列,但我仍然得到相同的级别顺序,这不是我想要的顺序.

任何帮助将不胜感激,

阿亚拉

r paste levels

2
推荐指数
1
解决办法
1219
查看次数

标签 统计

r ×2

cmd ×1

devtools ×1

levels ×1

paste ×1