as.date

R Read abbreviated month form a date that is not in English

孤街醉人 提交于 2019-11-28 07:44:50
问题 I have a text file that includes dates, and want to convert it to a datatable. Converting the dates such as 03-FEB-2011 can be done with data$fecha <- as.Date(data$textDate , "%d-%b-%Y") The problem is that the column is in Spanish, so I don't get Jan but Ene, or Aug but Ago. How can I change the locale so the %b abbreviation works for Spanish? Is there any other way to achieve this? 回答1: As my previous comment, here is a complete and tested answer. As I've said you have to set your locale to

R aggregate data.frame with date column

时光怂恿深爱的人放手 提交于 2019-11-28 06:15:30
问题 I have the data frame resambling the one in the below Date Expenditure Indicator 29-01-2011 5455 212 25-01-2012 5452 111 11-02-2011 365 5 I'm currently interested in summing up the Expenditure values, I'm trying to use the function below dta.sum <- aggregate(x = dta, FUN = sum, by = list(Group.date = dta$date)) but R returns the following error, Error in Summary.Date(c(15614L, 15614L, 15614L, 15614L, 15614L, 15614L, : sum not defined for "Date" objects . The Date column was previously defined

What are the “standard unambiguous date” formats for string-to-date conversion in R?

我们两清 提交于 2019-11-26 02:07:36
问题 Please consider the following $ R --vanilla > as.Date(\"01 Jan 2000\") Error in charToDate(x) : character string is not in a standard unambiguous format But that date clearly is in a standard unambiguous format. Why the error message? Worse, an ambiguous date is apparently accepted without warning or error and then read incorrectly! > as.Date(\"01/01/2000\") [1] \"0001-01-20\" I\'ve searched and found 28 other questions in the [R] tag containing this error message. All with solutions and