在Shiny应用程序中使用dplyr过滤器

时间:2017-04-06 01:12:50

标签: r shiny dplyr

我在构建Shiny应用程序的早期阶段,根据用户选择绘制一些数据。我的数据开始了:

Price,Mileage,Make,Model,Trim,Type,Cylinder,Liter,Doors,Cruise,Sound,Leather
17314.10313,8221,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,1,1
17542.03608,9135,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,1,0
16218.84786,13196,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,1,0
16336.91314,16342,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,0,0
16339.17032,19832,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,0,1
15709.05282,22236,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,1,0
15230.00339,22576,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,1,0
15048.04218,22964,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,1,0
14862.09387,24021,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,0,1
15295.01827,27325,Buick,Century,Sedan 4D,Sedan,6,3.1,4,1,1,1
21335.85248,10237,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,0,0
20538.08751,15066,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,0
20512.09409,16633,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,0
19924.15905,19800,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,1
19774.24907,23359,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,1
19344.16554,23765,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,0
19105.13012,24008,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,0,0
18543.42705,26034,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,1
17808.199,32896,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,0
17968.83828,34665,Buick,Lacrosse,CX Sedan 4D,Sedan,6,3.6,4,1,1,1
22358.87768,8970,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,1,0
23785.92253,10577,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,1,1
22926.09037,14363,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,1,1
21895.75878,16508,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,0,1
21273.06171,18908,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,0,0
21460.01395,19467,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,0,1
21183.12359,21394,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,0,0
20406.0995,22596,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,0,0
21058.13958,24469,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,1,1
19556.89932,25245,Buick,Lacrosse,CXL Sedan 4D,Sedan,6,3.6,4,1,0,0
23447.68656,15755,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,1,0
23547.23944,16235,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,1,0
23016.00801,18147,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,1,1
22230.0275,22102,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,0,1
22625.07357,23612,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,0,1
21799.1721,24439,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,0,0
21341.25721,25212,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,1,1
21683.03146,26779,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,1,0
20986.01602,27096,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,0,0
20902.10379,29649,Buick,Lacrosse,CXS Sedan 4D,Sedan,6,3.8,4,1,1,1
20698.07708,2992,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,0,1
20099.25684,10036,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,1,1
18145.12649,18339,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,1,0
17944.85692,19592,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,0,0
19027.86231,21797,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,0,1
18348.89857,23852,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,1,0
17750.88457,25040,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,1,0
17772.96968,25052,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,1,0
17394.0214,25464,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,1,0
17645.74504,27830,Buick,Lesabre,Custom Sedan 4D,Sedan,6,3.8,4,1,1,1
21908.36662,17353,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,0,0
21956.34266,17787,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,0
21646.11692,19562,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,1
21575.45683,20137,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,0
20952.2178,20158,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,0
21562.04758,23767,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,0,1
19981.12791,24323,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,0
19425.84862,27839,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,0
19191.98962,29187,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,1
19641.7419,31324,Buick,Lesabre,Limited Sedan 4D,Sedan,6,3.8,4,1,1,1
25589.98315,2308,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,1,0
25098.62906,10014,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,1,0
23420.70695,18910,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,0,1
22661.04849,20105,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,0,0
23493.0823,20453,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,1,0
22435.20282,22287,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,1,1
21878.12,23237,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,1,0
23077.56591,23798,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,0,1
21698.01475,25489,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,1,1
21831.82292,25564,Buick,Park Avenue,Sedan 4D,Sedan,6,3.8,4,1,1,1
26831.19404,4695,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,1,0
26060.33535,9795,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,1,0
26781.81465,12052,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,1,0
26302.07428,13050,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,1,0
26190.27147,17335,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,0,1
25508.21096,17480,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,1,0
23348.01695,24027,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,0,1
23406.68982,25387,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,0,1
23159.54378,25869,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,0,0
21536.74173,37128,Buick,Park Avenue,Special Ed Ultra 4D,Sedan,6,3.8,4,1,1,1
51154.04722,2202,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,1,1
49248.15897,6685,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,0,1
46747.67327,15343,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,1,1
44130.61706,21341,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,0,1
44084.91421,21367,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,1,1
43892.46788,23371,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,0,1
44300.63996,23751,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,0,1
42677.60112,24052,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,0,1
43374.05242,25199,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,1,1
40619.07227,30082,Cadillac,CST-V,Sedan 4D,Sedan,8,5.7,4,1,1,1
33417.96501,6598,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
30957.08075,10625,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
31431.13037,11013,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
30781.51563,14937,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
30646.4377,17094,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
30792.14903,17870,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
30392.75016,18449,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
28817.08185,21039,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,0,1
29275.20871,21056,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
28040.12853,27484,Cadillac,CTS,Sedan 4D,Sedan,6,2.8,4,1,1,1
39801.55135,14095,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
40335.73731,14743,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
39307.00916,16041,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
38600.23956,17138,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
38445.89717,18661,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
36077.79612,21966,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
35866.58271,24415,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,1,1
35338.65369,25163,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
36154.30355,25339,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,1,1
34685.66298,25421,Cadillac,Deville,DHS Sedan 4D,Sedan,8,4.6,4,1,0,1
42820.32902,5499,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,0,1
41378.04809,8125,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,0,1
40856.3909,12791,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,1,1
41419.03726,14452,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,0,1
37510.25357,21593,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,0,1
37215.16938,22211,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,0,1
36332.89469,25153,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,0,1
36245.15823,26250,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,1,1
32954.14134,36074,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,0,1
32537.18675,41829,Cadillac,Deville,DTS Sedan 4D,Sedan,8,4.6,4,1,1,1
35715.76856,6447,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,0,1
35651.68002,10555,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,1,1
35129.34077,11975,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,1,1
35165.75937,13449,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,1,1
32501.24519,17508,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,0,1
33220.02845,18661,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,0,1
32509.47829,20910,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,0,1
31132.21349,23124,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,1,1
31181.71516,26222,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,0,1
31059.18103,27544,Cadillac,Deville,Sedan 4D,Sedan,8,4.6,4,1,1,1
42741.52367,2846,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,0,1
40966.60741,7476,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,1,1
38795.37909,13973,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,1,1
38297.46254,16754,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,0,1
37192.89637,19100,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,0,1
36210.123,21778,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,0,1
36633.63382,22042,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,1,1
35895.49941,23056,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,1,1
34974.37804,25796,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,1,1
32038.33956,35326,Cadillac,STS-V6,Sedan 4D,Sedan,6,3.6,4,1,1,1
48310.32954,788,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,0,1
48365.9809,2616,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,1,1
45061.95194,13829,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,1,1
44205.87588,15104,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,0,1
42377.95544,18581,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,0,1
41671.58314,20575,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,0,1
41516.42986,23861,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,1,1
41053.48217,25717,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,1,1
38208.50102,31303,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,1,1
39072.39205,31587,Cadillac,STS-V8,Sedan 4D,Sedan,8,4.6,4,1,0,1
70755.46672,583,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
68566.18719,6420,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
69133.73172,7892,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
66374.30704,12021,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
65281.48124,15600,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
63913.11725,18200,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
60567.54909,23193,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
57154.44344,29260,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
55639.08765,31805,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,0,1
52001.99438,42691,Cadillac,XLR-V8,Hardtop Conv 2D,Convertible,8,4.6,2,1,1,1
12146.18803,10011,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,0,1
12163.82042,12101,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,0,1
11472.02276,19699,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,0,1
11017.16871,20100,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,1,0
11096.85727,20334,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,1,0,0
10386.04022,22225,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,0,0
11137.04565,22484,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,1,1
11045.10884,24568,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,1,0,1
10777.05254,27906,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,0,0
9928.188175,29680,Chevrolet,AVEO,LS Hatchback 4D,Hatchback,4,1.6,4,0,0,1
12649.11089,3629,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,0,1,0
12314.59122,4142,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,0,1,0
11318.00809,11156,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,0,1,1
12409.94909,11981,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,1,1,1
11555.2674,13404,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,1,1,0
11700.11149,15253,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,1,0,0
11215.01865,19945,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,0,0,0
10144.95208,23963,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,1,1,0
10491.0752,30948,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,0,1,0
9954.054174,37345,Chevrolet,AVEO,LS Sedan 4D,Sedan,4,1.6,4,0,1,1
11031.12993,20156,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,0,1,1
11343.05401,20186,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,1,1,1
11391.21372,21421,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,0,1,1
11247.86253,21427,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,1,1,1
10921.94537,23119,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,0,1,1
11179.95357,23121,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,0,1,1
11394.8864,25107,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,0,1,1
11070.06064,25476,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,0,1,1
11013.87137,25746,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,1,1,1
11115.01364,30056,Chevrolet,AVEO,LT Hatchback 4D,Hatchback,4,1.6,4,1,1,1
11918.45607,7278,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,0,0
12408.80615,10213,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,0,1
11302.90299,14627,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,1,0
11615.02102,19014,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,1,1
10805.13009,21013,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,1,1,1
11169.91839,22380,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,1,0
10770.10655,25065,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,1,0
10872.01393,25869,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,0,0
10921.94537,27776,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,1,0,0
9919.048185,34621,Chevrolet,AVEO,LT Sedan 4D,Sedan,4,1.6,4,0,1,0
10813.34352,266,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,1,0,1
11167.861,4716,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,1,1,0
10897.07651,6699,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,0,1,1
10106.01643,14200,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,1,0,0
10354.04385,14521,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,0,1,0
10287.97736,16521,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,1,1,1
9720.97889,20836,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,1,1,0
9506.047937,22169,Chevrolet,AVEO,SVM Hatchback 4D,Hatchback,4,1.6,4,0,0,1

