暫無描述

.Rhistory 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. library(ggplot2)
  2. I = c(0,0,0,0,.005,0,.002,.01,.012,.01,.012,.0,.022,.020,.017,.03,.015,.052,.072,.06,.062,.062,.052,.047,.065,.09,.082,.077,.037,.017,.067)
  3. data = data.frame(I,II,III,IV,V,VI,VII)
  4. ggplot(data) + geom_point()
  5. ggplot(data[I]) + geom_point()
  6. ggplot(data[I],aes(x,y)) + geom_point()
  7. data
  8. mtcars
  9. data = rbind(I,II,III,IV,V,VI,VII)
  10. data
  11. ggplot(data,aes(x="I",y="[],1]")) + geom_point()
  12. plot(data)
  13. par(mfrow=c(3,3))
  14. "indigo"
  15. par(mfrow=c(1,1))
  16. plot(I, color="red",pch=21,xlab = "bins",ylab="frequency")
  17. plot(I, gcolor="red",pch=21,xlab = "bins",ylab="frequency")
  18. plot(I, gcolor="red",pch=21,xlab = "bins",ylab="frequency")
  19. plot(II, gcolor="orange",pch=21,xlab="bins",ylab="frequency")
  20. plot(III, gcolor="yellow",pch=21,xlab="bins",ylab="frequency")
  21. plot(IV, gcolor="green",pch=21,xlab="bins",ylab="frequency")
  22. plot(V, gcolor="blue",pch=21,xlab="bins",ylab="frequency")
  23. plot(VI, gcolor="indigo",pch=21,xlab="bins",ylab="frequency")
  24. plot(VII, gcolor="purple",pch=21,xlab="bins",ylab="frequency")
  25. plot(VII, gcolor="purple",pch=16,xlab="bins",ylab="frequency")
  26. plot(I, col="red",pch=16,xlab = "bins",ylab="frequency")
  27. par(bg="pink")
  28. plot(I, col="red",pch=16,xlab = "bins",ylab="frequency")
  29. points(II, col="orange",pch=16)
  30. plot(I, col="red",pch=16,xlab = "bins",ylab="frequency")
  31. points(II, col="orange",pch=16)
  32. points(III, col="yellow",pch=16)
  33. points(IV, col="green",pch=16)
  34. points(V, col="blue",pch=16)
  35. points(VI, col="indigo",pch=16)
  36. plot(I, col="red",pch=8,xlab = "bins",ylab="frequency")
  37. points(II, col="orange",pch=8)
  38. points(III, col="yellow",pch=8)
  39. points(IV, col="green",pch=8)
  40. points(V, col="blue",pch=8)
  41. points(VI, col="indigo",pch=8)
  42. points(VII, col="purple",pch=8)
  43. plot(I, col="red",pch=8,xlab = "bins",ylab="frequency")
  44. points(II, col="orange",pch=8)
  45. points(III, col="yellow",pch=8)
  46. points(IV, col="green",pch=8)
  47. points(V, col="blue",pch=8)
  48. points(VI, col="indigo",pch=8)
  49. legend(0,0,legend=c("I","II","III","IV","V","VI","VII")
  50. )
  51. legend(0,0,legend=c("I","II","III","IV","V","VI","VII"))
  52. legend(1,1,legend=c("I","II","III","IV","V","VI","VII"))
  53. plot(I, col="red",pch=8,xlab = "bins",ylab="frequency")
  54. points(II, col="orange",pch=8)
  55. points(III, col="yellow",pch=8)
  56. points(IV, col="green",pch=8)
  57. points(V, col="blue",pch=8)
  58. points(VI, col="purple",pch=8)
  59. points(VII, col="black",pch=8)
  60. legend(1,1,legend=c("I","II","III","IV","V","VI","VII"))
  61. legend(0,1,legend=c("I","II","III","IV","V","VI","VII"))
  62. legend(1,95,legend=c("I","II","III","IV","V","VI","VII"))
  63. legend(1,1,legend=c("I","II","III","IV","V","VI","VII"))
  64. legend(1,1,legend=c("I","II","III","IV","V","VI","VII"),fill="white")
  65. legend(1,1,legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  66. legend(legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  67. legend(0,legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  68. legend(3,legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  69. legend(x=0,y=1legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  70. legend(x=0,y=1,legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  71. par(bg="pink")
  72. plot(I, col="red",pch=8,xlab = "bins",ylab="frequency")
  73. points(II, col="orange",pch=8)
  74. points(III, col="yellow",pch=8)
  75. points(IV, col="green",pch=8)
  76. points(V, col="blue",pch=8)
  77. points(VI, col="purple",pch=8)
  78. points(VII, col="black",pch=8)
  79. legend(x=0,y=1,legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  80. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),fill="white",col=c("red","orange","yellow","green","blue","purple","black"))
  81. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),col=c("red","orange","yellow","green","blue","purple","black"))
  82. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),col=1:7)
  83. plot(I, col="red",pch=8,xlab = "bins",ylab="frequency")
  84. points(II, col="orange",pch=8)
  85. points(III, col="yellow",pch=8)
  86. points(IV, col="green",pch=8)
  87. points(V, col="blue",pch=8)
  88. points(VI, col="purple",pch=8)
  89. points(VII, col="black",pch=8)
  90. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),col=1:7)
  91. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),col=c("red","orange","yellow","green","blue","purple","black"))
  92. plot(I, col="red",pch=8,xlab = "bins",ylab="frequency")
  93. points(II, col="orange",pch=8)
  94. points(III, col="yellow",pch=8)
  95. points(IV, col="green",pch=8)
  96. points(V, col="blue",pch=8)
  97. points(VI, col="purple",pch=8)
  98. points(VII, col="black",pch=8)
  99. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),col=c("red","orange","yellow","green","blue","purple","black"))
  100. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),col=c("red","orange","yellow","green","blue","purple","black"))
  101. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),fill=c("red","orange","yellow","green","blue","purple","black"))
  102. plot(I, col="red",pch=8,xlab = "Bins",ylab="Frequency")
  103. points(II, col="orange",pch=8)
  104. points(III, col="yellow",pch=8)
  105. points(IV, col="green",pch=8)
  106. points(V, col="blue",pch=8)
  107. points(VI, col="purple",pch=8)
  108. points(VII, col="black",pch=8)
  109. legend("topleft",legend=c("I","II","III","IV","V","VI","VII"),fill=c("red","orange","yellow","green","blue","purple","black"))
  110. bins = rep(c(1:31),each=7)
  111. bins
  112. 1:31
  113. bins = rep(c((1:31)),each=7)
  114. 1:31
  115. bins
  116. bins = rep(c((1:31)),times=7)
  117. bins
  118. sample = rep(c("I","II","III","IV","V","VI","VII"), each =31)
  119. sample
  120. library(tidyverse)
  121. I = c(0,0,0,0,.005,0,.002,.01,.012,.01,.012,.0,.022,.020,.017,.03,.015,.052,.072,.06,.062,.062,.052,.047,.065,.09,.082,.077,.037,.017,.067)
  122. II = c(0,0,.002,0,0,.004,.004,.011,.009,.015,.013,.017,.028,.028,.019,.026,.030,.043,.054,.054,.058,.078,.061,.061,.056,.082,.069,.078,.032,.030,.035)
  123. III = c(0,0,0,0,0,0,.012,.006,.014,.006,.017,.012,.038,.012,.003,.029,.049,.043,.078,.058,.064,.066,.052,.072,.069,.061,.081,.075,.026,.006,.052)
  124. IV = c(0,0,0,0,0,.003,.006,.009,.006,.009,.012,.006,.037,.018,.027,.040,.015,.046,.095,.073,.067,.064,.052,.043,.052,.061,.073,.076,.015,.027,.067)
  125. V = c(0,0,0,0,0,.010,.012,.012,.007,.022,.026,.014,.034,.026,.031,.022,.034,.043,.048,.058,.077,.046,.050,.050,.072,.063,.050,.072,.019,.026,.075)
  126. install.packages("assertthat")
  127. library(tidyverse)
  128. install.packages("Rcpp")
  129. library(tidyverse)
  130. I = c(0,0,0,0,.005,0,.002,.01,.012,.01,.012,.0,.022,.020,.017,.03,.015,.052,.072,.06,.062,.062,.052,.047,.065,.09,.082,.077,.037,.017,.067)
  131. II = c(0,0,.002,0,0,.004,.004,.011,.009,.015,.013,.017,.028,.028,.019,.026,.030,.043,.054,.054,.058,.078,.061,.061,.056,.082,.069,.078,.032,.030,.035)
  132. III = c(0,0,0,0,0,0,.012,.006,.014,.006,.017,.012,.038,.012,.003,.029,.049,.043,.078,.058,.064,.066,.052,.072,.069,.061,.081,.075,.026,.006,.052)
  133. IV = c(0,0,0,0,0,.003,.006,.009,.006,.009,.012,.006,.037,.018,.027,.040,.015,.046,.095,.073,.067,.064,.052,.043,.052,.061,.073,.076,.015,.027,.067)
  134. V = c(0,0,0,0,0,.010,.012,.012,.007,.022,.026,.014,.034,.026,.031,.022,.034,.043,.048,.058,.077,.046,.050,.050,.072,.063,.050,.072,.019,.026,.075)
  135. VI = c(0,0,0,.002,0,.007,.005,.009,.009,.011,.014,.018,.043,.016,.027,.018,.043,.080,.062,.050,.084,.082,.062,.071,.050,.082,.057,.043,.005,.014,.034)
  136. VII = c(0,.002,.002,.003,.002,.003,.013,.013,.018,.015,.020,.016,.031,.010,.042,.016,.021,.028,.056,.056,.090,.044,.044,.056,.065,.075,.083,.075,.025,.026,.051)
  137. bins = rep(c((1:31)),times=7)
  138. sample = rep(c("I","II","III","IV","V","VI","VII"), each =31)
  139. values = c(I,II,III,IV,V,VI,VII)
  140. length(values)
  141. length(bins)
  142. length(sample)
  143. data = data.frame(bins,sample,values)
  144. data
  145. ggplot(data) +
  146. geom_point(mapping=aes(x=bins,y=values,color=sample)) +
  147. theme_bw()
  148. ggplot(data) +
  149. geom_point(mapping=aes(x=bins,y=values,color=sample)) +
  150. theme_bw() + xlab("Bin") + ylab("Alelles") +
  151. scale_x_continuous(breaks=(1:31))
  152. library(tidyverse)
  153. ggplot(data) +
  154. geom_point(mapping=aes(x=bins,y=values,color=sample)) +
  155. theme_bw() + xlab("Bin") + ylab("Alelle Frecuency") +
  156. scale_x_continuous(breaks=(1:31))
  157. a = c(9.96,9.97,9.95)
  158. sd(a)
  159. b = sd(a)
  160. b
  161. help(sd)
  162. a = c(10.01,10.26,9.96)
  163. sd(a)
  164. a = c(9.63,9.74,9.76)
  165. sd(a)
  166. a = c(7.24,7.59,8.46)
  167. sd(a)
  168. a = c(1.027,1.029,1.026)
  169. sd(a)
  170. mean(a)
  171. 2,5/10.27
  172. 2.5/10.27
  173. 10.25/10
  174. density = c(0.99,1.006,1.027,1.045,1.067)
  175. concentration = (0.87,2.01,5.02,7.00,10.00)
  176. concentration = c(0.87,2.01,5.02,7.00,10.00)
  177. plot(density, concentration)
  178. library(tidyverse)
  179. I = c(0,0,0,0,.005,0,.002,.01,.012,.01,.012,.0,.022,.020,.017,.03,.015,.052,.072,.06,.062,.062,.052,.047,.065,.09,.082,.077,.037,.017,.067)
  180. II = c(0,0,.002,0,0,.004,.004,.011,.009,.015,.013,.017,.028,.028,.019,.026,.030,.043,.054,.054,.058,.078,.061,.061,.056,.082,.069,.078,.032,.030,.035)
  181. III = c(0,0,0,0,0,0,.012,.006,.014,.006,.017,.012,.038,.012,.003,.029,.049,.043,.078,.058,.064,.066,.052,.072,.069,.061,.081,.075,.026,.006,.052)
  182. IV = c(0,0,0,0,0,.003,.006,.009,.006,.009,.012,.006,.037,.018,.027,.040,.015,.046,.095,.073,.067,.064,.052,.043,.052,.061,.073,.076,.015,.027,.067)
  183. V = c(0,0,0,0,0,.010,.012,.012,.007,.022,.026,.014,.034,.026,.031,.022,.034,.043,.048,.058,.077,.046,.050,.050,.072,.063,.050,.072,.019,.026,.075)
  184. VI = c(0,0,0,.002,0,.007,.005,.009,.009,.011,.014,.018,.043,.016,.027,.018,.043,.080,.062,.050,.084,.082,.062,.071,.050,.082,.057,.043,.005,.014,.034)
  185. VII = c(0,.002,.002,.003,.002,.003,.013,.013,.018,.015,.020,.016,.031,.010,.042,.016,.021,.028,.056,.056,.090,.044,.044,.056,.065,.075,.083,.075,.025,.026,.051)
  186. bins = rep(c((1:31)),times=7)
  187. sample = rep(c("I","II","III","IV","V","VI","VII"), each =31)
  188. values = c(I,II,III,IV,V,VI,VII)
  189. data = data.frame(bins,sample,values)
  190. ggplot(data) +
  191. geom_point(mapping=aes(x=bins,y=values,color=sample)) +
  192. theme_bw() + xlab("Bin") + ylab("Alelle Frecuency") +
  193. scale_x_continuous(breaks=(1:31))
  194. library(tidyverse)
  195. density = c(0.99,1.006,1.027,1.045,1.067)
  196. concentration = c(0.87,2.01,5.02,7.00,10.00)
  197. data = data.frame(density,concentration)
  198. data
  199. ggplot(data) +
  200. geom_point(mapping=aes(x=density,y=concentration,color=sample)) +
  201. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%")
  202. ggplot(data) +
  203. geom_point(mapping=aes(x=density,y=concentration)) +
  204. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%")
  205. ggplot(data) +
  206. geom_point(mapping=aes(x=density,y=concentration)) +
  207. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%")+
  208. geom_smooth(method='lm')
  209. ggplot(data) +
  210. geom_point(mapping=aes(x=density,y=concentration)) +
  211. geom_smooth(method='lm') +
  212. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%")
  213. ggplot(data, aes(x=density,y=concentration)) +
  214. geom_point() +
  215. geom_smooth(method='lm') +
  216. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%")
  217. ggplot(data, aes(x=density,y=concentration)) +
  218. geom_point() +
  219. geom_smooth(method='lm') +
  220. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%") +
  221. ggtitle("Density vs Concentration of Prepared Solutions")
  222. data = data.frame(density,concentration)
  223. model <- lm(concentration~density, data=data)
  224. summary(model)
  225. ggplot(data, aes(x=density,y=concentration)) +
  226. geom_point() +
  227. geom_smooth(method='lm') +
  228. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%") +
  229. ggtitle("Density vs Concentration of Prepared Solutions") +
  230. geom_label(x = x_lab, y = y_lab, label = "avg rate")
  231. ggplot(data, aes(x=density,y=concentration)) +
  232. geom_point() +
  233. geom_smooth(method='lm') +
  234. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%") +
  235. ggtitle("Density vs Concentration of Prepared Solutions") +
  236. geom_label(x = 1, y = 5, label = "avg rate")
  237. summary(model)
  238. ggplot(data, aes(x=density,y=concentration)) +
  239. geom_point() +
  240. geom_smooth(method='lm') +
  241. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%") +
  242. ggtitle("Density vs Concentration of Prepared Solutions") +
  243. geom_label(x = 1, y = 5, label = "y = 120.94x - 119.23") +
  244. geom_label(x = 1, y = 4, label = "R-squared: 0.9931") +
  245. xx
  246. library(tidyverse)
  247. density = c(0.99,1.006,1.027,1.045,1.067)
  248. concentration = c(0.87,2.01,5.02,7.00,10.00)
  249. data = data.frame(density,concentration)
  250. model <- lm(concentration~density, data=data)
  251. summary(model)
  252. ggplot(data, aes(x=density,y=concentration)) +
  253. geom_point() +
  254. geom_smooth(method='lm') +
  255. theme_bw() + xlab("Density(g/mL)") + ylab("Concentration%") +
  256. ggtitle("Density vs Concentration of Prepared Solutions") +
  257. geom_label(x = 1, y = 5, label = "y = 120.94x - 119.23") +
  258. geom_label(x = 1, y = 4, label = "R-squared: 0.9931")
  259. p = c(5.10,5.25,5.16)
  260. v = c(4.86,5.01,4.94)
  261. mean(p)
  262. sd(p)
  263. mean(v)
  264. sd(v)
  265. A = c(0.335,0.199,0.0953,0.0278)
  266. concentration = c(0.60,0.30,0.12,0.06)
  267. data = data.frame(A,concentration)
  268. model <- lm(A~concentration, data=data)
  269. summary(model)
  270. data = data.frame(A,concentration)
  271. model <- lm((A-0.01674)~(concentration-0.01674), data=data)
  272. summary(model)
  273. data = data.frame(A,concentration)
  274. model <- lm((A-0.01674)~(concentration-0.01674), data=data)
  275. summary(model)
  276. data = data.frame(A,concentration)
  277. model <- lm(I(A-0.01674)~(concentration-0.01674), data=data)
  278. summary(model)
  279. c = c(5.10,5.26,5.17)
  280. sd(c)
  281. mean(c)
  282. library(tidycensus)
  283. library(tidyverse)
  284. install.package("tidycensus")
  285. install.packages("tidycensus")
  286. library(tidyverse)
  287. library(tidycensus)
  288. library(tidycensus)
  289. library(tidyverse)
  290. library("writexl")
  291. census_api_key("7a853acf81fd5758228680556ac831138c40b83e")
  292. variables = load_variables(2019,"acs5")
  293. variables
  294. variables$name
  295. match("DP02",variables)
  296. variables$name[2000]
  297. variables$name[3000]
  298. variables$name[5000]
  299. variables$name[10000]
  300. variables$name[600000]
  301. variables$name[60000]
  302. variables$name[50000]
  303. variables$name[40000]
  304. variables$name[30000]
  305. variables$name[20000]
  306. variables = load_variables(2019,"acs5/profile")
  307. variables
  308. View(variables)
  309. length(variables)
  310. length(variables[1])
  311. variables = load_variables(2021,"acs5/profile")
  312. variables = load_variables(2020,"pl/profile")
  313. variables = load_variables(2020,"acs5/profile")
  314. variables
  315. View(variables)
  316. test = get_acs(geography = "county",
  317. state = "PR",
  318. year = 2020,
  319. variables = "DP02_0001")
  320. test
  321. View(test)
  322. test = get_acs(geography = "region",
  323. state = "PR",
  324. year = 2020,
  325. variables = "DP02_0001")
  326. test = get_acs(geography = "block",
  327. state = "PR",
  328. year = 2020,
  329. variables = "DP02_0001")
  330. test = get_acs(geography = "county",
  331. state = "PR",
  332. year = 2020,
  333. variables = "DP02_0001")
  334. View(test)
  335. variables$name
  336. codes = variables$name
  337. test = get_acs(geography = "county",
  338. state = "PR",
  339. year = 2020,
  340. variables = codes)
  341. view(test)
  342. noNA = na.omit(test)
  343. noNA
  344. view(noNA)
  345. view(variables)
  346. DP02table = noNA %>% filter(startsWith(variable,"DP02"))
  347. DP02table
  348. view(DP02table)
  349. DP02table = noNA %>% filter(startsWith(variable,"DP02"))
  350. DP03table = noNA %>% filter(startsWith(variable,"DP03"))
  351. DP04table = noNA %>% filter(startsWith(variable,"DP04"))
  352. DP05table = noNA %>% filter(startsWith(variable,"DP05"))
  353. view(DP04table)
  354. variables$name
  355. variables$label
  356. noNA$GEOID
  357. table(noNA$GEOID)
  358. length(table(noNA$GEOID))
  359. view(test)
  360. #amount of GEOIDS
  361. for (x in 1:78){
  362. labelCol = c(labelCol, labels)
  363. }
  364. #add label column
  365. #create empty vector
  366. labelCol = c()
  367. #amount of GEOIDS
  368. for (x in 1:78){
  369. labelCol = c(labelCol, labels)
  370. }
  371. #combine test and cols
  372. test["label"] = labelCol
  373. labelCol
  374. #amount of GEOIDS
  375. for (x in 1:78){
  376. labelCol = c(labelCol, labels)
  377. }
  378. labels()
  379. labels()
  380. labels
  381. variables
  382. variables$label
  383. label
  384. labels
  385. label0 = variables$label
  386. label0
  387. #add label column
  388. #create empty vector
  389. labelCol = c()
  390. #amount of GEOIDS
  391. for (x in 1:78){
  392. labelCol = c(labelCol, label0)
  393. }
  394. #combine test and cols
  395. test["label"] = labelCol
  396. view(test)
  397. #omit NA rows
  398. noNA = na.omit(test)
  399. DP02table = noNA %>% filter(startsWith(variable,"DP02"))
  400. DP03table = noNA %>% filter(startsWith(variable,"DP03"))
  401. DP04table = noNA %>% filter(startsWith(variable,"DP04"))
  402. DP05table = noNA %>% filter(startsWith(variable,"DP05"))
  403. view(DP02table)
  404. GEOIDS = table(test$GEOID)
  405. GEOIDS
  406. #rearrange cols
  407. test = test[c("NAME","label","variable","estimate","moe","GEOID")]
  408. view(test)
  409. pnorm(1.25)
  410. pnorm(1.25) - pnorm(-1.25)
  411. pnorm(1.875) - pnorm(-1.25)
  412. pnorm(0.75) - pnorm(-1.25)
  413. pnorm(1.25) - pnorm(-2.5)
  414. pnorm(2.7) - pnorm(2)
  415. pnorm(1.54)
  416. pnorm(1.54) - pnorm(-1.54)
  417. qnorm(0.4564)
  418. qnorm(0.9564)
  419. qnorm(0.05)
  420. qnorm(0.07)
  421. qnorm(0.94)
  422. qnorm(0.43)
  423. pnorm(-0.18)
  424. qnorm(0.43)
  425. pnorm(-0.17)
  426. pnorm(-1.30)
  427. qnorm(0.70,400,80)
  428. (106 - qnorm(0.70,106,21))/21
  429. (qnorm(0.70,106,21)-106)/21
  430. (qnorm(0.87,106,28)
  431. )
  432. qnorm(0.77)
  433. 0.74 * 17 + 108
  434. pnorm(252,369,59)
  435. pnorm(140,120,18) - pnorm(110,120,18)
  436. qnorm(0.87,100,10)
  437. 1- pnorm(96,100,20)
  438. pnorm(180,159,10) - pnorm(150,159,10)
  439. (pnorm(180,159,10) - pnorm(150,159,10))*425
  440. x = c(-40,0,260,460,960)
  441. px = c(0.99510,1/200,1/500,1/1000,1/2000)
  442. len(px)
  443. length(px)
  444. Ex = sum(x*px)
  445. Vx = sum(((x-Ex)^2)*px)
  446. Ex
  447. Vx
  448. library(tidycensus)
  449. library(tidyverse)
  450. tableYear = 2020
  451. #log on with API
  452. census_api_key("7a853acf81fd5758228680556ac831138c40b83e")
  453. #load variables
  454. pueblos = 78
  455. variables = load_variables(2020,"acs5/profile")
  456. codes = variables$name
  457. codess
  458. codes
  459. startsWith(codes,"DP02")
  460. callData = function(year,table,municipality) {
  461. #year is between 2000 and 2020
  462. #table is dp02pr, dp03, dp04, dp05
  463. #load variables
  464. variables = load_variables(year,"acs5/profile")
  465. #load variable vectors
  466. codes = variables$name
  467. codesBool = startsWith(codes,table)
  468. codes = codes[codesBool]
  469. labels = variables$label[codesBool]
  470. #pull table
  471. bigTable = get_acs(geography = "county",
  472. state = "PR",
  473. year = year,
  474. county = municipality,
  475. variables = codes)
  476. bigTable$Label = labels
  477. return(bigTable)
  478. }
  479. table = callData(2020,"DP05","Aguada")
  480. table
  481. view(table)
  482. view(table)
  483. callData = function(year,table,municipality) {
  484. #year is between 2000 and 2020
  485. #table is dp02pr, dp03, dp04, dp05
  486. #load variables
  487. variables = load_variables(year,"acs5/profile")
  488. #load variable vectors
  489. codes = variables$name
  490. codesBool = startsWith(codes,table)
  491. codes = codes[codesBool]
  492. labels = variables$label[codesBool]
  493. #pull table
  494. bigTable = get_acs(geography = "county",
  495. state = "PR",
  496. year = year,
  497. county = municipality,
  498. variables = codes)
  499. bigTable$Label = labels
  500. bigTable = bigTable[c("Label","estimate","moe")]
  501. return(bigTable)
  502. }
  503. table = callData(2020,"DP05","Aguada")
  504. view(table)
  505. plumber::plumb(file='C:/Users/kashi/Desktop/R.R')$run()
  506. plumb(file='C:/Users/kashi/Desktop/R.R')$run()
  507. setwd("C:/Users/kashi/Desktop")
  508. plumb(file='R.R')$run()
  509. setwd("C:/Users/kashi/Desktop/censusproject")
  510. plumb(file='R.R')$run()
  511. plumb(file='R.R')$run()
  512. plumb(file='R.R')$run()