Kevin Vo bio photo

Kevin Vo

Data Enthusiast, works in R and Python

Email Facebook LinkedIn Github

Jupyter MD file with jekyll

load("~/Dropbox/Fall 2015/STAT 141/Assignment1/vehicles.rda")
ls()

<ol class=list-inline> <li>‘lungDeaths’</li> <li>‘vposts’</li> </ol>

vehicle = vposts
library(lattice)
library(ggplot2)
library(gmodels)
library(RColorBrewer)
class(vehicle)

‘data.frame’

names(vehicle)

<ol class=list-inline> <li>‘id’</li> <li>‘title’</li> <li>‘body’</li> <li>‘lat’</li> <li>‘long’</li> <li>‘posted’</li> <li>‘updated’</li> <li>‘drive’</li> <li>‘odometer’</li> <li>‘type’</li> <li>‘header’</li> <li>‘condition’</li> <li>‘cylinders’</li> <li>‘fuel’</li> <li>‘size’</li> <li>‘transmission’</li> <li>‘byOwner’</li> <li>‘city’</li> <li>‘time’</li> <li>‘description’</li> <li>‘location’</li> <li>‘url’</li> <li>‘price’</li> <li>‘year’</li> <li>‘maker’</li> <li>‘makerMethod’</li> </ol>

unlist( sapply(X = vehicle, FUN = class) )

<dl class=dl-horizontal> <dt>id</dt> <dd>‘character’</dd> <dt>title</dt> <dd>‘character’</dd> <dt>body</dt> <dd>‘character’</dd> <dt>lat</dt> <dd>‘numeric’</dd> <dt>long</dt> <dd>‘numeric’</dd> <dt>posted1</dt> <dd>‘POSIXct’</dd> <dt>posted2</dt> <dd>‘POSIXt’</dd> <dt>updated1</dt> <dd>‘POSIXct’</dd> <dt>updated2</dt> <dd>‘POSIXt’</dd> <dt>drive</dt> <dd>‘factor’</dd> <dt>odometer</dt> <dd>‘integer’</dd> <dt>type</dt> <dd>‘factor’</dd> <dt>header</dt> <dd>‘character’</dd> <dt>condition</dt> <dd>‘factor’</dd> <dt>cylinders</dt> <dd>‘integer’</dd> <dt>fuel</dt> <dd>‘factor’</dd> <dt>size</dt> <dd>‘factor’</dd> <dt>transmission</dt> <dd>‘factor’</dd> <dt>byOwner</dt> <dd>‘logical’</dd> <dt>city</dt> <dd>‘factor’</dd> <dt>time1</dt> <dd>‘POSIXct’</dd> <dt>time2</dt> <dd>‘POSIXt’</dd> <dt>description</dt> <dd>‘character’</dd> <dt>location</dt> <dd>‘character’</dd> <dt>url</dt> <dd>‘character’</dd> <dt>price</dt> <dd>‘integer’</dd> <dt>year</dt> <dd>‘integer’</dd> <dt>maker</dt> <dd>‘character’</dd> <dt>makerMethod</dt> <dd>‘numeric’</dd> </dl>

densityplot(vehicle$price, main = "Price", xlab = "Price")

svg

tail( sort(vehicle$price), 50)

<ol class=list-inline> <li>95593</li> <li>96590</li> <li>97000</li> <li>97500</li> <li>97911</li> <li>98000</li> <li>99560</li> <li>99999</li> <li>100000</li> <li>100000</li> <li>100000</li> <li>100000</li> <li>104800</li> <li>105000</li> <li>105500</li> <li>107000</li> <li>112000</li> <li>116100</li> <li>116491</li> <li>120000</li> <li>122950</li> <li>123981</li> <li>125000</li> <li>129950</li> <li>129990</li> <li>138500</li> <li>139000</li> <li>139950</li> <li>143000</li> <li>143000</li> <li>143950</li> <li>147000</li> <li>149890</li> <li>149995</li> <li>150000</li> <li>152900</li> <li>159000</li> <li>169000</li> <li>177588</li> <li>202455</li> <li>240000</li> <li>286763</li> <li>359000</li> <li>400000</li> <li>559500</li> <li>569500</li> <li>9999999</li> <li>30002500</li> <li>600030000</li> <li>600030000</li> </ol>