整个事情太大而无法发布,但这应该足够了。

我的ui.R文件包含

library(shiny)


data <- read.csv("Amstat.csv", header = TRUE)
modelTypes <- unique(data$Model)

# Define UI for application that draws a histogram
shinyUI(fluidPage(

  # Application title
  titlePanel("Car prices"),

  # Sidebar with a slider input for number of bins 
  sidebarLayout(
    sidebarPanel(
      selectInput("Model", 
                  label = "Choose a Model to display",
                  choices = modelTypes),

      selectInput("price",
                  label = "Choose a price",
                  choices = list("Left","Center", "Right"),
                  selected="CENTER")


    ),

    # Show a plot of the generated distribution
    mainPanel(
       plotOutput("carpricePlot")
    )
  )
))

我的server.r包含

library(shiny)
library(magrittr)
library(dplyr)

shinyServer(function(input, output) {

  data <- read.csv("Amstat.csv", header = TRUE)
  amstat1<-data %>% select(Type,Price,Model )%>% filter(Model == input$Model)

  output$carpricePlot <- renderPlot({

    plot(Model,
         Price,
         xlab="Model",
         ylab="prirce",
         pch=20)

  })
})

当我尝试运行该应用时,收到错误消息

  

filter_impl(.data,dots)中的错误:不允许操作   积极的反应背景。 (你试图做一些只能做的事情   从反应性表达或观察者内部完成。)

我没有抓住什么。在我尝试学习Shiny的其他应用程序中,我使用子集而不是过滤器完成了基本相同的事情...我应该避免使用Shiny中的过滤器吗?或者我做错了什么?好吧,显然我做错了什么!

1 个答案:

答案 0 :(得分:2)

当你使用来自UI(input$...)的变量时,你必须在被动反应中这样做:

shinyServer(function(input, output) {

  data <- read.csv("Amstat.csv", header = TRUE)
  amstat1<-reactive({
    data %>% select(Type,Price,Model ) %>% filter(Model == input$Model)
    })

  output$carpricePlot <- renderPlot({
    plot(amstat1()$Model,
         amstat1()$Price,
         xlab="Model",
         ylab="Price",
         pch=20)

  })
})