首页 > 解决方案 > 强制引入的 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

标签: r

解决方案


推荐阅读