Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Project Introduction
Inspired by my son’s love for everything solar system and my wanting to play with Shiny Assistant. I’ve built an app that takes your date of birth and displays your age for each of the major planets in our solar system.
< section id="how-to-use" class="level2">How to Use
Upon launching the app, you’ll see all the controls on the left hand side. Add your date of birth to automatically display your solar ages.
There’s also a toggle to switch to days calculation mode which requires a little explanation.
< section id="calculation-mode" class="level3">Calculation Mode
Year: Gives your Earth age based on a planets orbit.
Day: Gives your Earth age based on a planets rotation.
Examples of how the calculation modes work using someone born 27th May 2005.
# Use age is converted to Earth days age_difference_in_earth_days <- Sys.Date() - ymd("2005-05-27") # The Year calculation divides and floors by the number of Earth days of # a planet. # Let's use Jupiter which orbits around the Sun every ~4331 Earth days. jupiter_age_year_calc <- floor(age_difference_in_earth_days / 4331.984) |> as.numeric() # Jupiter age of 20 year old by years calculation jupiter_age_year_calc
[1] 1
# The Days calculation converts your days Earth age to a planets equivalent. # Then divides and floors by an Earth year. # Let's use Jupiter which rotates around it's axis every ~9.8 Earth hours age_difference_in_jupiter_days <- age_difference_in_earth_days / (9.8/24) jupiter_age_days_calc <- floor(age_difference_in_jupiter_days / 365.26) |> as.numeric() # Jupiter age of 20 year old by days calculation jupiter_age_days_calc
[1] 49
Venus inspired the days-based calculation with it’s day longer than it’s year. Still wrapping my head around that.
< section id="dashboard" class="level2">Dashboard
Well here it is, the Solar System Age Converter.
The app was the result of a 2 hour Shiny Assistant assisted play around, a feat I would have spent quadruple the time on. I am a fan of Shiny Assistant but I have notes:
- Functions were sometimes implemented in code without calling the library.
- It got stuck on the trickier css elements, in my case shadow-root constructed stylesheets.
- I wish a button was introduced to take me to the editor rather than typing “Open the editor”.
- I could not clear the console.
- I could use control + f but couldn’t close.
It is probable I missed a bunch of functionality in my speed run and I’ll aim to read around, see how others have fared.
< section id="acknowledgements" class="level2">Acknowledgements
Winston Chang for Shiny Assistant.
Royal Museums Greenwich for solar system information.
r-bloggers.com for the reach, platform, and content
Packages and package maintainer(s):
- lubridate | Vitalie Spinu
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.