Published: 26 May 2018 › Updated: 26 May 2018

R basic, 'for loop' Calculating Leap Year
- Logical meaning
- & - > and
- | - > OR
- ! - > Not
> for(year in 2000:2018){
+ if (year%%4==0 & year%%100!=0 | year%%400==0){
+ result <- paste(year, "is a leap year.")
+ print(result)
+ }
+ else{
+ result <- paste(year, "is not a leap year.")
+ print(result)
+ }
+ }
[1] "2000 is a leap year."
[1] "2001 is not a leap year."
[1] "2002 is not a leap year."
[1] "2003 is not a leap year."
[1] "2004 is a leap year."
[1] "2005 is not a leap year."
[1] "2006 is not a leap year."
[1] "2007 is not a leap year."
[1] "2008 is a leap year."
[1] "2009 is not a leap year."
[1] "2010 is not a leap year."
[1] "2011 is not a leap year."
[1] "2012 is a leap year."
[1] "2013 is not a leap year."
[1] "2014 is not a leap year."
[1] "2015 is not a leap year."
[1] "2016 is a leap year."
[1] "2017 is not a leap year."
[1] "2018 is not a leap year."
Leave R basic, 'for loop' Calculating Leap Year to:
Read more #load0file0r posts
Best Posts From mimiming
We have not curated any of mimiming's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From mimiming
- python crawling 삽질3
- python 크롤링 삽질2
- python 크롤링 삽질
- Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
- Install Tensorwflow with Pycharm
- All about notepad++ 64bit plugin manager
- R Basic, Lists of Packages & Functions for loading files
- R basic, 'for loop' Calculating Leap Year
- day 1 ) bithum api r