Guys im using the filter verb on a column. It is filtering out only a few of all the values i have typed in. Why might this be happening? An asap response is highly appreciated.
I would really encourage you to review the following guide, FAQ: Tips for writing R-related questions.
For example, the guide emphasizes asking coding questions with formatted code-chunks and a reprex
.
You may have noticed folks here requesting minimal reprex
es, that's because asking questions this way saves answerers a lot of time.
Reproducible Examples:
- help make your question clear and replicable
- increases the probability folks will reach out and try to help,
- reduces the number of back-and-forths required to understand the question,
- and makes your question and suggested solutions more useful to folks in the future researching similar problems.
I tried creating a reprex, however, when i try attaching the data using datapasta it gives me the following error: "Could not format input_table as table. Unexpected class."
In short, Im trying to filter out the below mentioned observations from a single column. However, it only filters out "Education" and six observations for "Other", even though there are seven observations for "Other" in the column. Please help.
p_activity <- filter(cbecs_2, X %in% c("Education", "Food sales", "Food service", "Health care", "Inpatient", "Outpatient", "Lodging", "Mercantile", "Retail (other than mall)", "Enclosed and strip malls", "Office", "Public assembly", "Public order and safety", "Religious worship", "Service", "Warehouse and storage", "Other", "Vacant"))
To supply sample data simply do
dput(columnName)
where columnName is the name your data and paste the output here.
Nothing really happened. It just outputs whatever i put in the brackets.
p_activity <- filter(cbecs_2, X %in% c("Education, Food sales, Food service, Health care, Inpatient, Outpatient, Lodging, Mercantile, Retail (other than mall), Enclosed and strip malls, Office, Public assembly, Public order and safety, Religious worship, Service, Warehouse and storage, Other, Vacant"))
Tried the above code instead and it gives me the output seen in the screenshot which says 'no data available in table'. However, there is data in the table.
And here the output was as below:
It only filters out "Education" and six observations for "Other", even though there are seven observations for "Other" in the column.
We really need the data in dput() format. a screenshot does not tell us much.
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need.
how can what you are saying be simultaneously true.
That your code produces an empty table with no data.
but also returns a result with 7 entries in scenario which are Education, and Other x6 (rather than some desired 7). You talk about 'filtering out education' but you are happy to have education be 'in' the result; this is confusing language. presumably you mispoke about filtering out education, and you rather want to filter out things that are not education so that only education ( and certain other specified things are kept). I suppose I'm being pedantic, but its useful to have understandable terminology to communicate as we try to come up with precise code for you; its a matter of being clear in the requirements of what we are doing.
question to ponder - if you are concerned with the contents of the Scenario column, why does your filtering code not mention Scenario ? it mentions X ?
I would encourage you to try to engage with the reprex material ; using dput is not terribly difficult. The guide has a literal example for you to follow along with. If it requires an improvement in the writing let us know.
Finally, I hope this sorts it out.
structure(list(Scenario = c("All buildings", "1,001 to 5,000 ",
"5,001 to 10,000 ", "10,001 to 25,000", "25,001 to 50,000", "50,001 to 100,000 ",
"100,001 to 200,000 ", "200,001 to 500,000 ", "Over 500,000 ",
"Education", "Food sales ", "Food service ", "Health care ",
"Inpatient ", "Outpatient ", "Lodging ", "Mercantile ", "Retail (other than mall) ",
"Enclosed and strip malls ", "Office ", "Public assembly ", "Public order and safety ",
"Religious worship ", "Service ", "Warehouse and storage ", "Other ",
"Vacant ", "Before 1920", "1920 to 1945", "1946 to 1959", "1960 to 1969",
"1970 to 1979", "1980 to 1989", "1990 to 1999", "2000 to 2009",
"2010 to 2018", "Northeast", "New England ", "Middle Atlantic",
"Midwest", "East North Central", "West North Central", "South",
"South Atlantic ", "East South Central", "West South Central",
"West", "Mountain", "Pacific", "Cold or very cold", "Cool", "Mixed mild",
"Warm", "Hot or very hot", "1", "2", "3", "4 to 9", "10 or more",
"Any elevators", "1 elevator", "2 to 5 elevators", "6 or more elevators",
"Any escalators", "Fewer than 5", "5 to 9", "10 to 19", "20 to 49",
"50 to 99", "100 to 249", "250 or more", "Fewer than 40", "40 to 48",
"49 to 60", "61 to 84", "85 to 167", "Open continuously", "Nongovernment owned",
"Owner occupied", "Leased to tenant or tenants", "Unoccupied",
"Government owned", "Federal", "State", "Local", "Building owner",
"Business owner or tenant", "Property management", "Other", "Building owner",
"Business owner or tenant", "Property management", "Other", "1",
"2 to 5", "6 to 10", "11 to 20", "More than 20", "Currently unoccupied",
"Brick, stone, or stucco"), Number.of.buildings..thousand. = c(5613L,
2631L, 1288L, 949L, 385L, 217L, 93L, 40L, 9L, 437L, 163L, 286L,
137L, 9L, 129L, 207L, 513L, 346L, 167L, 970L, 488L, 81L, 439L,
866L, 792L, 108L, 124L, 323L, 368L, 496L, 673L, 787L, 752L, 844L,
860L, 508L, 769L, 274L, 496L, 1647L, 1074L, 573L, 2011L, 987L,
313L, 711L, 1186L, 431L, 755L, 511L, 1644L, 1169L, 1495L, 794L,
3822L, 1270L, 364L, 142L, 16L, 499L, 362L, 121L, 16L, 14L, 2968L,
1113L, 713L, 492L, 201L, 90L, 37L, 1233L, 1473L, 1231L, 618L,
421L, 637L, 4693L, 3104L, 1511L, 78L, 920L, 70L, 246L, 603L,
4636L, 783L, 83L, 110L, 4864L, 456L, 42L, 250L, 4504L, 805L,
134L, 63L, 19L, 87L, 2420L), Total.floorspace..million..square.feet. = c(94844L,
7471L, 9644L, 15464L, 13935L, 15269L, 12983L, 11761L, 8317L,
13623L, 1006L, 1385L, 4018L, 2259L, 1760L, 6976L, 10776L, 5188L,
5588L, 16662L, 7192L, 1538L, 5471L, 6208L, 16335L, 2407L, 1246L,
3568L, 5581L, 6823L, 10258L, 12902L, 13298L, 15066L, 17254L,
10094L, 15811L, 3737L, 12074L, 25488L, 17374L, 8114L, 34353L,
17732L, 5272L, 11349L, 19192L, 7411L, 11781L, 6934L, 26339L,
24731L, 24605L, 12235L, 42188L, 23152L, 10480L, 13027L, 5998L,
36474L, 14194L, 13312L, 8968L, 3753L, 19535L, 10285L, 11346L,
16132L, 12961L, 12433L, 12152L, 10200L, 18744L, 22739L, 14604L,
9803L, 18754L, 73201L, 44617L, 27937L, 647L, 21644L, 1946L, 6854L,
12843L, 78105L, 12558L, 1949L, 2233L, 81555L, 7373L, 1044L, 4872L,
64261L, 16365L, 5530L, 3894L, 3989L, 804L, 45718L), Total..trillion.British.thermal.units..Btu.. = c(11861L,
1081L, 1078L, 1634L, 1658L, 1820L, 1689L, 1732L, 1169L, 1268L,
530L, 601L, 947L, 644L, 303L, 991L, 1785L, 703L, 1082L, 2247L,
865L, 212L, 264L, 445L, 964L, 693L, 50L, 349L, 643L, 657L, 1185L,
1579L, 1793L, 1767L, 2509L, 1378L, 1876L, 430L, 1446L, 2956L,
2024L, 932L, 4730L, 2539L, 648L, 1543L, 2299L, 939L, 1360L, 859L,
2950L, 3164L, 3172L, 1715L, 5223L, 2449L, 1254L, 1943L, 992L,
5056L, 1532L, 1983L, 1541L, 550L, 1612L, 1198L, 1263L, 2167L,
1744L, 1781L, 2096L, 691L, 1686L, 2238L, 1983L, 1712L, 3551L,
9349L, 5585L, 3746L, 18L, 2512L, 267L, 912L, 1333L, 9660L, 1607L,
283L, 311L, 10062L, 1025L, 162L, 612L, 7708L, 2107L, 791L, 618L,
611L, 26L, 6013L), Total...Btu. = c(4090L, 373L, 372L, 564L,
572L, 627L, 582L, 597L, 403L, 437L, 183L, 207L, 327L, 222L, 105L,
342L, 616L, 242L, 373L, 775L, 298L, 73L, 91L, 153L, 332L, 239L,
17L, 120L, 222L, 227L, 409L, 545L, 618L, 609L, 865L, 475L, 647L,
148L, 499L, 1019L, 698L, 321L, 1631L, 876L, 223L, 532L, 793L,
324L, 469L, 296L, 1017L, 1091L, 1094L, 591L, 1801L, 845L, 432L,
670L, 342L, 1743L, 528L, 684L, 531L, 190L, 556L, 413L, 436L,
747L, 602L, 614L, 723L, 238L, 581L, 772L, 684L, 590L, 1225L,
3224L, 1926L, 1292L, 6L, 866L, 92L, 314L, 460L, 3331L, 554L,
98L, 107L, 3470L, 354L, 56L, 211L, 2658L, 727L, 273L, 213L, 211L,
9L, 2073L), Total..billion.kilowatthours. = c(1199L, 109L, 109L,
165L, 168L, 184L, 171L, 175L, 118L, 128L, 54L, 61L, 96L, 65L,
31L, 100L, 180L, 71L, 109L, 227L, 87L, 21L, 27L, 45L, 97L, 70L,
5L, 35L, 65L, 66L, 120L, 160L, 181L, 179L, 254L, 139L, 190L,
43L, 146L, 299L, 205L, 94L, 478L, 257L, 65L, 156L, 232L, 95L,
137L, 87L, 298L, 320L, 321L, 173L, 528L, 248L, 127L, 196L, 100L,
511L, 155L, 200L, 156L, 56L, 163L, 121L, 128L, 219L, 176L, 180L,
212L, 70L, 170L, 226L, 200L, 173L, 359L, 945L, 564L, 379L, 2L,
254L, 27L, 92L, 135L, 976L, 162L, 29L, 31L, 1017L, 104L, 16L,
62L, 779L, 213L, 80L, 62L, 62L, 3L, 608L), Total..million.dollars. = c(119248L,
12170L, 11658L, 17352L, 17325L, 17609L, 15942L, 16565L, 10628L,
12594L, 5306L, 5890L, 8911L, 5576L, 3334L, 9634L, 16549L, 6817L,
9732L, 23712L, 8524L, 2061L, 2996L, 5060L, 10426L, 7066L, 519L,
3604L, 6799L, 6596L, 12077L, 16053L, 18961L, 17804L, 24479L,
12875L, 21752L, 6792L, 14961L, 29153L, 20275L, 8878L, 40879L,
23288L, 6159L, 11432L, 27464L, 8175L, 19288L, 8576L, 30085L,
32172L, 33026L, 15389L, 52814L, 25479L, 12620L, 18783L, 9552L,
49606L, 15670L, 19486L, 14449L, 4986L, 17815L, 12301L, 12969L,
21626L, 17338L, 17253L, 19946L, 7564L, 17702L, 23075L, 20289L,
16926L, 33693L, 94988L, 55964L, 38813L, 210L, 24261L, 2461L,
8054L, 13745L, 96532L, 16798L, 2830L, 3089L, 100383L, 10734L,
1615L, 6516L, 78400L, 20584L, 7982L, 6224L, 5780L, 278L, 58662L
), usd_per_sqft = c(1.25730673527055, 1.62896533261946, 1.2088345085027,
1.12209001551992, 1.24327233584499, 1.15325168642347, 1.2279134252484,
1.4084686676303, 1.2778646146447, 0.924465976657124, 5.27435387673956,
4.25270758122744, 2.21777003484321, 2.46834882691456, 1.89431818181818,
1.38102064220183, 1.53572754268745, 1.31399383191982, 1.74158911954188,
1.42311847317249, 1.18520578420467, 1.34005201560468, 0.547614695668068,
0.815077319587629, 0.638261401897765, 2.93560448691317, 0.41653290529695,
1.01008968609865, 1.21824045869916, 0.966730177341345, 1.17732501462273,
1.24422570144164, 1.42585351180629, 1.1817337050312, 1.41874347977281,
1.27551020408163, 1.37575105938903, 1.81750066898582, 1.23910882888852,
1.14379315756434, 1.16697363877058, 1.09415824500863, 1.18996885279306,
1.31333182946086, 1.16824734446131, 1.00731341968455, 1.43101292205085,
1.10309000134935, 1.63721246074187, 1.23680415344678, 1.14222255970234,
1.30087744126804, 1.34224751066856, 1.25778504290969, 1.25187257039917,
1.10050967519005, 1.20419847328244, 1.44185153911108, 1.59253084361454,
1.36003728683446, 1.10398760039453, 1.46379206730769, 1.61117305976806,
1.32853717026379, 0.911952905042232, 1.19601361205639, 1.14304600740349,
1.34056533597818, 1.3377054239642, 1.38767795383254, 1.64137590520079,
0.74156862745098, 0.944408877507469, 1.0147763753903, 1.3892769104355,
1.72661430174436, 1.79657673029754, 1.29763254600347, 1.2543201022032,
1.38930450656835, 0.324574961360124, 1.12091110700425, 1.26464542651593,
1.17508024511234, 1.07023281164837, 1.23592599705525, 1.33763338111164,
1.4520266803489, 1.3833407971339, 1.23086260805591, 1.45585243455852,
1.54693486590038, 1.33743842364532, 1.2200245872302, 1.25780629391995,
1.44339963833635, 1.59835644581407, 1.44898470794685, 0.345771144278607,
1.28312699593158), mean_area = c(16900, 2800, 7500, 16300, 36200,
70300, 140200, 293800, 947600, 31100, 6200, 4800, 29300, 264800,
13700, 33700, 21000, 15000, 33500, 17200, 14700, 18900, 12500,
7200, 20600, 22200, 10000, 11000, 15200, 13700, 15200, 16400,
17700, 17800, 20100, 19900, 20600, 13700, 24400, 15500, 16200,
14200, 17100, 18000, 16800, 16000, 16200, 17200, 15600, 13600,
16000, 21200, 16500, 15400, 11000, 18200, 28800, 92000, 379900,
73000, 39200, 110000, 545800, 277800, 6600, 9200, 15900, 32800,
64500, 137900, 329900, 8300, 12700, 18500, 23600, 23300, 29400,
15600, 14400, 18500, 8300, 23500, 27700, 27800, 21300, 16800,
16000, 23400, 20200, 16800, 16200, 24800, 19500, 14300, 20300,
41300, 61600, 206900, 9200, 18900), usd_per_avg_area = c(21248.4838260723,
4561.10293133449, 9066.25881377022, 18290.0672529746, 45006.4585575888,
81073.5935555701, 172153.462219826, 413808.094549783, 1210904.50883732,
28750.8918740366, 32700.9940357853, 20412.9963898917, 64980.6620209059,
653618.769366977, 25952.1590909091, 46540.3956422018, 32250.2783964365,
19709.9074787972, 58343.2355046528, 24477.6377385668, 17422.5250278087,
25326.9830949285, 6845.18369585085, 5868.55670103093, 13148.184879094,
65170.4196094724, 4165.3290529695, 11110.9865470852, 18517.2549722272,
13244.2034295764, 17895.3402222655, 20405.3015036428, 25237.6071589713,
21034.8599495553, 28516.7439434334, 25382.6530612245, 28340.4718234141,
24899.7591651057, 30234.2554248799, 17728.7939422473, 18904.9729480833,
15537.0470791225, 20348.4673827613, 23639.9729302955, 19626.5553869499,
16117.0147149529, 23182.4093372238, 18973.1480232087, 25540.5143875732,
16820.5364868763, 18275.5609552375, 27578.6017548825, 22147.0839260313,
19369.8896608092, 13770.5982743908, 20029.2760884589, 34680.9160305343,
132650.341598219, 605002.467489163, 99282.7219389154, 43276.3139354657,
161017.127403846, 879378.256021409, 369067.625899281, 6018.88917327873,
11003.3252309188, 18174.4315177155, 43970.5430200843, 86281.9998456909,
191360.789833508, 541489.911125741, 6155.01960784314, 11993.9927443449,
18773.3629447205, 32786.9350862777, 40230.1132306437, 52819.3558707476,
20243.0677176541, 18062.209471726, 25702.1333715145, 2693.97217928903,
26341.4110145999, 35030.6783144913, 32667.2308141231, 22795.9588881103,
20763.5567505281, 21402.1340977863, 33977.4243201642, 27943.4841021048,
20678.4918153393, 23584.8094398481, 38363.9846743295, 26080.0492610837,
17446.3515973919, 25533.467766575, 59612.4050632911, 98458.7570621469,
299794.936074204, 3181.09452736318, 24251.1002231069)), na.action = structure(c(`2` = 2L,
`11` = 11L, `30` = 30L, `40` = 40L, `54` = 54L, `60` = 60L, `66` = 66L,
`72` = 72L, `80` = 80L, `87` = 87L, `96` = 96L, `101` = 101L,
`106` = 106L, `113` = 113L, `121` = 121L, `130` = 130L, `134` = 134L,
`140` = 140L, `157` = 157L, `166` = 166L, `172` = 172L, `179` = 179L,
`183` = 183L, `187` = 187L, `191` = 191L, `199` = 199L, `204` = 204L,
`209` = 209L, `210` = 210L, `215` = 215L, `220` = 220L, `221` = 221L,
`230` = 230L, `238` = 238L, `239` = 239L, `248` = 248L, `251` = 251L,
`255` = 255L, `259` = 259L, `266` = 266L, `267` = 267L, `276` = 276L,
`287` = 287L, `293` = 293L, `298` = 298L, `311` = 311L, `313` = 313L,
`321` = 321L, `322` = 322L), class = "omit"), row.names = c(1L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 45L,
46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 55L, 56L, 57L, 58L, 59L,
61L, 62L, 63L, 64L, 65L, 67L, 68L, 69L, 70L, 71L, 73L, 74L, 75L,
76L, 77L, 78L, 79L, 81L, 82L, 83L, 84L, 85L, 86L, 88L, 89L, 90L,
91L, 92L, 93L, 94L, 95L, 97L, 98L, 99L, 100L, 102L, 103L, 104L,
105L, 107L, 108L, 109L, 110L, 111L, 112L, 114L), class = "data.frame")
Finally, I hope this sorts it out.
structure(list(Scenario = c("All buildings", "1,001 to 5,000 ",
"5,001 to 10,000 ", "10,001 to 25,000", "25,001 to 50,000", "50,001 to 100,000 ",
"100,001 to 200,000 ", "200,001 to 500,000 ", "Over 500,000 ",
"Education", "Food sales ", "Food service ", "Health care ",
"Inpatient ", "Outpatient ", "Lodging ", "Mercantile ", "Retail (other than mall) ",
"Enclosed and strip malls ", "Office ", "Public assembly ", "Public order and safety ",
"Religious worship ", "Service ", "Warehouse and storage ", "Other ",
"Vacant ", "Before 1920", "1920 to 1945", "1946 to 1959", "1960 to 1969",
"1970 to 1979", "1980 to 1989", "1990 to 1999", "2000 to 2009",
"2010 to 2018", "Northeast", "New England ", "Middle Atlantic",
"Midwest", "East North Central", "West North Central", "South",
"South Atlantic ", "East South Central", "West South Central",
"West", "Mountain", "Pacific", "Cold or very cold", "Cool", "Mixed mild",
"Warm", "Hot or very hot", "1", "2", "3", "4 to 9", "10 or more",
"Any elevators", "1 elevator", "2 to 5 elevators", "6 or more elevators",
"Any escalators", "Fewer than 5", "5 to 9", "10 to 19", "20 to 49",
"50 to 99", "100 to 249", "250 or more", "Fewer than 40", "40 to 48",
"49 to 60", "61 to 84", "85 to 167", "Open continuously", "Nongovernment owned",
"Owner occupied", "Leased to tenant or tenants", "Unoccupied",
"Government owned", "Federal", "State", "Local", "Building owner",
"Business owner or tenant", "Property management", "Other", "Building owner",
"Business owner or tenant", "Property management", "Other", "1",
"2 to 5", "6 to 10", "11 to 20", "More than 20", "Currently unoccupied",
"Brick, stone, or stucco"), Number.of.buildings..thousand. = c(5613L,
2631L, 1288L, 949L, 385L, 217L, 93L, 40L, 9L, 437L, 163L, 286L,
137L, 9L, 129L, 207L, 513L, 346L, 167L, 970L, 488L, 81L, 439L,
866L, 792L, 108L, 124L, 323L, 368L, 496L, 673L, 787L, 752L, 844L,
860L, 508L, 769L, 274L, 496L, 1647L, 1074L, 573L, 2011L, 987L,
313L, 711L, 1186L, 431L, 755L, 511L, 1644L, 1169L, 1495L, 794L,
3822L, 1270L, 364L, 142L, 16L, 499L, 362L, 121L, 16L, 14L, 2968L,
1113L, 713L, 492L, 201L, 90L, 37L, 1233L, 1473L, 1231L, 618L,
421L, 637L, 4693L, 3104L, 1511L, 78L, 920L, 70L, 246L, 603L,
4636L, 783L, 83L, 110L, 4864L, 456L, 42L, 250L, 4504L, 805L,
134L, 63L, 19L, 87L, 2420L), Total.floorspace..million..square.feet. = c(94844L,
7471L, 9644L, 15464L, 13935L, 15269L, 12983L, 11761L, 8317L,
13623L, 1006L, 1385L, 4018L, 2259L, 1760L, 6976L, 10776L, 5188L,
5588L, 16662L, 7192L, 1538L, 5471L, 6208L, 16335L, 2407L, 1246L,
3568L, 5581L, 6823L, 10258L, 12902L, 13298L, 15066L, 17254L,
10094L, 15811L, 3737L, 12074L, 25488L, 17374L, 8114L, 34353L,
17732L, 5272L, 11349L, 19192L, 7411L, 11781L, 6934L, 26339L,
24731L, 24605L, 12235L, 42188L, 23152L, 10480L, 13027L, 5998L,
36474L, 14194L, 13312L, 8968L, 3753L, 19535L, 10285L, 11346L,
16132L, 12961L, 12433L, 12152L, 10200L, 18744L, 22739L, 14604L,
9803L, 18754L, 73201L, 44617L, 27937L, 647L, 21644L, 1946L, 6854L,
12843L, 78105L, 12558L, 1949L, 2233L, 81555L, 7373L, 1044L, 4872L,
64261L, 16365L, 5530L, 3894L, 3989L, 804L, 45718L), Total..trillion.British.thermal.units..Btu.. = c(11861L,
1081L, 1078L, 1634L, 1658L, 1820L, 1689L, 1732L, 1169L, 1268L,
530L, 601L, 947L, 644L, 303L, 991L, 1785L, 703L, 1082L, 2247L,
865L, 212L, 264L, 445L, 964L, 693L, 50L, 349L, 643L, 657L, 1185L,
1579L, 1793L, 1767L, 2509L, 1378L, 1876L, 430L, 1446L, 2956L,
2024L, 932L, 4730L, 2539L, 648L, 1543L, 2299L, 939L, 1360L, 859L,
2950L, 3164L, 3172L, 1715L, 5223L, 2449L, 1254L, 1943L, 992L,
5056L, 1532L, 1983L, 1541L, 550L, 1612L, 1198L, 1263L, 2167L,
1744L, 1781L, 2096L, 691L, 1686L, 2238L, 1983L, 1712L, 3551L,
9349L, 5585L, 3746L, 18L, 2512L, 267L, 912L, 1333L, 9660L, 1607L,
283L, 311L, 10062L, 1025L, 162L, 612L, 7708L, 2107L, 791L, 618L,
611L, 26L, 6013L), Total...Btu. = c(4090L, 373L, 372L, 564L,
572L, 627L, 582L, 597L, 403L, 437L, 183L, 207L, 327L, 222L, 105L,
342L, 616L, 242L, 373L, 775L, 298L, 73L, 91L, 153L, 332L, 239L,
17L, 120L, 222L, 227L, 409L, 545L, 618L, 609L, 865L, 475L, 647L,
148L, 499L, 1019L, 698L, 321L, 1631L, 876L, 223L, 532L, 793L,
324L, 469L, 296L, 1017L, 1091L, 1094L, 591L, 1801L, 845L, 432L,
670L, 342L, 1743L, 528L, 684L, 531L, 190L, 556L, 413L, 436L,
747L, 602L, 614L, 723L, 238L, 581L, 772L, 684L, 590L, 1225L,
3224L, 1926L, 1292L, 6L, 866L, 92L, 314L, 460L, 3331L, 554L,
98L, 107L, 3470L, 354L, 56L, 211L, 2658L, 727L, 273L, 213L, 211L,
9L, 2073L), Total..billion.kilowatthours. = c(1199L, 109L, 109L,
165L, 168L, 184L, 171L, 175L, 118L, 128L, 54L, 61L, 96L, 65L,
31L, 100L, 180L, 71L, 109L, 227L, 87L, 21L, 27L, 45L, 97L, 70L,
5L, 35L, 65L, 66L, 120L, 160L, 181L, 179L, 254L, 139L, 190L,
43L, 146L, 299L, 205L, 94L, 478L, 257L, 65L, 156L, 232L, 95L,
137L, 87L, 298L, 320L, 321L, 173L, 528L, 248L, 127L, 196L, 100L,
511L, 155L, 200L, 156L, 56L, 163L, 121L, 128L, 219L, 176L, 180L,
212L, 70L, 170L, 226L, 200L, 173L, 359L, 945L, 564L, 379L, 2L,
254L, 27L, 92L, 135L, 976L, 162L, 29L, 31L, 1017L, 104L, 16L,
62L, 779L, 213L, 80L, 62L, 62L, 3L, 608L), Total..million.dollars. = c(119248L,
12170L, 11658L, 17352L, 17325L, 17609L, 15942L, 16565L, 10628L,
12594L, 5306L, 5890L, 8911L, 5576L, 3334L, 9634L, 16549L, 6817L,
9732L, 23712L, 8524L, 2061L, 2996L, 5060L, 10426L, 7066L, 519L,
3604L, 6799L, 6596L, 12077L, 16053L, 18961L, 17804L, 24479L,
12875L, 21752L, 6792L, 14961L, 29153L, 20275L, 8878L, 40879L,
23288L, 6159L, 11432L, 27464L, 8175L, 19288L, 8576L, 30085L,
32172L, 33026L, 15389L, 52814L, 25479L, 12620L, 18783L, 9552L,
49606L, 15670L, 19486L, 14449L, 4986L, 17815L, 12301L, 12969L,
21626L, 17338L, 17253L, 19946L, 7564L, 17702L, 23075L, 20289L,
16926L, 33693L, 94988L, 55964L, 38813L, 210L, 24261L, 2461L,
8054L, 13745L, 96532L, 16798L, 2830L, 3089L, 100383L, 10734L,
1615L, 6516L, 78400L, 20584L, 7982L, 6224L, 5780L, 278L, 58662L
), usd_per_sqft = c(1.25730673527055, 1.62896533261946, 1.2088345085027,
1.12209001551992, 1.24327233584499, 1.15325168642347, 1.2279134252484,
1.4084686676303, 1.2778646146447, 0.924465976657124, 5.27435387673956,
4.25270758122744, 2.21777003484321, 2.46834882691456, 1.89431818181818,
1.38102064220183, 1.53572754268745, 1.31399383191982, 1.74158911954188,
1.42311847317249, 1.18520578420467, 1.34005201560468, 0.547614695668068,
0.815077319587629, 0.638261401897765, 2.93560448691317, 0.41653290529695,
1.01008968609865, 1.21824045869916, 0.966730177341345, 1.17732501462273,
1.24422570144164, 1.42585351180629, 1.1817337050312, 1.41874347977281,
1.27551020408163, 1.37575105938903, 1.81750066898582, 1.23910882888852,
1.14379315756434, 1.16697363877058, 1.09415824500863, 1.18996885279306,
1.31333182946086, 1.16824734446131, 1.00731341968455, 1.43101292205085,
1.10309000134935, 1.63721246074187, 1.23680415344678, 1.14222255970234,
1.30087744126804, 1.34224751066856, 1.25778504290969, 1.25187257039917,
1.10050967519005, 1.20419847328244, 1.44185153911108, 1.59253084361454,
1.36003728683446, 1.10398760039453, 1.46379206730769, 1.61117305976806,
1.32853717026379, 0.911952905042232, 1.19601361205639, 1.14304600740349,
1.34056533597818, 1.3377054239642, 1.38767795383254, 1.64137590520079,
0.74156862745098, 0.944408877507469, 1.0147763753903, 1.3892769104355,
1.72661430174436, 1.79657673029754, 1.29763254600347, 1.2543201022032,
1.38930450656835, 0.324574961360124, 1.12091110700425, 1.26464542651593,
1.17508024511234, 1.07023281164837, 1.23592599705525, 1.33763338111164,
1.4520266803489, 1.3833407971339, 1.23086260805591, 1.45585243455852,
1.54693486590038, 1.33743842364532, 1.2200245872302, 1.25780629391995,
1.44339963833635, 1.59835644581407, 1.44898470794685, 0.345771144278607,
1.28312699593158), mean_area = c(16900, 2800, 7500, 16300, 36200,
70300, 140200, 293800, 947600, 31100, 6200, 4800, 29300, 264800,
13700, 33700, 21000, 15000, 33500, 17200, 14700, 18900, 12500,
7200, 20600, 22200, 10000, 11000, 15200, 13700, 15200, 16400,
17700, 17800, 20100, 19900, 20600, 13700, 24400, 15500, 16200,
14200, 17100, 18000, 16800, 16000, 16200, 17200, 15600, 13600,
16000, 21200, 16500, 15400, 11000, 18200, 28800, 92000, 379900,
73000, 39200, 110000, 545800, 277800, 6600, 9200, 15900, 32800,
64500, 137900, 329900, 8300, 12700, 18500, 23600, 23300, 29400,
15600, 14400, 18500, 8300, 23500, 27700, 27800, 21300, 16800,
16000, 23400, 20200, 16800, 16200, 24800, 19500, 14300, 20300,
41300, 61600, 206900, 9200, 18900), usd_per_avg_area = c(21248.4838260723,
4561.10293133449, 9066.25881377022, 18290.0672529746, 45006.4585575888,
81073.5935555701, 172153.462219826, 413808.094549783, 1210904.50883732,
28750.8918740366, 32700.9940357853, 20412.9963898917, 64980.6620209059,
653618.769366977, 25952.1590909091, 46540.3956422018, 32250.2783964365,
19709.9074787972, 58343.2355046528, 24477.6377385668, 17422.5250278087,
25326.9830949285, 6845.18369585085, 5868.55670103093, 13148.184879094,
65170.4196094724, 4165.3290529695, 11110.9865470852, 18517.2549722272,
13244.2034295764, 17895.3402222655, 20405.3015036428, 25237.6071589713,
21034.8599495553, 28516.7439434334, 25382.6530612245, 28340.4718234141,
24899.7591651057, 30234.2554248799, 17728.7939422473, 18904.9729480833,
15537.0470791225, 20348.4673827613, 23639.9729302955, 19626.5553869499,
16117.0147149529, 23182.4093372238, 18973.1480232087, 25540.5143875732,
16820.5364868763, 18275.5609552375, 27578.6017548825, 22147.0839260313,
19369.8896608092, 13770.5982743908, 20029.2760884589, 34680.9160305343,
132650.341598219, 605002.467489163, 99282.7219389154, 43276.3139354657,
161017.127403846, 879378.256021409, 369067.625899281, 6018.88917327873,
11003.3252309188, 18174.4315177155, 43970.5430200843, 86281.9998456909,
191360.789833508, 541489.911125741, 6155.01960784314, 11993.9927443449,
18773.3629447205, 32786.9350862777, 40230.1132306437, 52819.3558707476,
20243.0677176541, 18062.209471726, 25702.1333715145, 2693.97217928903,
26341.4110145999, 35030.6783144913, 32667.2308141231, 22795.9588881103,
20763.5567505281, 21402.1340977863, 33977.4243201642, 27943.4841021048,
20678.4918153393, 23584.8094398481, 38363.9846743295, 26080.0492610837,
17446.3515973919, 25533.467766575, 59612.4050632911, 98458.7570621469,
299794.936074204, 3181.09452736318, 24251.1002231069)), na.action = structure(c(2
= 2L,
11
= 11L, 30
= 30L, 40
= 40L, 54
= 54L, 60
= 60L, 66
= 66L,
72
= 72L, 80
= 80L, 87
= 87L, 96
= 96L, 101
= 101L,
106
= 106L, 113
= 113L, 121
= 121L, 130
= 130L, 134
= 134L,
140
= 140L, 157
= 157L, 166
= 166L, 172
= 172L, 179
= 179L,
183
= 183L, 187
= 187L, 191
= 191L, 199
= 199L, 204
= 204L,
209
= 209L, 210
= 210L, 215
= 215L, 220
= 220L, 221
= 221L,
230
= 230L, 238
= 238L, 239
= 239L, 248
= 248L, 251
= 251L,
255
= 255L, 259
= 259L, 266
= 266L, 267
= 267L, 276
= 276L,
287
= 287L, 293
= 293L, 298
= 298L, 311
= 311L, 313
= 313L,
321
= 321L, 322
= 322L), class = "omit"), row.names = c(1L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 45L,
46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 55L, 56L, 57L, 58L, 59L,
61L, 62L, 63L, 64L, 65L, 67L, 68L, 69L, 70L, 71L, 73L, 74L, 75L,
76L, 77L, 78L, 79L, 81L, 82L, 83L, 84L, 85L, 86L, 88L, 89L, 90L,
91L, 92L, 93L, 94L, 95L, 97L, 98L, 99L, 100L, 102L, 103L, 104L,
105L, 107L, 108L, 109L, 110L, 111L, 112L, 114L), class = "data.frame")
This is very helpful. It appears that you don't have a column named X
.
While trying various things for a solution, I had manually changed 'X' to 'Scenario' in the csv file.
its unclear if you still require assistance or not ?
It would be helpful if you could post your exact code, as @nirgrahamuk suggests. This could be something as simple as a typo in the code.
---
title: "Untitled"
subtitle:
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll #fill
source_code: embed
author:
date:
runtime: shiny
---
# Install packages
```{r packages, echo=FALSE}
install.packages("tidyverse")
install.packages('dplyr')
```
# *****
# Load libraries
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(broom)
library(dplyr)
```
# *****
# Read in data
```{r data, echo=FALSE}
cbecs <- read.csv("data/c13.csv")
cbecs
```
# *****
# Add two columns cost/sq.ft, cost/mean floor space and create the linear model
```{r mutate lm, echo=FALSE}
cbecs_mod <- na.omit(cbecs)
cbecs_1 <- mutate(cbecs_mod, usd_per_sqft = Total..million.dollars. / Total.floorspace..million..square.feet., mean_area = Mean.floorspace..per.building...thousand.square.feet. * 1000) %>% select(-Mean.floorspace..per.building...thousand.square.feet.)
cbecs_2 <- mutate(cbecs_1, usd_per_avg_area = usd_per_sqft * mean_area)
# Fit a linear model of cost on avg area
cost_fit <- lm(usd_per_avg_area~mean_area, data=cbecs_2)
tidy(cost_fit)
# Add predictions, residuals, etc. to the training data
cost_model <- augment(cost_fit, cbecs_2)
# Fitting the estimated model over the data
ggplot(cost_model, aes(x=mean_area, y=usd_per_avg_area)) +
geom_line() +
geom_line(aes(y=.fitted), colour="blue")
```
# *****
# filter out average area between 0 and 200000 sqft
```{r filter, echo=FALSE}
cbecs_a <- filter(cbecs_2, mean_area >= 0, mean_area <= 100000)
# Fit a linear model of cost on avg area
cost_fit <- lm(usd_per_avg_area~mean_area, data=cbecs_a)
tidy(cost_fit)
# Add predictions, residuals, etc. to the training data
cost_model <- augment(cost_fit, cbecs_a)
# Fitting the estimated model over the data
ggplot(cost_model, aes(x=mean_area, y=usd_per_avg_area)) +
geom_line() +
geom_line(aes(y=.fitted), colour="blue")
```
# *****
# summary cost_model
```{r summary, echo=FALSE}
# Fit a linear regression model of hwy on displ using mpg data
expense_lin_fit <- lm(formula = usd_per_avg_area ~ mean_area, data = cbecs_a)
# Return a summary of the fitted linear regression model
summary(expense_lin_fit)
```
# Analysis Component 1
Principal Activity
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
# (Expense vs Principal activity), (Consumption vs Principal activity) both to show on one graph
```{r, echo=FALSE}
# filter out the Principal activity details
p_activity <- cbecs_2 %>% filter(Scenario %in% c("Education", "Food sales", "Food service", "Health care", "Inpatient", "Outpatient", "Lodging", "Mercantile", "Retail (other than mall)", "Enclosed and strip malls", "Office", "Public assembly", "Public order and safety", "Religious worship", "Service", "Warehouse and storage", "Vacant"))
p_activity
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r}
```
### Chart C
```{r}
```
```
This is very helpful.
The dput()
output you had previously posted has disappeared, at least for me. No idea how that could happen. Could you repost? Maybe also a dput()
of cbecs_2
.
structure(list(Scenario = c("All buildings", "1,001 to 5,000 ",
"5,001 to 10,000 ", "10,001 to 25,000", "25,001 to 50,000", "50,001 to 100,000 ",
"100,001 to 200,000 ", "200,001 to 500,000 ", "Over 500,000 ",
"Education", "Food sales ", "Food service ", "Health care ",
"Inpatient ", "Outpatient ", "Lodging ", "Mercantile ", "Retail (other than mall) ",
"Enclosed and strip malls ", "Office ", "Public assembly ", "Public order and safety ",
"Religious worship ", "Service ", "Warehouse and storage ", "Other ",
"Vacant ", "Before 1920", "1920 to 1945", "1946 to 1959", "1960 to 1969",
"1970 to 1979", "1980 to 1989", "1990 to 1999", "2000 to 2009",
"2010 to 2018", "Northeast", "New England ", "Middle Atlantic",
"Midwest", "East North Central", "West North Central", "South",
"South Atlantic ", "East South Central", "West South Central",
"West", "Mountain", "Pacific", "Cold or very cold", "Cool", "Mixed mild",
"Warm", "Hot or very hot", "1", "2", "3", "4 to 9", "10 or more",
"Any elevators", "1 elevator", "2 to 5 elevators", "6 or more elevators",
"Any escalators", "Fewer than 5", "5 to 9", "10 to 19", "20 to 49",
"50 to 99", "100 to 249", "250 or more", "Fewer than 40", "40 to 48",
"49 to 60", "61 to 84", "85 to 167", "Open continuously", "Nongovernment owned",
"Owner occupied", "Leased to tenant or tenants", "Unoccupied",
"Government owned", "Federal", "State", "Local", "Building owner",
"Business owner or tenant", "Property management", "Other", "Building owner",
"Business owner or tenant", "Property management", "Other", "1",
"2 to 5", "6 to 10", "11 to 20", "More than 20", "Currently unoccupied",
"Brick, stone, or stucco"), Number.of.buildings..thousand. = c(5613L,
2631L, 1288L, 949L, 385L, 217L, 93L, 40L, 9L, 437L, 163L, 286L,
137L, 9L, 129L, 207L, 513L, 346L, 167L, 970L, 488L, 81L, 439L,
866L, 792L, 108L, 124L, 323L, 368L, 496L, 673L, 787L, 752L, 844L,
860L, 508L, 769L, 274L, 496L, 1647L, 1074L, 573L, 2011L, 987L,
313L, 711L, 1186L, 431L, 755L, 511L, 1644L, 1169L, 1495L, 794L,
3822L, 1270L, 364L, 142L, 16L, 499L, 362L, 121L, 16L, 14L, 2968L,
1113L, 713L, 492L, 201L, 90L, 37L, 1233L, 1473L, 1231L, 618L,
421L, 637L, 4693L, 3104L, 1511L, 78L, 920L, 70L, 246L, 603L,
4636L, 783L, 83L, 110L, 4864L, 456L, 42L, 250L, 4504L, 805L,
134L, 63L, 19L, 87L, 2420L), Total.floorspace..million..square.feet. = c(94844L,
7471L, 9644L, 15464L, 13935L, 15269L, 12983L, 11761L, 8317L,
13623L, 1006L, 1385L, 4018L, 2259L, 1760L, 6976L, 10776L, 5188L,
5588L, 16662L, 7192L, 1538L, 5471L, 6208L, 16335L, 2407L, 1246L,
3568L, 5581L, 6823L, 10258L, 12902L, 13298L, 15066L, 17254L,
10094L, 15811L, 3737L, 12074L, 25488L, 17374L, 8114L, 34353L,
17732L, 5272L, 11349L, 19192L, 7411L, 11781L, 6934L, 26339L,
24731L, 24605L, 12235L, 42188L, 23152L, 10480L, 13027L, 5998L,
36474L, 14194L, 13312L, 8968L, 3753L, 19535L, 10285L, 11346L,
16132L, 12961L, 12433L, 12152L, 10200L, 18744L, 22739L, 14604L,
9803L, 18754L, 73201L, 44617L, 27937L, 647L, 21644L, 1946L, 6854L,
12843L, 78105L, 12558L, 1949L, 2233L, 81555L, 7373L, 1044L, 4872L,
64261L, 16365L, 5530L, 3894L, 3989L, 804L, 45718L), Total..trillion.British.thermal.units..Btu.. = c(11861L,
1081L, 1078L, 1634L, 1658L, 1820L, 1689L, 1732L, 1169L, 1268L,
530L, 601L, 947L, 644L, 303L, 991L, 1785L, 703L, 1082L, 2247L,
865L, 212L, 264L, 445L, 964L, 693L, 50L, 349L, 643L, 657L, 1185L,
1579L, 1793L, 1767L, 2509L, 1378L, 1876L, 430L, 1446L, 2956L,
2024L, 932L, 4730L, 2539L, 648L, 1543L, 2299L, 939L, 1360L, 859L,
2950L, 3164L, 3172L, 1715L, 5223L, 2449L, 1254L, 1943L, 992L,
5056L, 1532L, 1983L, 1541L, 550L, 1612L, 1198L, 1263L, 2167L,
1744L, 1781L, 2096L, 691L, 1686L, 2238L, 1983L, 1712L, 3551L,
9349L, 5585L, 3746L, 18L, 2512L, 267L, 912L, 1333L, 9660L, 1607L,
283L, 311L, 10062L, 1025L, 162L, 612L, 7708L, 2107L, 791L, 618L,
611L, 26L, 6013L), Total...Btu. = c(4090L, 373L, 372L, 564L,
572L, 627L, 582L, 597L, 403L, 437L, 183L, 207L, 327L, 222L, 105L,
342L, 616L, 242L, 373L, 775L, 298L, 73L, 91L, 153L, 332L, 239L,
17L, 120L, 222L, 227L, 409L, 545L, 618L, 609L, 865L, 475L, 647L,
148L, 499L, 1019L, 698L, 321L, 1631L, 876L, 223L, 532L, 793L,
324L, 469L, 296L, 1017L, 1091L, 1094L, 591L, 1801L, 845L, 432L,
670L, 342L, 1743L, 528L, 684L, 531L, 190L, 556L, 413L, 436L,
747L, 602L, 614L, 723L, 238L, 581L, 772L, 684L, 590L, 1225L,
3224L, 1926L, 1292L, 6L, 866L, 92L, 314L, 460L, 3331L, 554L,
98L, 107L, 3470L, 354L, 56L, 211L, 2658L, 727L, 273L, 213L, 211L,
9L, 2073L), Total..billion.kilowatthours. = c(1199L, 109L, 109L,
165L, 168L, 184L, 171L, 175L, 118L, 128L, 54L, 61L, 96L, 65L,
31L, 100L, 180L, 71L, 109L, 227L, 87L, 21L, 27L, 45L, 97L, 70L,
5L, 35L, 65L, 66L, 120L, 160L, 181L, 179L, 254L, 139L, 190L,
43L, 146L, 299L, 205L, 94L, 478L, 257L, 65L, 156L, 232L, 95L,
137L, 87L, 298L, 320L, 321L, 173L, 528L, 248L, 127L, 196L, 100L,
511L, 155L, 200L, 156L, 56L, 163L, 121L, 128L, 219L, 176L, 180L,
212L, 70L, 170L, 226L, 200L, 173L, 359L, 945L, 564L, 379L, 2L,
254L, 27L, 92L, 135L, 976L, 162L, 29L, 31L, 1017L, 104L, 16L,
62L, 779L, 213L, 80L, 62L, 62L, 3L, 608L), Total..million.dollars. = c(119248L,
12170L, 11658L, 17352L, 17325L, 17609L, 15942L, 16565L, 10628L,
12594L, 5306L, 5890L, 8911L, 5576L, 3334L, 9634L, 16549L, 6817L,
9732L, 23712L, 8524L, 2061L, 2996L, 5060L, 10426L, 7066L, 519L,
3604L, 6799L, 6596L, 12077L, 16053L, 18961L, 17804L, 24479L,
12875L, 21752L, 6792L, 14961L, 29153L, 20275L, 8878L, 40879L,
23288L, 6159L, 11432L, 27464L, 8175L, 19288L, 8576L, 30085L,
32172L, 33026L, 15389L, 52814L, 25479L, 12620L, 18783L, 9552L,
49606L, 15670L, 19486L, 14449L, 4986L, 17815L, 12301L, 12969L,
21626L, 17338L, 17253L, 19946L, 7564L, 17702L, 23075L, 20289L,
16926L, 33693L, 94988L, 55964L, 38813L, 210L, 24261L, 2461L,
8054L, 13745L, 96532L, 16798L, 2830L, 3089L, 100383L, 10734L,
1615L, 6516L, 78400L, 20584L, 7982L, 6224L, 5780L, 278L, 58662L
), usd_per_sqft = c(1.25730673527055, 1.62896533261946, 1.2088345085027,
1.12209001551992, 1.24327233584499, 1.15325168642347, 1.2279134252484,
1.4084686676303, 1.2778646146447, 0.924465976657124, 5.27435387673956,
4.25270758122744, 2.21777003484321, 2.46834882691456, 1.89431818181818,
1.38102064220183, 1.53572754268745, 1.31399383191982, 1.74158911954188,
1.42311847317249, 1.18520578420467, 1.34005201560468, 0.547614695668068,
0.815077319587629, 0.638261401897765, 2.93560448691317, 0.41653290529695,
1.01008968609865, 1.21824045869916, 0.966730177341345, 1.17732501462273,
1.24422570144164, 1.42585351180629, 1.1817337050312, 1.41874347977281,
1.27551020408163, 1.37575105938903, 1.81750066898582, 1.23910882888852,
1.14379315756434, 1.16697363877058, 1.09415824500863, 1.18996885279306,
1.31333182946086, 1.16824734446131, 1.00731341968455, 1.43101292205085,
1.10309000134935, 1.63721246074187, 1.23680415344678, 1.14222255970234,
1.30087744126804, 1.34224751066856, 1.25778504290969, 1.25187257039917,
1.10050967519005, 1.20419847328244, 1.44185153911108, 1.59253084361454,
1.36003728683446, 1.10398760039453, 1.46379206730769, 1.61117305976806,
1.32853717026379, 0.911952905042232, 1.19601361205639, 1.14304600740349,
1.34056533597818, 1.3377054239642, 1.38767795383254, 1.64137590520079,
0.74156862745098, 0.944408877507469, 1.0147763753903, 1.3892769104355,
1.72661430174436, 1.79657673029754, 1.29763254600347, 1.2543201022032,
1.38930450656835, 0.324574961360124, 1.12091110700425, 1.26464542651593,
1.17508024511234, 1.07023281164837, 1.23592599705525, 1.33763338111164,
1.4520266803489, 1.3833407971339, 1.23086260805591, 1.45585243455852,
1.54693486590038, 1.33743842364532, 1.2200245872302, 1.25780629391995,
1.44339963833635, 1.59835644581407, 1.44898470794685, 0.345771144278607,
1.28312699593158), mean_area = c(16900, 2800, 7500, 16300, 36200,
70300, 140200, 293800, 947600, 31100, 6200, 4800, 29300, 264800,
13700, 33700, 21000, 15000, 33500, 17200, 14700, 18900, 12500,
7200, 20600, 22200, 10000, 11000, 15200, 13700, 15200, 16400,
17700, 17800, 20100, 19900, 20600, 13700, 24400, 15500, 16200,
14200, 17100, 18000, 16800, 16000, 16200, 17200, 15600, 13600,
16000, 21200, 16500, 15400, 11000, 18200, 28800, 92000, 379900,
73000, 39200, 110000, 545800, 277800, 6600, 9200, 15900, 32800,
64500, 137900, 329900, 8300, 12700, 18500, 23600, 23300, 29400,
15600, 14400, 18500, 8300, 23500, 27700, 27800, 21300, 16800,
16000, 23400, 20200, 16800, 16200, 24800, 19500, 14300, 20300,
41300, 61600, 206900, 9200, 18900), usd_per_avg_area = c(21248.4838260723,
4561.10293133449, 9066.25881377022, 18290.0672529746, 45006.4585575888,
81073.5935555701, 172153.462219826, 413808.094549783, 1210904.50883732,
28750.8918740366, 32700.9940357853, 20412.9963898917, 64980.6620209059,
653618.769366977, 25952.1590909091, 46540.3956422018, 32250.2783964365,
19709.9074787972, 58343.2355046528, 24477.6377385668, 17422.5250278087,
25326.9830949285, 6845.18369585085, 5868.55670103093, 13148.184879094,
65170.4196094724, 4165.3290529695, 11110.9865470852, 18517.2549722272,
13244.2034295764, 17895.3402222655, 20405.3015036428, 25237.6071589713,
21034.8599495553, 28516.7439434334, 25382.6530612245, 28340.4718234141,
24899.7591651057, 30234.2554248799, 17728.7939422473, 18904.9729480833,
15537.0470791225, 20348.4673827613, 23639.9729302955, 19626.5553869499,
16117.0147149529, 23182.4093372238, 18973.1480232087, 25540.5143875732,
16820.5364868763, 18275.5609552375, 27578.6017548825, 22147.0839260313,
19369.8896608092, 13770.5982743908, 20029.2760884589, 34680.9160305343,
132650.341598219, 605002.467489163, 99282.7219389154, 43276.3139354657,
161017.127403846, 879378.256021409, 369067.625899281, 6018.88917327873,
11003.3252309188, 18174.4315177155, 43970.5430200843, 86281.9998456909,
191360.789833508, 541489.911125741, 6155.01960784314, 11993.9927443449,
18773.3629447205, 32786.9350862777, 40230.1132306437, 52819.3558707476,
20243.0677176541, 18062.209471726, 25702.1333715145, 2693.97217928903,
26341.4110145999, 35030.6783144913, 32667.2308141231, 22795.9588881103,
20763.5567505281, 21402.1340977863, 33977.4243201642, 27943.4841021048,
20678.4918153393, 23584.8094398481, 38363.9846743295, 26080.0492610837,
17446.3515973919, 25533.467766575, 59612.4050632911, 98458.7570621469,
299794.936074204, 3181.09452736318, 24251.1002231069)), na.action = structure(c(`2` = 2L,
`11` = 11L, `30` = 30L, `40` = 40L, `54` = 54L, `60` = 60L, `66` = 66L,
`72` = 72L, `80` = 80L, `87` = 87L, `96` = 96L, `101` = 101L,
`106` = 106L, `113` = 113L, `121` = 121L, `130` = 130L, `134` = 134L,
`140` = 140L, `157` = 157L, `166` = 166L, `172` = 172L, `179` = 179L,
`183` = 183L, `187` = 187L, `191` = 191L, `199` = 199L, `204` = 204L,
`209` = 209L, `210` = 210L, `215` = 215L, `220` = 220L, `221` = 221L,
`230` = 230L, `238` = 238L, `239` = 239L, `248` = 248L, `251` = 251L,
`255` = 255L, `259` = 259L, `266` = 266L, `267` = 267L, `276` = 276L,
`287` = 287L, `293` = 293L, `298` = 298L, `311` = 311L, `313` = 313L,
`321` = 321L, `322` = 322L), class = "omit"), row.names = c(1L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 45L,
46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 55L, 56L, 57L, 58L, 59L,
61L, 62L, 63L, 64L, 65L, 67L, 68L, 69L, 70L, 71L, 73L, 74L, 75L,
76L, 77L, 78L, 79L, 81L, 82L, 83L, 84L, 85L, 86L, 88L, 89L, 90L,
91L, 92L, 93L, 94L, 95L, 97L, 98L, 99L, 100L, 102L, 103L, 104L,
105L, 107L, 108L, 109L, 110L, 111L, 112L, 114L), class = "data.frame")
I formatted your code for you now; but you should learn how to do it