不断收到错误-'xts(dat,order.by = as.POSIXct(dat $ Date,format =“%Y /%m /%d”))中的错误:'order.by'不能包含'NA',' NaN”或“ Inf”

时间:2019-07-01 01:41:14

标签: r xts

遇到困扰我的错误。我是R的新手,并且会不断出现这种错误。

我运行以下代码,由于不适用,因此无法使用。然后,我用NA修复程序再次运行它。但这是否真的有必要,感觉我做错了什么?感谢帮助。

R> datxts <- xts(dat, order.by =  as.POSIXct( dat$Date, format="%Y / %m / %d" ))
Error in xts(dat, order.by = as.POSIXct(dat$Date, format = "%Y / %m / %d")) : 
  'order.by' cannot contain 'NA', 'NaN', or 'Inf'

R> datxts <- xts(dat, order.by = na.locf( as.POSIXct( dat$Date, format="%Y / %m / %d" )))


以下是一些输入数据:

           X     Date       Day.of.Week X.HBC.HEALTH..and..BEAUTY.CARE ALCOHOL..BEER.
0001-01-18 "  1" "1/1/18"   "Monday"    "$38.94 "                      "$510.37 "    
0001-02-18 "  2" "1/2/18"   "Tuesday"   "$31.77 "                      "$392.83 "    
0001-03-18 "  3" "1/3/18"   "Wednesday" "$84.39 "                      "$325.54 "    
0001-04-18 "  4" "1/4/18"   "Thursday"  "$63.84 "                      "$435.39 "    
0001-05-18 "  5" "1/5/18"   "Friday"    "$71.40 "                      "$392.62 "    
0001-06-18 "  6" "1/6/18"   "Saturday"  "$75.91 "                      "$611.53 "    
0001-07-18 "  7" "1/7/18"   "Sunday"    "$60.97 "                      "$432.04 "    
0001-08-18 "  8" "1/8/18"   "Monday"    "$77.94 "                      "$375.45 "    
0001-09-18 "  9" "1/9/18"   "Tuesday"   "$63.14 "                      "$291.42 "    
0001-10-18 " 10" "1/10/18"  "Wednesday" "$36.31 "                      "$331.06 "    
0001-11-18 " 11" "1/11/18"  "Thursday"  "$41.70 "                      "$342.22 "    
0001-12-18 " 12" "1/12/18"  "Friday"    "$37.04 "                      "$502.85 "    
0001-12-18 " 13" "1/13/18"  "Saturday"  "$81.75 "                      "$771.83 "    
0001-12-18 " 14" "1/14/18"  "Sunday"    "$92.13 "                      "$621.16 "    
0001-12-18 " 15" "1/15/18"  "Monday"    "$24.40 "                      "$389.88 "    
0001-12-18 " 16" "1/16/18"  "Tuesday"   "$27.84 "                      "$355.42 "    
0001-12-18 " 17" "1/17/18"  "Wednesday" "$51.02 "                      "$351.90 "    
0001-12-18 " 18" "1/18/18"  "Thursday"  "$69.48 "                      "$577.52 "    
0001-12-18 " 19" "1/19/18"  "Friday"    "$42.72 "                      "$506.53 "    
0001-12-18 " 20" "1/20/18"  "Saturday"  "$73.75 "                      "$568.14 "    
0001-12-18 " 21" "1/21/18"  "Sunday"    "$74.19 "                      "$558.54 "    
0001-12-18 " 22" "1/22/18"  "Monday"    "$43.20 "                      "$460.79 "    
0001-12-18 " 23" "1/23/18"  "Tuesday"   "$46.27 "                      "$516.35 "    
0001-12-18 " 24" "1/24/18"  "Wednesday" "$83.28 "                      "$557.09 "    
0001-12-18 " 25" "1/25/18"  "Thursday"  "$33.10 "                      "$464.18 "    
0001-12-18 " 26" "1/26/18"  "Friday"    "$47.70 "                      "$454.37 "    
0001-12-18 " 27" "1/27/18"  "Saturday"  "$58.17 "                      "$750.93 "    
0001-12-18 " 28" "1/28/18"  "Sunday"    "$41.61 "                      "$580.73 "    
0001-12-18 " 29" "1/29/18"  "Monday"    "$43.47 "                      "$367.86 "    
0001-12-18 " 30" "1/30/18"  "Tuesday"   "$22.75 "                      "$274.31 "    
0001-12-18 " 31" "1/31/18"  "Wednesday" "$31.93 "                      "$380.82 "    
0002-01-18 " 32" "2/1/18"   "Thursday"  "$41.93 "                      "$398.98 "    
0002-02-18 " 33" "2/2/18"   "Friday"    "$45.70 "                      "$594.28 "    
0002-03-18 " 34" "2/3/18"   "Saturday"  "$59.35 "                      "$763.58 "    
0002-04-18 " 35" "2/4/18"   "Sunday"    "$39.03 "                      "$718.06 "    
0002-05-18 " 36" "2/5/18"   "Monday"    "$16.97 "                      "$440.09 "    
0002-06-18 " 37" "2/6/18"   "Tuesday"   "$24.44 "                      "$358.66 "    
           ALCOHOL..WINE. AUTOMOTIVE BEVERAGES  CANDY      CLEANING.MATERIALS
