简体   繁体   English

在R中选择一行,结果是一个新表

[英]Select one row in R, result is a new table

I try to select just one row in my data but the result come out in new data and I can't compute the mean of this, because the header is showing. 我尝试仅在数据中选择一行,但结果将显示在新数据中,并且由于标题显示,因此我无法计算其均值。 But when I select the column, there is no problem and I can see the result as a value. 但是,当我选择该列时,没有问题,我可以将结果视为一个值。 You can see the result of the code in the photo that y is in data and X is in the value. 您可以在照片中看到代码的结果,其中y是数据,而X是值。

y=mydata[1,]
X=mydata[,4]

enter image description here 在此处输入图片说明

you should use rowMeans. 您应该使用rowMeans。 When you select a row you are selecting multiple variables and that results in giving you a dataframe. 选择一行时,您正在选择多个变量,这将为您提供一个数据框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM