[英]How to select column of dataframe using numbers
At the moment I am selecting columns the usual way:目前我正在以通常的方式选择列:
`df$column1`
But I want to loop through the columns of my dataframe into a plot function, and when I use the method:但是我想将我的 dataframe 的列循环到 plot function 中,当我使用该方法时:
`df[,1]`
I get the error:我得到错误:
Don't know how to automatically pick scale for object of type data.frame.不知道如何为 data.frame 类型的 object 自动选择比例。 Defaulting to continuous.
默认为连续。 Error in is.finite(x): default method not implemented for type 'list'
is.finite(x) 中的错误:未为类型“列表”实现默认方法
So what would be the best way to select columns of the dataframe so that I can easily loop through the columns and avoid this error.那么,什么是 dataframe 的 select 列的最佳方法,以便我可以轻松地遍历列并避免此错误。
You can access dataframe columns using double square brackets eg df[[1]]
prints the first column.您可以使用双方括号访问 dataframe 列,例如
df[[1]]
打印第一列。 For more info on why/how/etc, see Dave Tang's blog post: https://davetang.org/muse/2013/08/16/double-square-brackets-in-r有关为什么/如何/等的更多信息,请参阅 Dave Tang 的博客文章: https://davetang.org/muse/2013/08/16/double-square-brackets-in-r
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.