Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用ggplot2的简单自定义打印功能:错误:长度必须为1或与数据相同_R_Ggplot2 - Fatal编程技术网

R 使用ggplot2的简单自定义打印功能:错误:长度必须为1或与数据相同

R 使用ggplot2的简单自定义打印功能:错误:长度必须为1或与数据相同,r,ggplot2,R,Ggplot2,在以下工作中,它根据数据顺序绘制一列数据: s<-data.frame(t=c(3, 50, 20, 100, 7, 80)) ggplot(s, aes(y=s$t, x=seq(1, length(s$t)))) + geom_point()+ geom_hline(yintercept =10) s不要在aes中使用$。它在指定为data的data.frame中查找使用非标准计算的变量。如果使用$,可能会得到意外的结果 我不知道在aes中有任何使用$的ggplot2示例

在以下工作中,它根据数据顺序绘制一列数据:

s<-data.frame(t=c(3, 50, 20, 100, 7, 80))
ggplot(s, aes(y=s$t, x=seq(1, length(s$t)))) + 
  geom_point()+
  geom_hline(yintercept =10)

s不要在
aes
中使用
$
。它在指定为
data
的data.frame中查找使用非标准计算的变量。如果使用
$
,可能会得到意外的结果

我不知道在
aes
中有任何使用
$
的ggplot2示例

在这里,您可以使用aes\u q

plot1<-function(a, b, c){
  a$x <- seq_len(nrow(a))
  ggplot(a, aes_q(y=substitute(b), x=quote(x))) + 
    geom_point()+
    geom_hline(yintercept = c) 
}

plot1(s, t, 10)

plot1请勿在
aes
中使用
$
。它在指定为
data
的data.frame中查找使用非标准计算的变量。如果使用
$
,可能会得到意外的结果

我不知道在
aes
中有任何使用
$
的ggplot2示例

在这里,您可以使用aes\u q

plot1<-function(a, b, c){
  a$x <- seq_len(nrow(a))
  ggplot(a, aes_q(y=substitute(b), x=quote(x))) + 
    geom_point()+
    geom_hline(yintercept = c) 
}

plot1(s, t, 10)
plot1可能对您有所帮助。也许对你有帮助。
plot1<-function(a, b, c){
  a$x <- seq_len(nrow(a))
  ggplot(a, aes_q(y=substitute(b), x=quote(x))) + 
    geom_point()+
    geom_hline(yintercept = c) 
}

plot1(s, t, 10)