Тихий type_convert

Есть ли способ использовать функцию type_convert из пакета readr, не сообщая вам, какую спецификацию столбца она использует в консоли.

Из примера в справочной документации ?:

> df <- data.frame(
+     x = as.character(runif(10)),
+     y = as.character(sample(10)),
+     stringsAsFactors = FALSE
+ )
> str(type_convert(df))
Parsed with column specification:
cols(
  x = col_double(),
  y = col_integer()
)
'data.frame':   10 obs. of  2 variables:
 $ x: num  0.10262 0.15581 0.00638 0.6815 0.98654 ...
 $ y: int  9 5 8 10 4 6 1 2 3 7

Я бы хотел, чтобы часть Parsed with column specification исчезла, чтобы она выглядела так:

> df <- data.frame(
+     x = as.character(runif(10)),
+     y = as.character(sample(10)),
+     stringsAsFactors = FALSE
+ )
> str(type_convert(df))
'data.frame':   10 obs. of  2 variables:
 $ x: num  0.10262 0.15581 0.00638 0.6815 0.98654 ...
 $ y: int  9 5 8 10 4 6 1 2 3 7

person Marijn Stevering    schedule 22.09.2016    source источник


Ответы (1)


Оберните вызов type_convert с помощью suppressMessages:

str(suppressMessages(type_convert(df)))

Подробное обсуждение см. в разделе read_excel read in messages- Supress?

person Holger Brandl    schedule 20.01.2017