0001-01-18 "$21.98 "      "$12.15 "  "$291.03 " "$172.93 " "$0.00 "          
0001-02-18 "$0.00 "       "$17.98 "  "$281.33 " "$154.09 " "$0.00 "          
0001-03-18 "$39.97 "      "$68.19 "  "$273.11 " "$142.65 " "$0.00 "          
0001-04-18 "$59.63 "      "$0.00 "   "$243.23 " "$151.48 " "$5.28 "          
0001-05-18 "$79.63 "      "$37.94 "  "$463.82 " "$221.09 " "$0.00 "          
0001-06-18 "$71.64 "      "$3.99 "   "$374.48 " "$210.33 " "$0.00 "          
0001-07-18 "$46.96 "      "$0.00 "   "$373.76 " "$205.70 " "$0.00 "          
0001-08-18 "$8.69 "       "$31.96 "  "$199.34 " "$128.98 " "$0.00 "          
0001-09-18 "$0.00 "       "$14.48 "  "$170.31 " "$128.19 " "$0.00 "          
0001-10-18 "$0.00 "       "$0.00 "   "$226.96 " "$131.95 " "$0.00 "          
0001-11-18 "$33.67 "      "$21.97 "  "$227.37 " "$140.46 " "$0.00 "          
0001-12-18 "$43.66 "      "$5.99 "   "$195.05 " "$147.84 " "$0.00 "          
0001-12-18 "$47.35 "      "$16.47 "  "$276.58 " "$138.59 " "$0.00 "          
0001-12-18 "$31.37 "      "$14.16 "  "$320.96 " "$196.92 " "$0.00 "          
0001-12-18 "$0.00 "       "$29.95 "  "$219.63 " "$125.36 " "$5.28 "          
0001-12-18 "$33.97 "      "$6.99 "   "$166.44 " "$151.61 " "$0.00 "          
0001-12-18 "$11.99 "      "$18.97 "  "$206.83 " "$108.18 " "$0.00 "          
0001-12-18 "$29.97 "      "$16.97 "  "$200.65 " "$171.75 " "$0.00 "          
0001-12-18 "$18.68 "      "$23.46 "  "$274.90 " "$158.76 " "$8.37 "          
0001-12-18 "$0.00 "       "$0.00 "   "$255.10 " "$157.99 " "$0.00 "          
0001-12-18 "$8.69 "       "$7.88 "   "$273.15 " "$156.81 " "$0.00 "          
0001-12-18 "$9.99 "       "$20.47 "  "$201.78 " "$120.84 " "$3.99 "          
0001-12-18 "$8.69 "       "$16.98 "  "$237.50 " "$150.79 " "$0.00 "          
0001-12-18 "$42.36 "      "$0.00 "   "$240.37 " "$128.63 " "$0.00 "          
0001-12-18 "$63.35 "      "$15.48 "  "$246.78 " "$124.40 " "$0.00 "          
0001-12-18 "$8.69 "       "$0.00 "   "$300.10 " "$156.59 " "$0.00 "          
0001-12-18 "$58.64 "      "$0.00 "   "$271.58 " "$206.11 " "$0.00 "          
0001-12-18 "$39.97 "      "$22.47 "  "$324.80 " "$164.35 " "$0.00 "          
0001-12-18 "$79.96 "      "$5.99 "   "$292.75 " "$129.62 " "$0.00 "          
0001-12-18 "$4.99 "       "$0.00 "   "$290.76 " "$139.89 " "$10.77 "         
0001-12-18 "$20.68 "      "$22.37 "  "$228.75 " "$98.76 "  "$0.00 "          
0002-01-18 "$78.63 "      "$10.47 "  "$323.42 " "$137.10 " "$0.00 "          
0002-02-18 "$49.75 "      "$0.00 "   "$391.12 " "$178.11 " "$0.00 "          
0002-03-18 "$88.43 "      "$34.95 "  "$327.68 " "$174.81 " "$0.00 "          
0002-04-18 "$125.38 "     "$8.49 "   "$291.98 " "$170.10 " "$3.99 "          
0002-05-18 "$27.36 "      "$6.99 "   "$205.60 " "$124.69 " "$0.00 "          
0002-06-18 "$9.98 "       "$8.97 "   "$224.33 " "$139.28 " "$0.00 "          
           COFFEE     CRV       DAIRY      DELI.SANDWICH..and..FOOD ENERGY.DRINKS
