介绍 iPhone 的 health APP 存储着我们的私人健康数据, 这里有一篇帖子是用 Python 分析 health APP 的数据Apple Health Data How to Export Analyze Visualize Guide - ryanpraski.com , 而我更喜欢 R 的版本. 让我们赶紧开始吧!! 首先获取数据并读取 从你的 health APP 应用中导出数据 在 R 中读取数据 加载包并读入数据 library(XML) library(tidyverse) library(lubridate) library(scales) library(here) library(ggthemes) xml <- xmlParse(here("data/apple_health_export/export.xml")) summary(xml) ## $nameCounts ## ## Record ExportDate HealthData Me Workout ## 90037 1 1 1 1 ## ## $numNodes ## [1] 90041 Record 是我的主要数据, 有 90,037 条

Continue reading

Mind map Goal impute missing data fit regression library(tidyverse) library(AER) library(naniar) library(mice) Steps Step 01. missing data wages_data <- read_csv("/Users/zero/myrepo/jixingBlogdown/data/Mroz.csv") wages_data <- wages_data %>% select(wage, educ, fatheduc, motheduc, inlf, hours, kidslt6, kidsge6, age, huswage, mtr, unem, city, exper) %>% mutate_at(vars(kidslt6, kidsge6, hours, educ, age, wage, huswage, mtr, motheduc, fatheduc, unem, exper), as.numeric) %>% mutate_at(vars(city, inlf), as.character) wages_data <- wages_data %>% mutate(wage = ifelse(is.na(wage), 0, wage)) vis_miss(wages_data) wages_mis <- ampute(wages_data)$amp vis_miss(wages_mis) Step 02.

Continue reading

在我写文章画图时经常遇到的一个问题是:ggplot2 坐标轴的输入不支持输入数据框的变量名,通常会报错找不到对象 🌰:问题描述 data: early senate poll library(tidyverse) # general tasks library(broom) # tidy model output library(ggthemes) # style the plots poll_data <- read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/early-senate-polls/early-senate-polls.csv") glimpse(poll_data) ## Observations: 107 ## Variables: 4 ## $ year <int> 2006, 2006, 2006, 2006, 2006, 2006, 2006... ## $ election_result <int> -39, -10, -9, -16, 40, 10, -2, -41, -31,... ## $ presidential_approval <int> 46, 33, 32, 33, 53, 44, 37, 39, 42, 33, ... ## $ poll_average <int> -28, -10, -1, -15, 39, 14, 2, -22, -27, .

Continue reading

Author's picture

Jixing Liu

Reading And Writing

Data Scientist

China