-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path12 Dummy data using replicate function.R
More file actions
56 lines (40 loc) · 1.5 KB
/
12 Dummy data using replicate function.R
File metadata and controls
56 lines (40 loc) · 1.5 KB
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
# Create variable values summary tables using DPLYR library
# 12 Variable values freq table.R
# 0. Setup Dummy data set
library(dplyr)
library(tidyverse)
library(here)
Indic_ID <-c(replicate(5,"AF-Prev"),replicate(3,"Exercise"),
replicate(7,"Education"),
replicate(4,"Housing"))
Region <-c(replicate(4,"Midlands"),replicate(7,"London"),
replicate(5,"North-west"),
replicate(3,"Souoth-East"))
Indic_value <-c(123,21,54,21,43,
76,87,43,48,65,
47,51,23,56,98,
41,57,12,19)
Mydata <-cbind.data.frame(Indic_ID,Region,Indic_value)
Mydata
names(Mydata)
> names(Mydata)
[1] "Indic_ID" "Indic_Name" "Region"
# 1. Get Frequency tables of each the data set metrics
# Frequency table for Metric 1: Indic_ID
# Variable 01-03 (Indic_ID)
ID_values <- Mydata %>%
select(Indic_ID) %>%
group_by(Indic_ID) %>%
summarize( freq = n()) %>%
arrange(desc(freq))
ID_values
# Variable 02-03 (Region)
Region_values <- Mydata %>%
select(Region) %>%
group_by(Region) %>%
summarize( freq = n()) %>%
arrange(desc(freq))
Region_values
# Write out each of the metric frequency tables to a .csv file
write.csv(ID_values,here("Checks",paste0("ID_values_table",".csv")), row.names = TRUE)
write.csv(Region_values,here("Checks",paste0("Region_values_table",".csv")), row.names = TRUE)