0001-01-18 "$84.95 "  "$44.47 " "$71.64 "  "$5.98 "                 "$206.06 "   
0001-02-18 "$57.69 "  "$38.56 " "$60.60 "  "$38.90 "                "$252.61 "   
0001-03-18 "$64.84 "  "$40.25 " "$44.14 "  "$10.97 "                "$275.32 "   
0001-04-18 "$73.40 "  "$40.95 " "$49.13 "  "$36.59 "                "$252.25 "   
0001-05-18 "$94.47 "  "$45.00 " "$54.62 "  "$27.92 "                "$326.20 "   
0001-06-18 "$43.56 "  "$51.55 " "$40.48 "  "$18.75 "                "$393.68 "   
0001-07-18 "$62.27 "  "$40.30 " "$55.61 "  "$21.94 "                "$261.48 "   
0001-08-18 "$65.24 "  "$29.65 " "$41.86 "  "$15.96 "                "$211.71 "   
0001-09-18 "$47.74 "  "$27.05 " "$49.64 "  "$20.94 "                "$144.22 "   
0001-10-18 "$80.35 "  "$31.25 " "$23.72 "  "$22.93 "                "$235.94 "   
0001-11-18 "$71.80 "  "$30.00 " "$42.15 "  "$43.68 "                "$246.85 "   
0001-12-18 "$66.04 "  "$38.20 " "$53.31 "  "$31.61 "                "$276.58 "   
0001-12-18 "$37.98 "  "$60.85 " "$38.75 "  "$6.77 "                 "$312.08 "   
0001-12-18 "$56.88 "  "$51.80 " "$30.68 "  "$15.96 "                "$304.08 "   
0001-12-18 "$96.56 "  "$30.95 " "$49.13 "  "$18.95 "                "$276.74 "   
0001-12-18 "$61.46 "  "$30.25 " "$29.08 "  "$40.58 "                "$240.22 "   
0001-12-18 "$67.62 "  "$34.85 " "$14.54 "  "$26.72 "                "$327.11 "   
0001-12-18 "$75.78 "  "$44.55 " "$17.83 "  "$18.94 "                "$269.86 "   
0001-12-18 "$70.01 "  "$43.10 " "$27.30 "  "$9.67 "                 "$261.76 "   
0001-12-18 "$87.83 "  "$42.75 " "$10.85 "  "$37.59 "                "$331.76 "   
0001-12-18 "$56.52 "  "$42.35 " "$40.84 "  "$26.92 "                "$304.32 "   
0001-12-18 "$56.71 "  "$30.65 " "$8.86 "   "$30.91 "                "$276.56 "   
0001-12-18 "$73.39 "  "$35.55 " "$13.14 "  "$6.98 "                 "$215.33 "   
0001-12-18 "$80.95 "  "$45.10 " "$21.02 "  "$25.92 "                "$303.60 "   
0001-12-18 "$111.80 " "$36.50 " "$16.05 "  "$22.74 "                "$292.74 "   
0001-12-18 "$107.60 " "$36.00 " "$29.98 "  "$37.69 "                "$286.49 "   
0001-12-18 "$91.10 "  "$46.76 " "$19.44 "  "$38.89 "                "$298.69 "   
0001-12-18 "$70.43 "  "$48.85 " "$35.09 "  "$40.69 "                "$282.18 "   
0001-12-18 "$50.92 "  "$37.80 " "$46.55 "  "$16.35 "                "$252.40 "   
0001-12-18 "$39.78 "  "$31.90 " "$47.25 "  "$23.93 "                "$218.74 "   
0001-12-18 "$52.31 "  "$30.80 " "$64.49 "  "$19.94 "                "$283.01 "   
0002-01-18 "$78.16 "  "$35.00 " "$38.86 "  "$43.87 "                "$174.82 "   
0002-02-18 "$77.77 "  "$52.80 " "$33.69 "  "$42.87 "                "$388.99 "   
0002-03-18 "$64.44 "  "$52.05 " "$42.14 "  "$54.64 "                "$317.47 "   
0002-04-18 "$58.90 "  "$52.90 " "$67.09 "  "$15.76 "                "$263.85 "   
0002-05-18 "$61.46 "  "$33.30 " "$50.65 "  "$22.64 "                "$238.95 "   
0002-06-18 "$101.83 " "$34.90 " "$59.01 "  "$17.95 "                "$237.21 "   
           FOUNTAIN  FROZEN.FOOD GENERAL.MERCHANDISE GIFTS..and..TOYS GROCERIES 
0001-01-18 "$17.11 " "$28.30 "   "$26.89 "           "$23.26 "        "$302.02 "
0001-02-18 "$15.02 " "$39.45 "   "$23.79 "           "$0.00 "         "$234.11 "
0001-03-18 "$15.32 " "$24.62 "   "$45.01 "           "$19.99 "        "$287.40 "
0001-04-18 "$14.92 " "$51.87 "   "$9.81 "            "$1.99 "         "$322.09 "
0001-05-18 "$11.54 " "$46.60 "   "$23.57 "           "$0.00 "         "$342.95 "
0001-06-18 "$36.31 " "$55.60 "   "$87.55 "           "$0.00 "         "$283.13 "
0001-07-18 "$19.00 " "$29.88 "   "$37.49 "           "$0.00 "         "$287.77 "
0001-08-18 "$19.20 " "$39.55 "   "$34.28 "           "$0.00 "         "$177.29 "
0001-09-18 "$15.12 " "$14.03 "   "$4.47 "            "$0.00 "         "$217.43 "
0001-10-18 "$16.61 " "$34.66 "   "$17.14 "           "$0.00 "         "$149.36 "
0001-11-18 "$13.53 " "$37.48 "   "$29.13 "           "$0.00 "         "$275.43 "
0001-12-18 "$18.60 " "$15.23 "   "$27.12 "           "$2.99 "         "$274.72 "
0001-12-18 "$20.99 " "$38.02 "   "$16.62 "           "$0.00 "         "$267.74 "
0001-12-18 "$26.36 " "$60.57 "   "$44.77 "           "$0.00 "         "$289.71 "
0001-12-18 "$12.93 " "$15.23 "   "$38.46 "           "$0.00 "         "$265.04 "
0001-12-18 "$18.40 " "$9.86 "    "$22.19 "           "$0.00 "         "$273.38 "
0001-12-18 "$11.04 " "$20.43 "   "$20.85 "           "$0.00 "         "$184.70 "
0001-12-18 "$30.24 " "$13.34 "   "$27.12 "           "$0.00 "         "$332.36 "
0001-12-18 "$15.12 " "$28.40 "   "$33.16 "           "$0.00 "         "$344.73 "
0001-12-18 "$13.43 " "$14.56 "   "$33.67 "           "$0.00 "         "$227.71 "
0001-12-18 "$22.68 " "$19.51 "   "$53.96 "           "$1.09 "         "$212.07 "
0001-12-18 "$21.39 " "$22.72 "   "$51.29 "           "$16.95 "        "$272.56 "
0001-12-18 "$25.76 " "$28.20 "   "$75.05 "           "$0.00 "         "$250.95 "
0001-12-18 "$11.34 " "$43.74 "   "$31.17 "           "$2.99 "         "$252.91 "
0001-12-18 "$11.44 " "$49.94 "   "$22.09 "           "$22.44 "        "$310.68 "
0001-12-18 "$13.53 " "$24.12 "   "$46.82 "           "$0.00 "         "$313.64 "
0001-12-18 "$16.21 " "$27.50 "   "$55.25 "           "$0.00 "         "$306.07 "
0001-12-18 "$21.19 " "$37.46 "   "$40.86 "           "$0.00 "         "$244.37 "
0001-12-18 "$26.06 " "$44.19 "   "$16.89 "           "$19.95 "        "$378.91 "
0001-12-18 "$20.99 " "$21.51 "   "$21.56 "           "$0.00 "         "$247.66 "
0001-12-18 "$20.99 " "$10.05 "   "$22.70 "           "$0.00 "         "$218.87 "
0002-01-18 "$11.34 " "$56.28 "   "$17.18 "           "$14.99 "        "$270.19 "
0002-02-18 "$31.43 " "$19.82 "   "$39.64 "           "$2.18 "         "$351.09 "
0002-03-18 "$17.41 " "$39.44 "   "$88.56 "           "$0.00 "         "$283.61 "
0002-04-18 "$17.31 " "$30.78 "   "$74.73 "           "$16.95 "        "$410.91 "
0002-05-18 "$9.05 "  "$22.41 "   "$16.51 "           "$0.00 "         "$280.97 "
0002-06-18 "$13.13 " "$13.36 "   "$25.67 "           "$0.00 "         "$239.05 "
           PASTRY     PHONE.ACCES...and..ETC. PUBLICATION SNACKS     SODAS     
0001-01-18 "$62.96 "  "$6.99 "                "$1.50 "    "$282.15 " "$128.43 "
0001-02-18 "$82.67 "  "$13.98 "               "$5.75 "    "$223.22 " "$97.98 " 
0001-03-18 "$63.28 "  "$0.00 "                "$1.50 "    "$351.33 " "$146.24 "
0001-04-18 "$84.91 "  "$13.98 "               "$3.00 "    "$284.90 " "$115.39 "
0001-05-18 "$74.26 "  "$20.97 "               "$3.00 "    "$386.42 " "$107.99 "
0001-06-18 "$54.60 "  "$6.99 "                "$8.00 "    "$384.08 " "$157.34 "
0001-07-18 "$110.33 " "$6.99 "                "$0.00 "    "$246.93 " "$106.56 "
0001-08-18 "$91.19 "  "$20.97 "               "$3.00 "    "$204.66 " "$90.80 " 
0001-09-18 "$56.70 "  "$13.98 "               "$1.50 "    "$249.16 " "$109.81 "
0001-10-18 "$93.92 "  "$0.00 "                "$1.50 "    "$221.80 " "$91.00 " 
0001-11-18 "$65.65 "  "$27.96 "               "$4.50 "    "$237.58 " "$94.46 " 
0001-12-18 "$78.09 "  "$6.99 "                "$3.00 "    "$288.99 " "$92.64 " 
0001-12-18 "$44.28 "  "$41.94 "               "$8.75 "    "$269.21 " "$154.99 "
0001-12-18 "$67.49 "  "$20.97 "               "$4.00 "    "$339.23 " "$127.89 "
0001-12-18 "$88.45 "  "$6.99 "                "$0.00 "    "$232.96 " "$84.22 " 
0001-12-18 "$63.56 "  "$20.97 "               "$3.00 "    "$228.63 " "$89.21 " 
0001-12-18 "$82.58 "  "$6.99 "                "$1.50 "    "$168.06 " "$71.69 " 
0001-12-18 "$91.63 "  "$4.99 "                "$4.25 "    "$281.65 " "$125.91 "
0001-12-18 "$99.97 "  "$6.99 "                "$4.50 "    "$271.74 " "$119.06 "
0001-12-18 "$83.48 "  "$55.92 "               "$4.75 "    "$276.45 " "$113.30 "
0001-12-18 "$115.52 " "$27.96 "               "$7.00 "    "$336.85 " "$116.38 "
0001-12-18 "$73.84 "  "$33.95 "               "$6.00 "    "$236.32 " "$104.20 "
0001-12-18 "$99.56 "  "$0.00 "                "$3.00 "    "$239.80 " "$84.79 " 
0001-12-18 "$96.80 "  "$6.99 "                "$5.75 "    "$253.55 " "$97.11 " 
0001-12-18 "$104.27 " "$20.97 "               "$1.50 "    "$308.31 " "$75.60 " 
0001-12-18 "$101.83 " "$20.97 "               "$1.50 "    "$277.60 " "$95.84 " 
0001-12-18 "$74.81 "  "$20.97 "               "$5.50 "    "$270.16 " "$111.58 "
0001-12-18 "$57.46 "  "$0.00 "                "$7.00 "    "$233.27 " "$122.13 "
0001-12-18 "$71.99 "  "$0.00 "                "$10.00 "   "$236.27 " "$104.47 "
0001-12-18 "$71.85 "  "$13.98 "               "$1.50 "    "$239.16 " "$79.65 " 
0001-12-18 "$79.01 "  "$6.99 "                "$3.00 "    "$215.53 " "$100.33 "
0002-01-18 "$89.86 "  "$20.97 "               "$8.50 "    "$235.64 " "$88.55 " 
0002-02-18 "$99.89 "  "$6.99 "                "$7.25 "    "$325.05 " "$103.64 "
0002-03-18 "$63.58 "  "$62.91 "               "$7.50 "    "$312.00 " "$122.24 "
0002-04-18 "$67.97 "  "$6.99 "                "$4.00 "    "$413.77 " "$150.57 "
0002-05-18 "$58.99 "  "$13.98 "               "$4.50 "    "$162.49 " "$123.30 "
0002-06-18 "$117.48 " "$27.96 "               "$2.75 "    "$242.04 " "$88.11 " 
           TOBACCO      TOTAL       