idx = which( vehicle$price >=  9999999 & !is.na(vehicle$price) )
vehicle[ idx, c("header", "price", "maker", "year") ]
<th scope=col>header</th><th scope=col>price</th><th scope=col>maker</th><th scope=col>year</th><th scope=row>posted22491</th><th scope=row>posted23881</th><th scope=row>posted6903</th><th scope=row>posted16005</th>
1969 Pontiac GTO600030000pontiac1969
1969 Pontiac GTO600030000pontiac1969
2002 Caddy Seville sls30002500cadillac2002
2001 Honda Accord9999999honda2001
idx = ( vehicle$maker == "pontiac" & vehicle$year %in% c(1968, 1969) &
+ vehicle$price < 9999999 & vehicle$price > 1 &
+ grepl(pattern = "GTO", x = vehicle$header, ignore.case = TRUE) &
+ !is.na(vehicle$maker) & !is.na(vehicle$price) & !is.na(vehicle$header) )
dat = vehicle[ idx, c("header", "price", "maker", "year") ]
dat[ order(dat$price), ]
<th scope=col>header</th><th scope=col>price</th><th scope=col>maker</th><th scope=col>year</th><th scope=row>posted4991</th><th scope=row>posted5371</th><th scope=row>posted231214</th><th scope=row>posted16497</th><th scope=row>posted201111</th><th scope=row>posted7355</th><th scope=row>posted16701</th><th scope=row>posted40911</th>
1968 pontiac gto15995pontiac1968
1968 pontiac gto15995pontiac1968
1968 Pontiac GTO24500pontiac1968
1969 Pontiac GTO25000pontiac1969
1969 Pontiac GTO25000pontiac1969
1968 pontiac gto30000pontiac1968
1968 Pontiac gto38500pontiac1968
1968 GTO38500pontiac1968
round( mean(vehicle$price[idx]), digits = -3)

27000

vehicle$price[vehicle$price == 600030000 & !is.na(vehicle$price)] = 27000
idx = which( vehicle$price >=  100000 & !is.na(vehicle$price))
length( idx )

40

vehicle[ idx, c("header", "price") ]
<th scope=col>header</th><th scope=col>price</th><th scope=row>posted698</th><th scope=row>posted1460</th><th scope=row>posted12461</th><th scope=row>posted22621</th><th scope=row>posted24081</th><th scope=row>posted21402</th><th scope=row>posted21422</th><th scope=row>posted6903</th><th scope=row>posted16934</th><th scope=row>posted7225</th><th scope=row>posted13245</th><th scope=row>posted16005</th><th scope=row>posted9976</th><th scope=row>posted11066</th><th scope=row>posted18506</th><th scope=row>posted18546</th><th scope=row>posted214110</th><th scope=row>posted6747</th><th scope=row>posted20867</th><th scope=row>posted5038</th><th scope=row>posted23788</th><th scope=row>posted12630</th><th scope=row>posted37310</th><th scope=row>posted163710</th><th scope=row>posted212510</th><th scope=row>posted231114</th><th scope=row>posted181511</th><th scope=row>posted194311</th><th scope=row>posted220311</th><th scope=row>posted106214</th><th scope=row>posted121313</th><th scope=row>posted129214</th><th scope=row>posted191712</th><th scope=row>posted222912</th><th scope=row>posted231215</th><th scope=row>posted95215</th><th scope=row>posted112215</th><th scope=row>posted212613</th><th scope=row>posted238613</th><th scope=row>posted245512</th>
2008 BMW X5177588
2010 CHEVROLET SILVERADO359000
2000 Mack RD688S1e+05
2013 Ford150000
2003 lincoln navigator1e+05
2009 CHEVROLET IMPALA559500
2007 CHEVROLET MONTE CARLO569500
2002 Caddy Seville sls30002500
2013 Isuzu NRR129990
1967 chevrolet corvette105500
2010 ford fusion105000
2001 Honda Accord9999999
2004 Toyota Corolla286763
2009 Lamborghini Gallardo129950
2009 Mercedes-Benz SL65139950
2013 Mercedes-Benz G63122950
2011 Bentley Mulsanne143950
2004 Lexus 470169000
2015 mercedes-benz s550107000
2012 Mercedes-Benz SLS AMG 2dr Roadster SLS AMG149890
2006 FORD GT4e+05
2014 ferrari 458 italia240000
2014 Audi RS 7 4.0T quattro116491
2015 Mercedes-Benz S-Class143000
2014 Porsche 911104800
2015 Porsche 911152900
1965 porsche 9111e+05
2005 TOYOTA AVALON112000
2011 toyota rav4159000
2014 Land Rover Range 5.0L V8123981
2016 porsche 911202455
2007 Lamborghini Gallardo Spyder149995
2015 Hyundai Sonata138500
2015 Porsche Panamera116100
2015 Mercedes-Benz S-Class143000
1988 porsche 911 Carrera Targa TL120000
1976 Porsche 930139000
1941 willys125000
2015 Porsche GT3147000
1961 Maserati 1511e+05
shortlist = vehicle[ idx, c("header", "price", "maker", "year") ]
filter_high_price = function(maker,year,header,price){
    idx = (vehicle$maker == maker & vehicle$year %in% c(year, year+1) &
          vehicle$price < 100000 & vehicle$price > 1 &
          grepl(pattern = gsub(maker,"",gsub("\\d+\\s","",header), ignore.case=TRUE),x = vehicle$header, ignore.case = TRUE) &
          !is.na(vehicle$maker) & !is.na(vehicle$price) & !is.na(vehicle$header))
  if(length(vehicle$price[idx])!= 0){
    newPrice = round( mean(vehicle$price[idx]), digits = -3)
    if(price > 1.5*newPrice) vehicle$price[vehicle$price == price & !is.na(vehicle$price)] <<- newPrice #return to global environment
  }
}

