I am running some analysis code in R studio and on my Mac I get an error that prevents me continuing, but when I run the same code on a PC I only get a warning, which then allows me to continue with the analysis.
convert.dates <- function(data, columns, format="%Y-%m-%d %H:%M:%S") {
if (length(columns) == 1) {
posdates <- data.frame(strptime(data[, columns], format))
names(posdates) <- columns
} else
posdates <- as.data.frame(apply(data[, columns], 2, strptime, format))
data <- data[, -match(columns, names(data))]
data.frame(data, posdates)
}
recdat$datetime <- as.character(strptime(recdat$datetime, "%Y:%m:%d %H:%M:%S"))
recdat <- convert.dates(recdat, "datetime")
Mac error code: Error in strptime(data[, columns], format) : input string is too long
PC warning: row names were found from a short variable and were discarded
Why might these be different and how can I ultimately avoid receiving the error?
`structure(list(placeID = c("SHPP9", "SHPP9", "MAPP4", "MAPP4",
"MAPP4", "MAPP4", "HAPP15", "HAPP15", "HAPP15", "DEPP2"), fileID = c("IMG_0086_grid_compass.JPG",
"IMG_0089_grid_compass.JPG", "IMG_0146_grid_compass.JPG", "IMG_0149_grid_compass.JPG",
"IMG_0152_grid_compass.JPG", "IMG_0155_grid_compass.JPG", "IMG_2671_grid_compass.JPG",
"IMG_2673_grid_compass.JPG", "IMG_2676_grid_compass.JPG", "IMG_0008_grid_compass.JPG"
), datetime = c("2019:06:01 02:59:22", "2019:06:01 02:59:23",
"2019:06:06 00:45:32", "2019:06:06 00:45:33", "2019:06:06 00:45:49",
"2019:06:06 00:45:50", "2019:06:07 23:05:46", "2019:06:07 23:05:47",
"2019:06:07 23:05:48", "2019:06:10 22:29:47"), time = c(0.782634725415124,
0.78270744746729, 31.6146031824166, 31.6146759044688, 31.6158394573035,
31.6159121793556, 43.7456595925075, 43.7457323145597, 43.7458050366119,
62.438208603419), species = c("Civet", "Civet", "Civet", "Civet",
"Civet", "Civet", "Civet", "Civet", "Civet", "Civet"), absangle = c(0.233516621633944,
0.22839855680029, 0.0168248958289925, 0.112940296923411, 0.00228507404113898,
0.0993839863232428, 0.221094165650959, 0.180608750801481, 0.12502377891255,
0.269755048548634), distance = c(6.25093914350113, 5.90579526441211,
3.35416246724451, 3.5986715069128, 3.74569894202013, 3.2687423704556,
8.63358410851277, 9.12459363127179, 9.03891669576689, 3.70247933884298
)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame"
))`