bike3 <- read.csv("bike_sharing_data.csv")
Business Intelligence (BI) can be an umbrella term that combines architectures, tools, databases, analytical tools, applications and methodologies. Its major objective is to enable interactive access to data, to enable manipulation of data, and to give ability to conduct appropriate analyses. Specifically, we approach BI by analyzing historical and current data, situations, and performances, and get valuable insights that enable them to make more informed and better decisions.
Answer: True
| Data structure | Correct description |
|---|---|
| Atomic vector | It contains a sequence of values of the same data type. And you could use the c() function to denote. |
| Matrix | A two-dimensional structure made of the same data type. |
| List | A two-dimensional structure made of the same data type. |
| Data frame | A list of vectors, possibly of different data types among vectors, but with all vectors (or columns) of the same length. A data frame has nrow(), ncol() or length(), rownames(), and colnames() or names(). |
A function call consists of the function name followed by one or more argument within parentheses.
You can check a function’s documentation by typing ?function_name (e.g., typing ?read.table() in the console, and it will return its description, usage, arguments, and example code.)
When calling the function, you could either match the arguments by their positions, or by their names. Note that some arguments may have default values if you not specify their values in the function call.
Answer: True
The questions below use the following dataset (available for download via Supporting Materials > Datasets in Bb):
bike_sharing_data.csv
bike_sharing_data.txt
At the end of this assignment page, you are required to upload a knitted .pdf or .docx file that documents your code and results for the questions below. In your knitted file, please clearly indicate the question number and include a brief description of the task before each corresponding code chunk.
Which of the following code would be correct to extract the bike sharing datasets in R?
This is a multiple answer question, select all that apply.
Hint: use the Help menu to understand the functions or directly try running the code in RStudio.
Option A
bike2 <- read.table(“bike_sharing_data.txt”, sep=“, header=TRUE)
Option B
bike4 <- read.delim(“bike_sharing_data.txt”)
Option C
bike3 <- read.csv(“bike_sharing_data.csv”)
Option D
bike1 <- read.table(“bike_sharing_data.csv”, sep=“,”, header=TRUE)
Answer: A, B, C, and D.
What is the total number of observations and variables for the bike sharing dataset?
Option A
17950, 11
Option B
11, 17950
Option C
13, 17379
Option D
17379, 13
dim(bike3)
## [1] 17379 13
Answer: Option D — 17379, 13.
If you import the bike sharing dataset in R using the above selected code option(s) (base R approaches) in Q4, what is data type of humidity perceived by R?
Note the result will be different if you use the manual data import option or use an external package’s function in RStudio.
Option A
character
Option B
integer
Option C
numerical
Option D
factor
str(bike3)
## 'data.frame': 17379 obs. of 13 variables:
## $ datetime : chr "1/1/2011 0:00" "1/1/2011 1:00" "1/1/2011 2:00" "1/1/2011 3:00" ...
## $ season : int 1 1 1 1 1 1 1 1 1 1 ...
## $ holiday : int 0 0 0 0 0 0 0 0 0 0 ...
## $ workingday: int 0 0 0 0 0 0 0 0 0 0 ...
## $ weather : int 1 1 1 1 1 2 1 1 1 1 ...
## $ temp : num 9.84 9.02 9.02 9.84 9.84 ...
## $ atemp : num 14.4 13.6 13.6 14.4 14.4 ...
## $ humidity : chr "81" "80" "80" "75" ...
## $ windspeed : num 0 0 0 0 0 ...
## $ casual : int 3 8 5 3 0 0 2 1 1 8 ...
## $ registered: int 13 32 27 10 1 1 0 2 7 6 ...
## $ count : int 16 40 32 13 1 1 2 3 8 14 ...
## $ sources : chr "ad campaign" "www.yahoo.com" "www.google.fi" "AD campaign" ...
Answer: Option A — character.
What is the value of season in row 6251? (Hint: you could use the indexing technique to retrieve the corresponding row and/or column)
Option A
2
Option B
3
Option C
1
Option D
4
bike3$season[6251]
## [1] 4
Answer: Option D — 4.
How many observations have the season as winter?
Hint: you could use table() to derive a contigency table and observe its count. Click the hyperlink above to see which number represents winter.
Option A
4232
Option B
4242
Option C
4409
Option D
4496
dim(subset(bike3, season == 4))
## [1] 4232 13
Answer: Option A — 4232.
If you need to add multiple conditions to obtain a subset of a data frame (e.g., observations in winter season and/or have high wind speed), you can use the logical operators such as & or | between the conditions. And within a condition, %in% could be used to denote a choice in a vector.
Answer: True.
How many observations having “High” wind thread condition or above during winter or spring?
You may reference the lowest threshold of “High” from National Weather Services.
Hint: Click the hyperlink above to see which number represents high wind thread condition.
Option A
64
Option B
63
Option C
46
Option D
48
dim(subset(bike3, windspeed >= 40 & season %in% c(1, 4)))
## [1] 46 13
Answer: Option C — 46.