andrea.nieves7 1 year ago
parent
commit
13711966fc
4 changed files with 17 additions and 129 deletions
  1. 16
    10
      App.js
  2. 0
    52
      R.R
  3. 1
    1
      app.json
  4. 0
    66
      fetchTables.py

+ 16
- 10
App.js View File

@@ -5,6 +5,20 @@ import data from './transfer.json'
5 5
 
6 6
 
7 7
 
8
+var information = ""
9
+
10
+function loadDoc() {
11
+  var xhttp = new XMLHttpRequest();
12
+  xhttp.onreadystatechange = function() {
13
+    if (this.readyState == 4 && this.status == 200) {
14
+         information = this.responseText;
15
+		 App.setData()
16
+  }
17
+  };
18
+  xhttp.open("GET", "https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72", true);
19
+  xhttp.send();
20
+  
21
+}
8 22
 
9 23
 //change this to an external css file later
10 24
 const styles = StyleSheet.create({
@@ -44,14 +58,6 @@ const styles = StyleSheet.create({
44 58
   },
45 59
   scrollView:{
46 60
 	  marginHorizontal: 20
47
-  },
48
-  data: {
49
-	  color: "white",
50
-	  fontSize: 20
51
-  },
52
-  graph: {
53
-	  borderColor: "blue",
54
-	  height: 200
55 61
   }
56 62
 });
57 63
 
@@ -97,7 +103,7 @@ let states = {
97 103
 		  
98 104
 			<Text style={styles.intro}>DATADATADATADATADATA</Text>
99 105
 		
100
-			<Text style={styles.sub}>{importJSON()}</Text>
106
+			<Text style={styles.sub}>{information}</Text>
101 107
 			 
102 108
 			<Image source={require('./testimg.gif')} />
103 109
 			
@@ -166,4 +172,4 @@ setNews = () => this.setState({ current: states.newsView })
166 172
 }
167 173
 
168 174
 
169
-export default App
175
+export default App

+ 0
- 52
R.R View File

@@ -1,52 +0,0 @@
1
-library(tidycensus)
2
-library(tidyverse)
3
-
4
-tableYear = 2020
5
-
6
-#log on with API
7
-census_api_key("7a853acf81fd5758228680556ac831138c40b83e")
8
-
9
-#load variables
10
-pueblos = 78
11
-variables = load_variables(2020,"acs5/profile")
12
-codes = variables$name
13
-label0 = variables$label
14
-
15
-#view variables
16
-#varTable = table(variables$concept)
17
-#write.table(varTable, file = "cat.txt", sep = ",", quote = FALSE, row.names = F)
18
-
19
-#pull all tables with every variable
20
-  
21
-test = get_acs(geography = "county",
22
-               state = "PR",
23
-               year = tableYear,
24
-               variables = codes)
25
-
26
-#add label column
27
-#create empty vector 
28
-labelCol = c()
29
-
30
-#amount of GEOIDS
31
-for (x in 1:pueblos){
32
-  labelCol = c(labelCol, label0)
33
-}
34
-
35
-#combine test and cols
36
-test["label"] = labelCol
37
-
38
-#rearrange cols
39
-test = test[c("NAME","label","variable","estimate","moe","GEOID")]
40
-
41
-GEOIDS = table(test$GEOID)
42
-
43
-#omit NA rows
44
-noNA = na.omit(test)
45
-
46
-DP02table = noNA %>% filter(startsWith(variable,"DP02"))
47
-
48
-DP03table = noNA %>% filter(startsWith(variable,"DP03"))
49
-
50
-DP04table = noNA %>% filter(startsWith(variable,"DP04"))
51
-
52
-DP05table = noNA %>% filter(startsWith(variable,"DP05"))

+ 1
- 1
app.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "expo": {
3
-    "name": "Test",
3
+    "name": "App",
4 4
     "slug": "Test",
5 5
     "version": "47.0.0",
6 6
     "assetBundlePatterns": [

+ 0
- 66
fetchTables.py View File

@@ -1,66 +0,0 @@
1
-import pandas as pd
2
-import rpy2.robjects as robjects
3
-
4
-#hellooo
5
-
6
-robjects.r('''
7
-        library(tidycensus)
8
-library(tidyverse)
9
-
10
-tableYear = 2020
11
-
12
-#log on with API
13
-census_api_key("7a853acf81fd5758228680556ac831138c40b83e")
14
-
15
-#load variables
16
-pueblos = 78
17
-variables = load_variables(2020,"acs5/profile")
18
-codes = variables$name
19
-label0 = variables$label
20
-
21
-#view variables
22
-#varTable = table(variables$concept)
23
-#write.table(varTable, file = "cat.txt", sep = ",", quote = FALSE, row.names = F)
24
-
25
-#pull all tables with every variable
26
-  
27
-test = get_acs(geography = "county",
28
-               state = "PR",
29
-               year = tableYear,
30
-               variables = codes)
31
-
32
-#add label column
33
-#create empty vector 
34
-labelCol = c()
35
-
36
-#amount of GEOIDS
37
-for (x in 1:pueblos){
38
-  labelCol = c(labelCol, label0)
39
-}
40
-
41
-#combine test and cols
42
-test["label"] = labelCol
43
-
44
-#rearrange cols
45
-test = test[c("NAME","label","variable","estimate","moe","GEOID")]
46
-
47
-GEOIDS = table(test$GEOID)
48
-
49
-#omit NA rows
50
-noNA = na.omit(test)
51
-
52
-DP02table = noNA %>% filter(startsWith(variable,"DP02"))
53
-
54
-DP03table = noNA %>% filter(startsWith(variable,"DP03"))
55
-
56
-DP04table = noNA %>% filter(startsWith(variable,"DP04"))
57
-
58
-DP05table = noNA %>% filter(startsWith(variable,"DP05"))
59
-        ''')
60
-        
61
-table02 = robjects.r('''DP02table''')
62
-table03 = robjects.r('''DP03table''')
63
-table04 = robjects.r('''DP04table''')
64
-table05 = robjects.r('''DP05table''')
65
-
66
-print(table02)