r - 强制引入的 NA(无缺失值)
问题描述
我有带有坐标的推文。我想根据位置将它们固定在地图上。当我尝试运行此代码块时,它给出“强制引入的 NAs”错误。我认为分隔符或 as.numeric 函数有问题。问题可能是由通过这个我阅读了所有其他主题,但我没有找到解决方案。
library(dplyr)
library(tidyr)
options(stringsAsFactors = FALSE)
json_file <- "db1.json"
boulder_flood_tweets <- stream_in(file(json_file))
tweet_data <- data.frame(date_time = boulder_flood_tweets$created_at,
username = boulder_flood_tweets$user$screen_name,
tweet_text = boulder_flood_tweets$text,
coords = boulder_flood_tweets$coordinates)
start_date <- as.POSIXct('2013-09-13 00:00:00')
end_date <- as.POSIXct('2019-05-12 00:00:00')
flood_tweets <- tweet_data %>%
mutate(coords.coordinates = gsub("\\)|c\\(", "", coords.coordinates),
date_time = as.POSIXct(date_time, format = "%a %b %d %H:%M:%S +0000 %Y")) %>%
separate(coords.coordinates, c("long", "lat"), sep = ", ") %>%
mutate_at(c("lat", "long"), as.numeric) %>%
filter(date_time >= start_date & date_time <= end_date )
坐标样本图片:https ://ibb.co/NV5PKzQ
我的数据集的图像:https ://ibb.co/0K68sc5
解决方案
推荐阅读
- jmeter - 在 jmeter 中,我们如何处理每次运行中生成的编码密码
- batch-file - 将一个 mp3 文件批量复制到其父目录并重命名
- node.js - Node Js 是否使用 libuv 线程池进行网络 I/O
- android - android 8(oreo)中的文本对齐问题 - 在两个单词之间添加了额外的空格
- java - 在编组之前动态隐藏一些字段(java到json)
- linux - 在 Bash 中显示调用堆栈
- ios - 重新选择 UITabBar 项目时防止弹出视图
- c# - 通过反射获取父级的静态字段值
- php - 在 redux 框架中自定义 css 不起作用
- javascript - 未选择父下拉列表时如何显示警报选择子类别?