I am primarily a Python programmer by profession, but I'm still studying R. I have a data problem here , but I will give a small example of the problem below.
FunctionR complete.cases()should return a logical vector indicating which rows of the test object (s) do not contain NA values.
df <- data.frame(val1=c(1, 2, NA, 4),
val2=c("12:00", "10:30", "09:15", "05:00"))
print(df)
print(length(df$val1) == length(df$val2))
complete.cases(df)
This works as expected: one value Falsecorresponding to value NAin df$val1.
I ran into a problem when after converting a character vector to a vector POSIXltthrough strptime, it complete.casesno longer works due to the following error:
Error in complete.cases(df) : not all arguments have the same length.
For instance:
df$val2 <- strptime(df$val2, format="%H:%M")
print(df)
print(length(df$val1) == length(df$val2))
complete.cases(df)
, df$val1 df$val2 . - ? complete.cases , strptime?
, ( , strptime), , complete.cases .
:
- R 3.1.1 (2014-07-10) - " "
- R Studio Version 0.98.1087
- Windows 7