![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
R语言做直方图,怎么出现“参数没用”,怎么修改什么意思
>coin_tosses=function(n)+{+s=sample(0:1,n,replace=TRUE)+}>outcome=function(x)+{+i=1+w...
> coin_tosses=function(n)
+ {
+ s=sample(0:1,n,replace=TRUE)
+ }
> outcome=function(x)
+ {
+ i=1
+ w=0
+ j=length(x)
+ while(i<=j)
+ {
+ if(x[i]==1)
+ {w=w+1}
+ else
+ {w=w-1}
+ i=i+1
+ }
+ z=w
+ }
> test_1000=function(m)
+ {
+ i=1
+ while(i<=m)
+ {
+ a=coin_tosses(1000)
+ b=outcome(a)
+ c[i]=b
+ i=i+1
+ }
+ y=c
+ }
>
> x=test_1000(100)
> hist(x)
Error in hist(y, col = "gray", main = "Histogram of the final profit/loss in each game", :
参数没有用(col = "gray", main = "Histogram of the final profit/loss in each game", xlab = "The final profit/loss of each game")
此外: There were 29 warnings (use warnings() to see them)
> 展开
+ {
+ s=sample(0:1,n,replace=TRUE)
+ }
> outcome=function(x)
+ {
+ i=1
+ w=0
+ j=length(x)
+ while(i<=j)
+ {
+ if(x[i]==1)
+ {w=w+1}
+ else
+ {w=w-1}
+ i=i+1
+ }
+ z=w
+ }
> test_1000=function(m)
+ {
+ i=1
+ while(i<=m)
+ {
+ a=coin_tosses(1000)
+ b=outcome(a)
+ c[i]=b
+ i=i+1
+ }
+ y=c
+ }
>
> x=test_1000(100)
> hist(x)
Error in hist(y, col = "gray", main = "Histogram of the final profit/loss in each game", :
参数没有用(col = "gray", main = "Histogram of the final profit/loss in each game", xlab = "The final profit/loss of each game")
此外: There were 29 warnings (use warnings() to see them)
> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询