小编Sj *_* Bq的帖子

要在R中的列表中的每个元素中添加新值?

这里list1只有两个元素 - " name"和" age",每个元素中都有两个值,现在我想在每个元素中添加新值,

list1<-list(name=c("bob","john"),age=c(15,17))
list1
$name
[1] "bob"  "john"

$age
[1] 15 17
list1[[1]][3]<-"herry"
list1[[2]][3]<-17
list1
$name
[1] "bob"   "john"  "herry"

$age
[1] 15 17 17
Run Code Online (Sandbox Code Playgroud)

有更简单的方法吗?

r list

9
推荐指数
1
解决办法
5768
查看次数

如何将t.test的结果写入文件?

如何将结果写入t.test文件?

> x  
[1] 12.2 10.8 12.0 11.8 11.9 12.4 11.3 12.2 12.0 12.3  
> t.test(x)

One Sample t-test  

data:  x   
t = 76.2395, df = 9, p-value = 5.814e-14  
alternative hypothesis: true mean is not equal to 0   
95 percent confidence interval:  
 11.5372 12.2428   
sample estimates:  
mean of x   
11.89   

> write(t.test(x),file="test")    
Error in cat(list(...), file, sep, fill, labels, append) : 
argument 1 (type 'list') cannot be handled by 'cat'
Run Code Online (Sandbox Code Playgroud)

r

0
推荐指数
1
解决办法
2413
查看次数

标签 统计

r ×2

list ×1