0001-01-18 "$693.90 "   "$3,034.01 "
0001-02-18 "$631.58 "   "$2,693.91 "
0001-03-18 "$640.26 "   "$2,964.32 "
0001-04-18 "$508.76 "   "$2,822.79 "
0001-05-18 "$746.01 "   "$3,578.02 "
0001-06-18 "$717.76 "   "$3,687.26 "
0001-07-18 "$835.00 "   "$3,240.98 "
0001-08-18 "$577.71 "   "$2,445.43 "
0001-09-18 "$688.32 "   "$2,327.65 "
0001-10-18 "$682.88 "   "$2,429.34 "
0001-11-18 "$528.39 "   "$2,555.98 "
0001-12-18 "$711.59 "   "$2,918.13 "
0001-12-18 "$806.43 "   "$3,457.97 "
0001-12-18 "$581.28 "   "$3,298.37 "
0001-12-18 "$643.62 "   "$2,654.73 "
0001-12-18 "$605.77 "   "$2,478.83 "
0001-12-18 "$810.67 "   "$2,598.24 "
0001-12-18 "$740.75 "   "$3,145.54 "
0001-12-18 "$831.39 "   "$3,200.32 "
0001-12-18 "$795.44 "   "$3,184.47 "
0001-12-18 "$660.74 "   "$3,123.97 "
0001-12-18 "$689.76 "   "$2,793.73 "
0001-12-18 "$821.48 "   "$2,949.56 "
0001-12-18 "$817.48 "   "$3,148.15 "
0001-12-18 "$621.64 "   "$2,976.00 "
0001-12-18 "$865.43 "   "$3,226.49 "
0001-12-18 "$903.96 "   "$3,632.32 "
0001-12-18 "$618.92 "   "$3,033.83 "
0001-12-18 "$669.01 "   "$2,901.41 "
0001-12-18 "$599.44 "   "$2,422.37 "
0001-12-18 "$651.89 "   "$2,563.22 "
0002-01-18 "$807.10 "   "$2,981.84 "
0002-02-18 "$744.56 "   "$3,586.62 "
0002-03-18 "$600.00 "   "$3,576.79 "
0002-04-18 "$637.90 "   "$3,647.41 "
0002-05-18 "$755.85 "   "$2,676.75 "
0002-06-18 "$763.12 "   "$2,749.23 "
 [ reached getOption("max.print") -- omitted 233 rows ]

似乎还有多余的一排什么?但是我删除了一个空行,我认为这可能会导致输入不均,但这并不能解决。

0 个答案:

没有答案