R中的字符(空)替换

时间:2016-02-07 11:25:02

标签: r

我一直在寻找一种方法来做到这一点并走向死胡同!

item1当前正在返回为字符(空)但是我想找到一种说法,如果item1返回为字符(空)然后“0”,否则显示item1

非常感谢帮助和建议!

代码

Goals <- PlayerScrape %>% 
  html_nodes("#yw1 tfoot .zentriert:nth-child(4)") %>%
  html_text()
  as.numeric()

一些尝试

  Goals <- na.zero(Goals)
  if(is.null(Goals)){Goals <-0}

其他尝试

Goals <- if(is.null(Goals)){0}else{Goals}

EmptyCheck <- nchar(as.character(Goals[1]))

0 个答案:

没有答案
相关问题