-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem of calculating the age #5
Comments
It looks fine. Did you run the chunk twice and convert your DateOfBirth twice? > dob <- "9 February 1951"
> dob.as.date <- as.Date( dob, format="%d %B %Y" )
> dob.as.date
[1] "1951-02-09"
> Sys.Date()
[1] "2019-04-20"
> time.diff <- Sys.Date() - dob.as.date # in days
> time.diff
Time difference of 24907 days
> as.numeric( time.diff ) / 365 # in years
[1] 68.23836 |
Just i n case, use: Sys.setlocale("LC_TIME", "English") Before making the date computation. Your computer may have a setting different than English. Please, let us know it is working well. |
It's giving you an error when you are trying to set the locale time. Can you type It's better if you share your code directly as text instead of a screen shot because it's easier for us to try the code to see where it might be broken. > sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tigris_0.7 geojsonio_0.6.0 sp_1.3-1 |
I tried this code and it shows something below, actually I think that kind of problem does not show up after I changed my system language of the computer to English. Matrix products: default locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
I can now run these code without the code |
I wrote the code to calculate the age of a person, but R shows me NA, what is the problem? I created the list and the list showed nothing wrong.
The text was updated successfully, but these errors were encountered: