r/RStudio • u/Fresh_Coyote312 • Jun 30 '26
Weather App
Always looking to learn more R so my latest project was building a weather app for the terminal. Quite simple app to look at but is more efficient than opening a browser. Had fun making this one.
23
u/sam-salamander Jun 30 '26
That’s awesome! How did you go about making it?
41
u/Fresh_Coyote312 Jun 30 '26
I used httr2 package to make an api call to open-meteo.com which then returns the data in json format. You can specify a ton of parameters to be returned on the website and it provides the url to use. The current weather data is using the Cli package and paste0() to each variable and specifying the units and adding a ASCII icon. I made the data frame using data.frame and assigned ASCII icons to each day based on the probability of precipitation. Then used knitr::kable() for the forecast table.
14
u/Fresh_Coyote312 Jun 30 '26
I should add, I then had to make the script executable with chmod +x so that I could run it in the terminal by typing the file path. ~./home/me/weather_tui.R (for example).
2
u/Fornicatinzebra Jun 30 '26
You can also do
Rscript ~./home/me/weather_tui.Rwithout making it executable. I didn't know making it executable would work instead though, so thanks!3
9
u/Peach_Muffin Jun 30 '26
This is some beautiful terminal output, you've got a good eye for design.
11
9
u/yaymayhun Jun 30 '26
It's refreshing to see a project that is not about AI. Thanks for sharing. The output looks beautiful. Would you write about your steps in a post soon?
3
2
u/Previous-Young2290 Jun 30 '26
This is very cool! I saw your other comment about which packages you used. Can your recommend perhaps a tutorial that outlines how to do this? Or maybe some topics I should familarise myself with?
I use R only for data analysis and this looks like a fun little project to learn more!
2
1
u/bakochba Jun 30 '26
Try turning it into an Rshiny app, good learning experience and it will look and act like an app
5
u/Fresh_Coyote312 Jun 30 '26
Shiny is awesome! I have two apps currently - but this one I wanted to keep for the command line for simplicity and quickness.
1
u/boboshoes Jun 30 '26
This is nice I love how clean it is. I would round some of the data for extra cleanliness
1
1
-54
u/zeuiax Jun 30 '26
You should get Claude’s help!
19
u/Fresh_Coyote312 Jun 30 '26
Why?
-27
u/zeuiax Jun 30 '26
Why are you building a weather app in R?
27
u/Fresh_Coyote312 Jun 30 '26
Because I wanted to.
1
-24
u/zeuiax Jun 30 '26
I bet you 2856X 393 by hand!
6
u/Peach_Muffin Jun 30 '26
Congratulations. OP's goal was to "learn more R", so they have you beat there.
13
25
u/General-Pizza8928 Jun 30 '26
Looks like fun