-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmedicamentos.Rmd
88 lines (61 loc) · 1.29 KB
/
medicamentos.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: "Analise Medicamentos"
output: html_notebook
---
```{r}
library(tidyverse)
library(fs)
library(zip) # install.packages("zip")
```
```{r}
dir_ls("data")
```
```{r}
unzip("data/TA_PRECOS_MEDICAMENTOS.zip",
exdir="data")
```
```{r}
fname <- "data/TA_PRECOS_MEDICAMENTOS.csv"
locale_brasil <- locale(encoding="ISO-8859-1",
decimal_mark = ",")
first3 <- read_lines(fname,n_max=3,locale=locale_brasil)
first3[1] %>% str_count(";")
```
```{r}
guess_encoding(fname)
```
```{r}
read_lines(fname,locale=locale_brasil) %>%
str_count(";") %>%
table
```
```{r}
df_medicamentos <- read_delim("data/TA_PRECOS_MEDICAMENTOS.zip",
delim=";",
locale=locale_brasil,
quote="@")
```
```{r}
read_lines(fname,locale=locale_brasil)[2084]
```
```{r}
nrow(df_medicamentos)
ncol(df_medicamentos)
```
```{r}
colnames(df_medicamentos)
```
```{r}
glimpse(df_medicamentos)
```
```{r}
df_medicamentos %>%
count(NO_RAZAO_SOCIAL,sort=T)
```
```{r}
df_medicamentos %>%
group_by(NO_RAZAO_SOCIAL,NO_PRODUTO) %>%
summarize(quantos=n(),
ticket_medio=mean(NU_PF18_INTEIRO,na.rm=T)) %>%
View
```