r - Tabulate column containing list in R
问题描述
I am using sapply (or lapply for what matters here) to tabulate the classes of a data frame.
f<-as.POSIXct(c("2014-10-02","2016-11-05","2014-09-11"))
dd<-c(1,12,22)
fr<-c("coo","foo","doo")
df<-cbind.data.frame(f,dd,fr)
c<-sapply(df,class)
This generates an error when, as for the case of the posixct class, the class in a list of 2 elements.
table(c)
Error in table(c) : all arguments must have the same length
c
$`f`
[1] "POSIXct" "POSIXt"
$dd
[1] "numeric"
$fr
[1] "factor"
Obviously unlist will not work as the double class is then counted as 2 separate classes. How do I collapse the double class in a unitary element here?
解决方案
推荐阅读
- javascript - 带画布的引导模式无法正确显示响应式设计
- java - Maven-src-plugin & Java 11 - 无法扫描类文件:
- python - 增加每秒的请求数量
- http - jboss 7 http 连接器支持字节范围标头
- c# - 发现 MSTest 框架测试期间的类型加载异常
- python-2.7 - 使用多次尝试:除了处理错误不起作用
- graphql - 用 Jest 编写结构期望
- php - Laravel ¦ 将 2 个值的集合存储在一个字符串中以供解析并稍后显示它们
- angularjs - 如何将自定义 angular 1 过滤器实现为 ES6 类?
- xaml - UWP - Pivot IsTabStop 未按预期工作