- R Programming Fundamentals
- Kaelen Medeiros
- 260字
- 2021-07-23 16:58:19
Setting up a New Project
Let us now set up a new project that we will use throughout the book. We will create an R project, script, custom function, and save an image of the global environment. Follow the steps given below:
- Open RStudio.
- Navigate to File | New Project to start a new project:
- Start with a new directory and save it in a place on your computer that makes sense to you.
- Save the project with the name IntroToDSwRCourse.
- Check the working directory using the getwd() function and be sure it's the same folder you chose to save your project in.
- Start a new script. Save the script with the filename lesson1_exercise.R.
- Write a custom function, area_rectangle(), which calculates the area of a rectangle, with the following code:
area_rectangle <- function(length, width){
length * width
}
- Try out area_rectangle() with the following sets of lengths and widths:
- 5, 10
- 80, 7
- 48209302930, 4
The code will be as follows:
area_rectangle(5, 10)
area_rectangle(80, 70)
area_rectangle(48209302930, 4)
- Save an image of the global environment for later; name the file introToDSwR.RData.
Output: The output you get after executing the getwd() function will be the folder on your computer that you have chosen to save your project in.
The area of the rectangle with different lengths will be provided as follows:

R and RStudio will be our main tools throughout this book for statistical analysis and programming. We've now seen how to create a new project, a new R script, and how to save a workspace image for use later.
推薦閱讀
- 機(jī)器學(xué)習(xí)實(shí)戰(zhàn):基于Sophon平臺(tái)的機(jī)器學(xué)習(xí)理論與實(shí)踐
- 深度學(xué)習(xí)中的圖像分類與對(duì)抗技術(shù)
- CorelDRAW X4中文版平面設(shè)計(jì)50例
- Hadoop Real-World Solutions Cookbook(Second Edition)
- 自動(dòng)控制理論(非自動(dòng)化專業(yè))
- 嵌入式操作系統(tǒng)
- 網(wǎng)絡(luò)安全與防護(hù)
- 分?jǐn)?shù)階系統(tǒng)分析與控制研究
- LAMP網(wǎng)站開(kāi)發(fā)黃金組合Linux+Apache+MySQL+PHP
- Hadoop應(yīng)用開(kāi)發(fā)基礎(chǔ)
- Dreamweaver CS6中文版多功能教材
- IBM? SmartCloud? Essentials
- 生成對(duì)抗網(wǎng)絡(luò)項(xiàng)目實(shí)戰(zhàn)
- 機(jī)器人制作入門(第4版)
- FreeCAD [How-to]