How to determine the zodiac symbol in R? -


i did statistics today using excel , r. part of work requires determine zodiac symbol according date of birth. did in excel:

sample data:

dob 25-jan-1985 25-jul-1983 28-aug-1982 24-feb-1984 13-jan-1985 24-jan-1982 15-feb-1984 14-oct-1983 08-sep-1984 04-mar-1983 04-apr-1984 31-mar-1985 04-aug-1984 29-jan-1984 20-jul-1984 ... 

here rule determine zodiac symbols:

dec. 22 - jan. 19 - capricorn  jan. 20 - feb. 17 - aquarius  feb. 18 - mar. 19 - pisces  march 20 - april 19 - aries  april 20 - may 19 - taurus  may 20 - june 20 - gemini  june 21 - july 21 - cancer  july 22 - aug. 22 - leo  aug 23 - sept. 21 - virgo  sept. 22 - oct. 22 - libran  oct. 23 - nov. 21 - scorpio  nov. 22 - dec. 21 - sagittarius 

excel formula:

=lookup(--text(a2,"mdd"),{101,"capricorn";120,"aquarius";219,"pisces";321,"aries";420,"taurus";521,"gemini";621,"cancer";723,"leo";823,"virgo";923,"libran";1023,"scorpio";1122,"sagittarius";1222,"capricorn"}) 

i'm wondering how in r? data.table great, possible figure out in data.table?

assuming data called dat.

first, convert date format:

dat$dob <- as.date(dat$dob, format = "%d-%b-%y") 

then use zodiac function desctools, mentioned @josh in comment:

library(desctools) dat$zodiac <- zodiac(dat$dob) dat 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -