2016-09-22 3 views
0

Gibt es eine Möglichkeit, die type_convert-Funktion aus dem readr-Paket zu verwenden, ohne Ihnen zu sagen, welche Spaltenspezifikation in der Konsole verwendet wird.Silent type_convert

Aus dem Beispiel in der ? Hilfe-Dokumentation:

> 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 

ich die Parsed with column specification Teil sieht es weg wollen würde, so wie:

> 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 

Antwort