sapply(1:length(shortlist$maker), function(i) filter_high_price(shortlist$maker[i],shortlist$year[i],shortlist$header[i], shortlist$price[i]))
  1. 19000
  2. 26000
  3. NULL
  4. 19000
  5. 6000
  6. 7000
  7. 7000
  8. NULL
  9. NULL
  10. 41000
  11. 9000
  12. 3000
  13. 5000
  14. NULL
  15. NULL
  16. NULL
  17. NULL
  18. 19000
  19. NULL
  20. NULL
  21. 14000
  22. NULL
  23. NULL
  24. NULL
  25. NULL
  26. NULL
  27. 6000
  28. 8000
  29. 17000
  30. NULL
  31. 97000
  32. NULL
  33. 20000
  34. NULL
  35. NULL
  36. NULL
  37. NULL
  38. 20000
  39. NULL
  40. 6000
idx = which( vehicle$price >=  100000 & !is.na(vehicle$price) )
vehicle[ idx, c("header", "price") ]
<th scope=col>header</th><th scope=col>price</th><th scope=row>posted6903</th><th scope=row>posted16934</th><th scope=row>posted11066</th><th scope=row>posted18506</th><th scope=row>posted18546</th><th scope=row>posted214110</th><th scope=row>posted20867</th><th scope=row>posted5038</th><th scope=row>posted12630</th><th scope=row>posted37310</th><th scope=row>posted163710</th><th scope=row>posted212510</th><th scope=row>posted231114</th><th scope=row>posted106214</th><th scope=row>posted129214</th><th scope=row>posted222912</th><th scope=row>posted231215</th><th scope=row>posted95215</th><th scope=row>posted112215</th><th scope=row>posted238613</th>
2002 Caddy Seville sls30002500
2013 Isuzu NRR129990
2009 Lamborghini Gallardo129950
2009 Mercedes-Benz SL65139950
2013 Mercedes-Benz G63122950
2011 Bentley Mulsanne143950
2015 mercedes-benz s550107000
2012 Mercedes-Benz SLS AMG 2dr Roadster SLS AMG149890
2014 ferrari 458 italia240000
2014 Audi RS 7 4.0T quattro116491
2015 Mercedes-Benz S-Class143000
2014 Porsche 911104800
2015 Porsche 911152900
2014 Land Rover Range 5.0L V8123981
2007 Lamborghini Gallardo Spyder149995
2015 Porsche Panamera116100
2015 Mercedes-Benz S-Class143000
1988 porsche 911 Carrera Targa TL120000
1976 Porsche 930139000
2015 Porsche GT3147000
densityplot(vehicle$price, main = "Price", xlab = "Price")

svg

sum( is.na(vehicle$price) )

3328

sum( vehicle$price == 1 & !is.na(vehicle$price) )

612

filter_low_price = function(maker,year,header,price){
    idx = (vehicle$maker == maker & vehicle$year %in% c(year, year+1) &
          vehicle$price < 100000 & vehicle$price > 1 &
          grepl(pattern = gsub(maker,"",gsub("\\d+\\s","",header), ignore.case=TRUE),x = vehicle$header, ignore.case = TRUE) &
          !is.na(vehicle$maker) & !is.na(vehicle$price) & !is.na(vehicle$header))
  if(length(vehicle$price[idx])!= 0){
    newPrice = round( mean(vehicle$price[idx]), digits = -3)
    if(price < 1.5*newPrice) vehicle$price[vehicle$price == price & !is.na(vehicle$price)] <<- newPrice #return to global environment
  }
}



