使用setAs()获取警告以指定R中的colClasses

tac*_*uan 9 datetime warnings r class user-defined-types

我尝试使用此问题中提供的答案@Greg Snow ,但不管我做什么,我都会收到警告.有人可以帮助这个:?

> setAs("character","myDate",function(from) as.Date(from, format="%b %d, %Y %r"))
in method for ‘coerce’ with signature ‘"character","myDate"’: no definition for class “myDate”
Run Code Online (Sandbox Code Playgroud)

我想确保"方法"包是加载的(看起来像setAs依赖它)我得到了这个:

> getOption("defaultPackages")
[1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"
Run Code Online (Sandbox Code Playgroud)

TIA