覆盖“未显示变量"在dplyr中,以显示df中的所有列 [英] Overriding "Variables not shown" in dplyr, to display all columns from df

查看:84
本文介绍了覆盖“未显示变量"在dplyr中,以显示df中的所有列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在本地数据框中有一列时,有时会收到消息Variables not shown,例如这个(荒谬的)示例,只需要足够的列即可.

library(dplyr)
library(ggplot2) # for movies

movies %.% 
 group_by(year) %.% 
 summarise(Length = mean(length), Title = max(title), 
  Dramaz = sum(Drama), Actionz = sum(Action), 
  Action = sum(Action), Comedyz = sum(Comedy)) %.% 
 mutate(Year1 = year + 1)

   year    Length                       Title Dramaz Actionz Action Comedyz
1  1898  1.000000 Pack Train at Chilkoot Pass      1       0      0       2
2  1894  1.000000           Sioux Ghost Dance      0       0      0       0
3  1902  3.555556     Voyage dans la lune, Le      1       0      0       2
4  1893  1.000000            Blacksmith Scene      0       0      0       0
5  1912 24.382353            Unseen Enemy, An     22       0      0       4
6  1922 74.192308      Trapped by the Mormons     20       0      0      16
7  1895  1.000000                 Photographe      0       0      0       0
8  1909  9.266667              What Drink Did     14       0      0       7
9  1900  1.437500      Uncle Josh's Nightmare      2       0      0       5
10 1919 53.461538     When the Clouds Roll by     17       2      2      29
..  ...       ...                         ...    ...     ...    ...     ...
Variables not shown: Year1 (dbl)

我想看Year1!如何查看所有列,最好是默认情况下.

解决方案

(现在)有一种方法可以覆盖打印出来的列的宽度.如果您运行此命令,一切都会很好

options(dplyr.width = Inf)

我在此处写下了.. >

When I have a column in a local data frame, sometimes I get the message Variables not shown such as this (ridiculous) example just needed enough columns.

library(dplyr)
library(ggplot2) # for movies

movies %.% 
 group_by(year) %.% 
 summarise(Length = mean(length), Title = max(title), 
  Dramaz = sum(Drama), Actionz = sum(Action), 
  Action = sum(Action), Comedyz = sum(Comedy)) %.% 
 mutate(Year1 = year + 1)

   year    Length                       Title Dramaz Actionz Action Comedyz
1  1898  1.000000 Pack Train at Chilkoot Pass      1       0      0       2
2  1894  1.000000           Sioux Ghost Dance      0       0      0       0
3  1902  3.555556     Voyage dans la lune, Le      1       0      0       2
4  1893  1.000000            Blacksmith Scene      0       0      0       0
5  1912 24.382353            Unseen Enemy, An     22       0      0       4
6  1922 74.192308      Trapped by the Mormons     20       0      0      16
7  1895  1.000000                 Photographe      0       0      0       0
8  1909  9.266667              What Drink Did     14       0      0       7
9  1900  1.437500      Uncle Josh's Nightmare      2       0      0       5
10 1919 53.461538     When the Clouds Roll by     17       2      2      29
..  ...       ...                         ...    ...     ...    ...     ...
Variables not shown: Year1 (dbl)

I want to see Year1! How do I see all the columns, preferably by default.

解决方案

There's (now) a way of overriding the width of columns that gets printed out. If you run this command all will be well

options(dplyr.width = Inf)

I wrote it up here.

这篇关于覆盖“未显示变量"在dplyr中,以显示df中的所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