idx = which( vehicle$price <= 500 & !is.na(vehicle$price))
shortlist = vehicle[ idx, c("header", "price", "maker", "year") ]
sapply(1:length(shortlist$maker), function(i) filter_low_price(shortlist$maker[i],shortlist$year[i],shortlist$header[i], shortlist$price[i]))
Error in if (price < 1.5 * newPrice) vehicle$price[vehicle$price == price & : missing value where TRUE/FALSE needed
library(shiny)
library(DT)
idx = which( vehicle$price <= 500 & !is.na(vehicle$price))
shortlist = vehicle[ idx, c("header", "price", "maker", "year") ]
head(shortlist,n=50)
<th scope=col>header</th><th scope=col>price</th><th scope=col>maker</th><th scope=col>year</th><th scope=row>posted1965</th><th scope=row>posted1974</th><th scope=row>posted2129</th><th scope=row>posted2138</th><th scope=row>posted7210</th><th scope=row>posted19510</th><th scope=row>posted24110</th><th scope=row>posted2498</th><th scope=row>posted2771</th><th scope=row>posted3931</th><th scope=row>posted5361</th><th scope=row>posted6871</th><th scope=row>posted7461</th><th scope=row>posted7471</th><th scope=row>posted7491</th><th scope=row>posted7501</th><th scope=row>posted7811</th><th scope=row>posted8091</th><th scope=row>posted8531</th><th scope=row>posted8961</th><th scope=row>posted9421</th><th scope=row>posted9451</th><th scope=row>posted9771</th><th scope=row>posted9791</th><th scope=row>posted10071</th><th scope=row>posted10161</th><th scope=row>posted11291</th><th scope=row>posted11961</th><th scope=row>posted12091</th><th scope=row>posted12111</th><th scope=row>posted12401</th><th scope=row>posted12781</th><th scope=row>posted12851</th><th scope=row>posted13201</th><th scope=row>posted13391</th><th scope=row>posted14011</th><th scope=row>posted14031</th><th scope=row>posted14411</th><th scope=row>posted16351</th><th scope=row>posted16581</th><th scope=row>posted16781</th><th scope=row>posted17031</th><th scope=row>posted17171</th><th scope=row>posted17791</th><th scope=row>posted17931</th><th scope=row>posted18031</th><th scope=row>posted18431</th><th scope=row>posted18611</th><th scope=row>posted18631</th><th scope=row>posted18911</th>
2004 Jeep Wrangler X23jeep2004
2005 Mini Cooper Sport19mini2005
1998 DODGE CARAVAN400dodge1998
1995 ford escort wagon300ford1995
1995 Subaru Legacy499subaru1995
2015 BRIWAY210NA2015
2005 Bridgestone dueler400NA2005
1964 Pontiac GTO30pontiac1964
2001 Chevrolet Malibu400chevrolet2001
1986 Mazda RX-7395mazda1986
2008 Honda Accord12honda2008
2009 chevrolet equinox8chevrolet2009
2012 cadillac srx6cadillac2012
2008 Mazda 62mazda2008
2006 saab 9-32saab2006
2004 chevrolet trailblazer ext3chevrolet2004
2000 trailer300NA2000
2006 Hyndai Tucson4hyundai2006
1994 acura legend300acura1994
2000 Fhfhfhffj200NA2000
2000 honda accord 4-door sedan450honda2000
1993 ford mustang100ford1993
2002 ford taurus x2ford2002
2002 TOYOTA COROLLA3toyota2002
2001 bobcat v 623 loadall55NA2001
1989 case 1835 c diesel11NA1989
2016 Variety2NA2016
1997 chevy495chevrolet1997
2012 cadillac srx6cadillac2012
2008 Mazda 62mazda2008
1969 repair manual60NA1969
1972 Chevrolet C1010chevrolet1972
2008 gmc 2500 sierra120gmc2008
2013 PowerStation80NA2013
2009 Ford F-15050ford2009
1986 Mazda RX-7395mazda1986
1999 toyota supra50toyota1999
2013 tral50NA2013
1985 300 D400mercedes1985
2003 ford windstar van4ford2003
1997 Ford pick up175ford1997
2014 Nissan Rogue SV AWD340nissan2014
2008 cadillac srx100cadillac2008
2003 Snowbear200NA2003
2015 Tire15NA2015
2010 truck60NA2010
1997 Chevy Cavalier450chevrolet1997
1999 Ford Ranger175ford1999
2001 honda accord 2-door coupe400honda2001
2003 Mercury marquis gs park lane165mercury2003
idx = which( vehicle$price <= 500 & !is.na(vehicle$price) & !is.na(vehicle$maker))
shortlist = vehicle[ idx, c("header", "price", "maker", "year") ]
sapply(1:length(shortlist$maker), function(i) filter_low_price(shortlist$maker[i],shortlist$year[i],shortlist$header[i], shortlist$price[i]))
  1. 8000
  2. NULL
  3. 1000
  4. NULL
  5. 2000
  6. NULL
  7. 2000
  8. 2000
  9. 10000
  10. 6000
  11. 16000
  12. 6000
  13. 6000
  14. 3000
  15. NULL
  16. NULL
  17. 3000
  18. 5000
  19. 6000
  20. 4000
  21. 3000
  22. 20000
  23. 7000
  24. 7000
  25. 17000
  26. 19000
  27. 2000
  28. 19000
  29. 5000
  30. 2000
  31. NULL
  32. NULL
  33. 7000
  34. 1000
  35. 3000
  36. 3000
  37. NULL
  38. NULL
  39. 3000
  40. 6000
  41. 5000
  42. 14000
  43. NULL
  44. NULL
  45. NULL
  46. NULL
  47. NULL
  48. NULL
  49. NULL
  50. NULL
  51. 6000
  52. 4000
  53. 7000
  54. 16000
  55. 29000
  56. NULL
  57. 13000
  58. NULL
  59. NULL
  60. 18000
  61. 21000
  62. 15000
  63. 8000
  64. 11000
  65. NULL
  66. 16000
  67. 11000
  68. 33000
  69. 17000
  70. 15000
  71. 16000
  72. 6000
  73. 4000
  74. NULL
  75. 4000
  76. 13000
  77. NULL
  78. 18000
  79. 10000
  80. 10000
  81. 10000
  82. 6000
  83. 16000
  84. 10000
  85. 12000
  86. NULL
  87. 10000
  88. NULL
  89. 11000
  90. 7000
  91. 14000
  92. 18000
  93. 4000
  94. 4000
  95. 6000
  96. 4000
  97. 4000
  98. 4000
  99. 4000
  100. 4000
  101. 12000
  102. 4000
  103. 4000
  104. 4000
  105. 20000
  106. 4000
  107. 4000
  108. 4000
  109. 4000
  110. 8000
  111. 4000
  112. 18000
  113. 23000
  114. 13000
  115. 9000
  116. 8000
  117. 36000
  118. 15000
  119. 32000
  120. 12000
  121. 12000
  122. 13000
  123. 6000
  124. 5000
  125. NULL
  126. 2000
  127. 5000
  128. 17000
  129. 5000
  130. NULL
  131. 6000
  132. 4000
  133. 3000
  134. NULL
  135. 2000
  136. 2000
  137. 2000
  138. 19000
  139. 13000
  140. 3000
  141. 3000
  142. 1000
  143. 3000
  144. 3000
  145. 1000
  146. 4000
  147. 3000
  148. NULL
  149. 1000
  150. NULL
  151. 16000
  152. 5000
  153. NULL
  154. 2000
  155. NULL
  156. 19000
  157. 4000
  158. 2000
  159. 11000
  160. 11000
  161. 13000
  162. 13000
  163. NULL
  164. 12000
  165. 15000
  166. 13000
  167. 30000
  168. 14000
  169. NULL
  170. 9000
  171. 9000
  172. 21000
  173. 2000
  174. NULL
  175. 4000
  176. 5000
  177. 1000
  178. 13000
  179. NULL
  180. 8000
  181. 5000
  182. 18000
  183. 2000
  184. 32000
  185. 18000
  186. NULL
  187. 2000
  188. 2000
  189. 16000
  190. NULL
  191. 2000
  192. 2000
  193. 5000
  194. NULL
  195. 17000
  196. 4000
  197. 11000
  198. 5000
  199. 2000
  200. 2000
  201. 21000
  202. 20000
  203. 26000
  204. 10000
  205. 17000
  206. 4000
  207. 11000
  208. 19000
  209. 3000
  210. 2000
  211. 2000
  212. 13000
  213. 2000
  214. 3000
  215. 17000
  216. 5000
  217. 8000
  218. 2000
  219. 5000
  220. 5000
  221. 4000
  222. 7000
  223. 4000
  224. NULL
  225. 22000
  226. 5000
  227. 12000
  228. 15000
  229. 7000
  230. 5000
  231. 13000
  232. 9000
  233. 19000
  234. 22000
  235. 2000
  236. 5000
  237. 4000
  238. 5000
  239. 4000
  240. 5000
  241. 13000
  242. 2000
  243. 3000
  244. 5000
  245. 7000
  246. 6000
  247. 6000
  248. 5000
  249. 5000
  250. 2000
  251. 5000
  252. 8000
  253. 7000
  254. 5000
  255. 2000
  256. 5000
  257. 22000
  258. 2000
  259. 2000
  260. 2000
  261. 7000
  262. 13000
  263. 9000
  264. 5000
  265. 2000
  266. 5000
  267. 3000
  268. 2000
  269. 2000
  270. 2000
  271. 5000
  272. 8000
  273. 5000
  274. 2000
  275. 3000
  276. 8000
  277. 19000
  278. 4000
  279. 8000
  280. 5000
  281. 23000
  282. 2000
  283. 2000
  284. 2000
  285. 5000
  286. 2000
  287. 6000
  288. 4000
  289. 5000
  290. 9000
  291. 7000
  292. 4000
  293. 6000
  294. 5000
  295. 7000
  296. 2000
  297. 8000
  298. 2000
  299. 5000
  300. 2000
  301. 2000
  302. 2000
  303. 2000
  304. 13000
  305. 3000
  306. 22000
  307. 2000
  308. 5000
  309. 5000
  310. 3000
  311. 3000
  312. 1000
  313. 6000
  314. 4000
  315. 6000
  316. 4000
  317. 4000
  318. 3000
  319. 15000
  320. 4000
  321. 13000
  322. 10000
  323. 1000
  324. 6000
  325. 6000
  326. 9000
  327. 12000
  328. 22000
  329. 6000
  330. 3000
  331. 2000
  332. 17000
  333. 2000
  334. 8000
  335. 2000
  336. 6000
  337. 11000
  338. 5000
  339. 8000
  340. NULL
  341. 6000
  342. 3000
  343. 11000
  344. 21000
  345. 5000
  346. 1000
  347. NULL
  348. 4000
  349. 2000
  350. 18000
  351. 4000
  352. 4000
  353. 5000
  354. 14000
  355. 22000
  356. 13000
  357. 3000
  358. 6000
  359. 5000
  360. 3000
  361. 5000
  362. 8000
  363. 5000
  364. 6000
  365. 3000
  366. 10000
  367. NULL
  368. NULL
  369. NULL
  370. NULL
  371. NULL
  372. NULL
  373. NULL
  374. NULL
  375. 12000
  376. 2000
  377. 2000
  378. 2000
  379. 2000
  380. 2000
  381. 2000
  382. 2000
  383. 3000
  384. 22000
  385. 28000
  386. 9000
  387. 8000
  388. 12000
  389. 13000
  390. 10000
  391. NULL
  392. 28000
  393. 30000
  394. 24000
  395. 16000
  396. 22000
  397. 10000
  398. NULL
  399. 5000
  400. 8000
  401. NULL
  402. 18000
  403. 3000
  404. 2000
  405. 13000
  406. 29000
  407. 12000
  408. 18000
  409. 22000
  410. 22000
  411. 29000
  412. 32000
  413. 27000
  414. 31000
  415. 33000
  416. 35000
  417. 29000
  418. 21000
  419. 22000
  420. 22000
  421. 32000
  422. 12000
  423. 13000
  424. 13000
  425. 14000
  426. 14000
  427. 16000
  428. 18000
  429. 13000
  430. 15000
  431. 15000
  432. 14000
  433. 16000
  434. 17000
  435. 17000
  436. 22000
  437. 15000
  438. 17000
  439. 15000
  440. 18000
  441. 24000
  442. 14000
  443. 15000
  444. 15000
  445. 15000
  446. 16000
  447. 20000
  448. 15000
  449. 15000
  450. 28000
  451. 31000
  452. 15000
  453. NULL
  454. 13000
  455. 10000
  456. 10000
  457. 10000
  458. 21000
  459. 19000
  460. 11000
  461. 22000
  462. 18000
  463. 25000
  464. 25000
  465. 16000
  466. 23000
  467. 32000
  468. 17000
  469. 36000
  470. 16000
  471. NULL
  472. 14000
  473. 17000
  474. 25000
  475. 22000
  476. 18000
  477. 4000
  478. 29000
  479. 7000
  480. 10000
  481. 15000
  482. 12000
  483. 15000
  484. 9000
  485. 23000
  486. 33000
  487. 34000
  488. 20000
  489. 18000
  490. 25000
  491. 33000
  492. 2000
  493. 14000
  494. 22000
  495. 18000
  496. 35000
  497. 13000
  498. 9000
  499. 10000
  500. 14000
  501. 10000
  502. 22000
  503. 24000
  504. 18000
  505. 10000
  506. 17000
  507. 15000
  508. 19000
  509. 17000
  510. 3000
  511. 5000
  512. 17000
  513. 17000
  514. 14000
  515. 16000
  516. 3000
  517. 29000
  518. 34000
  519. 17000
  520. 5000
  521. 18000
  522. 4000
  523. 17000
  524. 17000
  525. 33000
  526. 34000
  527. 17000
  528. 13000
  529. 5000
  530. 16000
  531. 27000
  532. 17000
  533. 5000
  534. 3000
  535. 23000
  536. 23000
  537. 34000
  538. 17000
  539. 15000
  540. 14000
  541. 10000
  542. 18000
  543. 18000
  544. 17000
  545. 16000
  546. 11000
  547. 23000
  548. 20000
  549. 25000
  550. 18000
  551. 10000
  552. 22000
  553. 10000
  554. 12000
  555. 9000
  556. 9000
  557. 18000
  558. 18000
  559. 17000
  560. 21000
  561. 24000
  562. 24000
  563. 13000
  564. 24000
  565. 20000
  566. 20000
  567. 30000
  568. 43000
  569. 16000
  570. NULL
  571. 25000
  572. 27000
  573. 25000
  574. 25000
  575. 10000
  576. 18000
  577. 19000
  578. 33000
  579. 14000
  580. 5000
  581. 10000
  582. 8000
  583. 5000
  584. 8000
  585. 24000
  586. 10000
  587. 22000
  588. 8000
  589. 8000
  590. 33000
  591. 19000
  592. 5000
  593. 10000
  594. 14000
  595. 22000
  596. 12000
  597. 10000
  598. 26000
  599. 24000
  600. 21000
  601. 14000
  602. 12000
  603. 24000
  604. 22000
  605. 22000
  606. 12000
  607. 22000
  608. 15000
  609. 18000
  610. 13000
  611. 23000
  612. 34000
  613. 13000
  614. 19000
  615. 17000
  616. 20000
  617. 4000
  618. 4000
  619. 30000
  620. 18000
  621. 17000
  622. 18000
  623. 18000
  624. 15000
  625. 30000
  626. 14000
  627. 14000
  628. 34000
  629. 30000
  630. 36000
  631. 23000
  632. 22000
  633. 35000
  634. 17000
  635. NULL
  636. NULL
  637. 14000
  638. 18000
  639. 18000
  640. 27000
  641. 27000
  642. 24000
  643. 30000
  644. 14000
  645. 32000
  646. 10000
  647. 10000
  648. 10000
  649. 8000
  650. 10000
  651. 10000
  652. 20000
  653. 20000
  654. 16000
  655. 26000
  656. 4000
  657. 8000
  658. 8000
  659. 8000
  660. 8000
  661. 15000
  662. 1000
  663. NULL
  664. 8000
  665. 8000
  666. NULL
  667. 4000
  668. 11000
  669. 3000
  670. NULL
  671. 14000
  672. 3000
  673. 24000
  674. 12000
  675. 12000
  676. 1000
  677. 1000
  678. 20000
  679. 3000
  680. 10000
  681. 10000
  682. 2000
  683. 13000
  684. 13000
  685. 25000
  686. 11000
  687. 7000
  688. 9000
  689. 9000
  690. 25000
  691. 2000
  692. 6000
  693. 11000
  694. 10000
  695. 7000
  696. 15000
  697. 2000
  698. 15000
  699. 22000
  700. 10000
  701. 3000
  702. 15000
  703. 15000
  704. 6000
  705. 14000
  706. 22000
  707. 10000
  708. 3000
  709. 5000
  710. 5000
  711. 1000
  712. 14000
  713. 14000
  714. 16000
  715. NULL
  716. 14000
  717. 10000
  718. 5000
  719. 9000
  720. 20000
  721. 8000
  722. 5000
  723. 18000
  724. 13000
  725. NULL
  726. 13000
  727. 13000
  728. 13000
  729. 10000
  730. 14000
  731. 14000
  732. NULL
  733. 11000
  734. 11000
  735. 10000
  736. 12000
  737. 14000
  738. 30000
  739. 22000
  740. 16000
  741. 20000
  742. 8000
  743. 6000
  744. 12000
  745. 8000
  746. 7000
  747. 7000
  748. 9000
  749. NULL
  750. 4000
  751. 23000
  752. 4000
  753. 13000
  754. 1000
  755. 5000
  756. 1000
  757. 3000
  758. 3000
  759. 4000
  760. 5000
  761. 1000
  762. 6000
  763. 16000
  764. 2000
  765. 1000
  766. 6000
  767. 4000
  768. 4000
  769. 4000
  770. 7000
  771. 1000
  772. 6000
  773. 20000
  774. 16000
  775. 1000
  776. 7000
  777. 2000
  778. 11000
  779. 10000
  780. 12000
  781. NULL
  782. 18000
  783. NULL
  784. 1000
  785. 4000
  786. 1000
  787. 27000
  788. 8000
  789. 1000
  790. 18000
  791. 4000
  792. 6000
  793. 4000
  794. 2000
  795. 2000
  796. 5000
  797. 6000
  798. NULL
  799. 2000
  800. NULL
  801. 2000
  802. 13000
  803. 20000
  804. 14000
  805. 12000
  806. 18000
  807. 19000
  808. 19000
  809. 13000
  810. 14000
  811. 3000
  812. 4000
  813. 1000
  814. 10000
  815. 1000
  816. 5000
  817. NULL
  818. 16000
  819. 1000
  820. 9000
  821. 5000
  822. NULL
  823. 14000
  824. 9000
  825. 6000
  826. 11000
  827. 5000
  828. 1000
  829. 1000
  830. 4000
  831. 1000
  832. 1000
  833. 16000
  834. 15000
  835. 23000
  836. 4000
  837. 19000
  838. 1000
  839. 1000
  840. NULL
  841. 10000
  842. 8000
  843. 2000
  844. NULL
  845. 4000
  846. 9000
  847. 7000
  848. 3000
  849. 8000
  850. 2000
  851. 4000
  852. 25000
  853. 3000
  854. 3000
  855. 12000
  856. 8000
  857. 5000
  858. 4000
  859. 19000
  860. NULL
  861. NULL
  862. NULL
  863. 15000
  864. 10000
  865. 4000
idx = which( vehicle$price <= 500 & !is.na(vehicle$price) & !is.na(vehicle$maker))
vehicle[ idx, c("header", "price", "maker", "year") ]
<th scope=col>header</th><th scope=col>price</th><th scope=col>maker</th><th scope=col>year</th><th scope=row>posted1974</th><th scope=row>posted17031</th><th scope=row>posted18911</th><th scope=row>posted15112</th><th scope=row>posted4082</th><th scope=row>posted21615</th><th scope=row>posted18374</th><th scope=row>posted2555</th><th scope=row>posted18929</th><th scope=row>posted9448</th><th scope=row>posted29613</th><th scope=row>posted128913</th><th scope=row>posted229713</th><th scope=row>posted229813</th><th scope=row>posted229913</th>
2005 Mini Cooper Sport19mini2005
2014 Nissan Rogue SV AWD340nissan2014
2003 Mercury marquis gs park lane165mercury2003
2012 Audi Q5 3.2 Quattro Premium Plus455audi2012
2014 Ford Explorer Limited365ford2014
1957 CHEVROLET BELAIR70chevrolet1957
2012 Audi Q5 3.2 Quattro Premium Plus455audi2012
1997 Subaru legacy80subaru1997
2014 Ford Explorer Limited365ford2014
2012 Chrysler 300-Series179chrysler2012
1998 ford e150 econoline375ford1998
1992 Saturn SL280saturn1992
1961 chevrolet corvette convertible53chevrolet1961
1961 chevrolet corvette convertible53chevrolet1961
1961 chevrolet corvette convertible53chevrolet1961
vehicle = vehicle[-idx,]
quantile(x = vehicle$price, probs = c(0.05,0.99), na.rm = TRUE)

<dl class=dl-horizontal> <dt>5%</dt> <dd>1350</dd> <dt>99%</dt> <dd>46000</dd> </dl>