简体   繁体   中英

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=mydata[1,]
X=mydata[,4]

enter image description here

you should use rowMeans. When you select a row you are selecting multiple variables and that results in giving you a dataframe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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