書名: R Programming Fundamentals作者名: Kaelen Medeiros本章字數(shù): 252字更新時間: 2021-07-23 16:58:21
Activity: Creating Vectors, Lists, Matrices, and Dataframes
Scenario
You have been asked to create vectors, lists, matrices, and dataframes that store information about yourself. The expected output is as follows:

Aim
To create vectors, lists, matrices, and dataframes.
Prerequisites
Make sure that you have R and RStudio installed on your machine.
Steps for Completion
Open a new R script and save it as a file called lesson1_activityB2.R.
Create vectors for the following:
The numbers 1:10
The letters A:Z, with the first four numbers and letters alternating
Hint: type ?LETTERS into your console.
- Create lists for the following:
- The numbers 1:10
- The letters A:Z
- A list of lists:
- Your favorite foods (two or more)
- Your favorite TV shows (three or more)
- Things you like to do (four or more)
- Create matrices of numbers and letters by using the following steps:
- First, try using cbind() to combine the vector 1:10 and the vector A:Z. What happens?
- Figure out a way to combine these two into a matrix, albeit one that will be coerced to character type (despite the numeric column).
- Create dataframes using the following steps:
- Coerce your matrix solution from the previous second bullet point into a dataframe. View it and take note of the type of each variable.
- Use rbind.data.frame() to build a data frame where the rows increase by five until 25, for example, 5, 10, 15, 20, 25.
- View it and notice how ugly the column names are. Give it better names ("one" through "five") with the names() function.
推薦閱讀
- TIBCO Spotfire:A Comprehensive Primer(Second Edition)
- 電腦上網(wǎng)直通車
- CorelDRAW X4中文版平面設(shè)計50例
- Hands-On Linux for Architects
- Visual Basic從初學(xué)到精通
- 數(shù)據(jù)庫原理與應(yīng)用技術(shù)
- 計算機網(wǎng)絡(luò)技術(shù)基礎(chǔ)
- 統(tǒng)計學(xué)習(xí)理論與方法:R語言版
- Nginx高性能Web服務(wù)器詳解
- Blender 3D Printing by Example
- Docker on Amazon Web Services
- Extending Ansible
- 啊哈C!思考快你一步
- Cloud Security Automation
- 人工智能技術(shù)入門