tibble [2,201 × 13] (S3: tbl_df/tbl/data.frame)
schedtime : num [1:2201] 1455 1640 1245 1715 1039 ...
carrier : chr [1:2201] "OH" "DH" "DH" "DH" ...
deptime : num [1:2201] 1455 1640 1245 1709 1035 ...
dest : chr [1:2201] "JFK" "JFK" "LGA" "LGA" ...
distance : num [1:2201] 184 213 229 229 229 228 228 228 228 228 ...
date : chr [1:2201] "37987" "37987" "37987" "37987" ...
flightnumber: num [1:2201] 5935 6155 7208 7215 7792 ...
origin : chr [1:2201] "BWI" "DCA" "IAD" "IAD" ...
weather : num [1:2201] 0 0 0 0 0 0 0 0 0 0 ...
dayweek : num [1:2201] 4 4 4 4 4 4 4 4 4 4 ...
daymonth : num [1:2201] 1 1 1 1 1 1 1 1 1 1 ...
tailnu : chr [1:2201] "N940CA" "N405FJ" "N695BR" "N662BR" ...
$ delay : chr [1:2201] "ontime" "ontime" "ontime" "ontime" ...
Problem :- Code and Errors
light_dataset$deptime <- hm(sprintf("%04d",flight_dataset$deptime))
Error in sprintf("%04d", flight_dataset$deptime) :
invalid format '%04d'; use format %s for character objects
View(flight_dataset)
?sprintf()
flight_dataset$deptime <- sprintf("%02d",flight_dataset$deptime)
Error in sprintf("%02d", flight_dataset$deptime) :
invalid format '%02d'; use format %s for character objects
View(flight_dataset)flight_dataset$date <- as.Date(flight_dataset$date, format = "%y%m%d")
Error in if (nchar(current) > nchars) { :
missing value where TRUE/FALSE needed
print(flight_dataset$date)
class(flight_dataset$schedtime)
[1] "numeric"
library(lubridate)
flight_dataset$schedtime <- hm(sprintf(""%04d",flight_dataset$numeric_schedtime))
Error: unexpected input in "flight_dataset$schedtime <- hm(sprintf(""%04d",flight_dataset$numeric_schedtime))"
View(flight_dataset)flight_dataset$schedtime <- hm(sprintf("%O4d",flight_dataset$schedtime))
Error in sprintf("%O4d", flight_dataset$schedtime) :
invalid format '%O4d'; use format %f, %e, %g or %a for numeric objects
View(flight_dataset)
Please help me ...I am a beginner and learning R