如何在一个空的data.frame中设置列的类型?

时间:2018-10-16 22:06:39

标签: r dataframe matrix types coercion

我需要将一个结果集<p>Hi Recruiter, in this email, you would find the resume of the latest applicant</p> <p>Resume: <%= image_tag @applicant.resume %></p> 放入此data.frame中,以确保我有适当的列,即使结果集不包含它们也是如此。这是为了稍后再写入MySQL数据库。

union

我该如何以不将dbNames <- c('a','b','c','d') emptyTableOut <- data.frame( cbind( matrix(character(), ncol = 1, nrow = 0), # needs to be char matrix(integer(), ncol = 3, nrow = 0) # needs to be int ), stringsAsFactors = FALSE) %>% setNames(nm = c(dbNames)) > glimpse(emptyTableOut) Observations: 0 Variables: 4 $ a <chr> $ b <chr> $ c <chr> $ d <chr> 强制为int的方式执行此操作?

这个问题与已经发布的答案不同,因为我有大量的列,而不是这个最小可重复的示例所隐含的列。

0 个答案:

没有答案