Stupid Way To Learn R programming (1)

Source: Internet
Author: User
In the legend of Yi Tian's dragon slaughter, one person calls it a toggle. This person does not rely on his or her mind to do his or her work, but only on imitating others' moves, from the outside to the inside. Practice programming also has such a method, not to look at text descriptions, but to observe and imitate others' Code . In this way, you can learn programming from outside. Zed Shaw, author of the stupid way to learn python, said that this stupid way is actually easier to get started. Yang zhiping is in his Article The article "How to learn a new programming language" also says that beginner programming requires a lot of deliberate exercises in the learning area and less theoretical books.


Another Ted Educator also talked about this story. He threw a computer in a remote Indian village and ignored it, children who have not yet studied can learn English and computer usage on their own. In fact, the human brain is very good at self-exploration and learning. Therefore, this series of tutorials only feature a small amount of comments to the Demo code. By repeatedly imitating and practicing the changes and results of the code, you can understand its meaning and lay a solid foundation for programming.


Each article in this series aims to solve the problem of a project Euler by programming in the r language. Project Euler is a series of computer programming challenges from easy to difficult. It provides a platform to inspire us to solve the problem. I am writing this tutorial for three purposes: one is for fun, the other is to improve the programming level, and the third is to demonstrate the instructions to provide the required R beginners. In addition, I learned from R-blogger that two senior engineers have used R to calculate the project Euler. You can also refer to their articles (blog 1 and blog 2 ).

Let's go

 # Prepare a knowledge exercise and enter the observation result row by row on the R Console 
1 : 10
10 : 1
X <- 1 : 10
Print ( X )
Sum ( X )
X> 5
X [ X> 5 ]
X> 5 & X < 8
X> 8 | X < 3
10 % 3
9 % 3
X % 3
X % 3 = 0
X [ X % 3 = 0 ]

# Project Euler 1
# Locate all the numbers that can be divisible by 3 or 5 under 1000 and add them
X <- 1 : 999
Sum ( X [ X % 3 = 0 | X % 5 = 0 ])
 
The final number is 233168. I feel that my solution is more representative of R than others. If you have any comments, you may wish to give me more advice.




From data science and R language http://xccds1977.blogspot.com/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.