osx - julian dates as.date -


i trying run simple regression in r (mac osx), see if level of environmental certification has improved on time - among other things. data downloaded offers level 1-4, , dates in 1-mar-12 format. can't seem r convert dates, , keep getting same error message. variables same length.

$ certification_date: chr  "1-aug-11" "1-aug-11" "1-aug-11" "1-jul-11" ...  jday<-as.date('certification_date',format='%d-%b-%y',"%j") mod <- lm(level_number ~ jday, data=data)  error in model.frame.default(formula = level_number ~ jday, data = data,  :    variable lengths differ (found 'jday')  summary(jday) min. 1st qu.  median    mean 3rd qu.    max.    na's    na      na      na      na      na      na     "1"  

can spot i've gone wrong?

you should remove quotes around certification_date mentioned in comment, %b abbreviated month name in current locale. can problem locals. here present independent-local solution:

## current local time loc <- sys.getlocale('lc_time')   ## set local english , since %b local dependent  sys.setlocale('lc_time','english') jday <-as.date(certification_date,format='%d-%b-%y',"%j") sys.setlocale('lc_time',loc) 

the result is:

jday [1] "2011-08-01" "2011-08-01" "2011-08-01" "2011-07-01" 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -