我有一个有两列的表:你是否生病(H01)和生病天数(H03).但是,如果H01 == false,则生病的天数为NA,我想将其设置为0.当我这样做时:
test <- pe94.person[pe94.person$H01 == 12,]
test$H03 <- 0
Run Code Online (Sandbox Code Playgroud)
它工作正常.但是,我想替换原始数据帧中的值.但是,这失败了:
pe94.person[pe94.person$H01 == 12,]$H03 <- 0
Run Code Online (Sandbox Code Playgroud)
它返回:
> pe94.person[pe94.person$H01 == 12,]$H03 <- 0
Error in `[<-.data.frame`(`*tmp*`, pe94.person$H01 == 12, , value = list( :
missing values are not allowed in subscripted assignments of data frames
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?对于它的价值,这是一个频率表:
> table(pe94.person[pe94.person$H01 == 12,]$H03)
2 3 5 28
3 1 1 1
Run Code Online (Sandbox Code Playgroud) 我正在尝试运行两件事:首先,我用4x5创建一个PDF,以dev.off()结束,然后尝试创建一个新图.然而,在开始第二个情节后,我得到:
Error in gzfile(file, "wb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "wb") :
cannot open compressed file '/var/folders/n9/pw_dz8d13j3gb2xgqb6rfnz00000gn/T/RtmpTfm1Ur/rs-graphics-822a1c83-b3fd-46c3-8028-4e0778f91d0c/4db4b438-ac35-403b-b791-e781baba152c.snapshot', probable reason 'No such file or directory'
Graphics error: Error in gzfile(file, "wb") : cannot open the connection
Run Code Online (Sandbox Code Playgroud)
这个错误是什么?工作目录是我有读/写访问权限,我的硬盘驱动器未满.
另外,我正在使用RStudio.