[英]How to select columns in RStudio Viewer?
I have a dataframe
and would like to inspect and compare several columns. 我有一个dataframe
,想检查和比较几列。 How can I select two or more columns with the data Viewer? 如何使用数据查看器选择两列或更多列? I do not want to create a subsample for those columns each time. 我不想每次为这些列创建一个子样本。 Is there another way? 还有另一种方法吗?
data(mtcars)
View(mtcars$mpg)
View(mtcars$mpg, mtcars$mpg) # not working
View(c(mtcars$mpg, mtcars$cyl)) # shows 2 columns underneath each other
I usually use this code to do this 我通常使用此代码执行此操作
library(dplyr)
mtcars%>%
select(mpg,cyl)%>%
View
It uses the dplyr
package and the pipe %>%
. 它使用dplyr
软件包和管道%>%
。 It works in a way that you first give it your data, then you manipulate it (in your case just selecting the rows) and then throw in View,
head()
, str()
or any other function. 它的工作方式是,首先给它提供数据,然后对其进行处理(在这种情况下,只需选择行),然后抛出View,
head()
, str()
或任何其他函数。
View()
will only take a dataframe, not 2 seperate vectors View()
将仅使用一个数据帧,而不是2个单独的向量
With base R you could do something like 使用基数R,您可以执行以下操作
View(mtcars[c("mpg", "cyl")])
您可以在View
使用data.frame
而不是c
,即
View(data.frame(mtcars$mpg, mtcars$cyl))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.