Scenario Based Unit 2 503

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/15

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

16 Terms

1
New cards

"Scenario: A company tracked 5 days of sales: 120, 155, 98, 210, and 180 units. Create a vector dailysales to store this data.","

dailysales = c(120, 155, 98, 210, 180)"

2
New cards

"Scenario: Create a vector named stockprices that starts at $25.00, ends at $30.00, and has 7 equally spaced values.",""

stockprices = seq(from=25.00, to=30.00, length=7)

3
New cards

"Scenario: You need a list of ID numbers from 1 to 100, but only for every fifth number (1, 6, 11, …). Create the vector fiveids.","

fiveids = seq(from=1, to=100, by=5)"

4
New cards

Scenario: The number '999' needs to be used as a placeholder for missing data exactly 50 times. Create the vector missingdata.,

"missingdata = rep(x=999, times=50)"

5
New cards

"Scenario: You have a vector temp with values (20, 25, 18, 22). Check if any of these temperatures are greater than 24.",

any(temp > 24)

6
New cards

"Scenario: Using a vector scores (10, 15, 20, 25, 30), extract only the scores that are less than 20.",

scores[scores < 20]

7
New cards

"Scenario: From the vector employees (Tom, Sue, Mike, Dan, Amy, Leo), remove the 2nd, 4th, and 6th names to create a new vector.","

employees[-c(2, 4, 6)]"

8
New cards

"Scenario: Combine the vectors mathscore (85, 90, 78) and sciencescore (88, 92, 80) side-by-side into a matrix named gradesmat.","

gradesmat = cbind(mathscore, sciencescore)"

9
New cards

Scenario: You have a matrix quarterlyrevenue and want to find the maximum revenue for each row (each quarter). Use apply().,"

apply(X=quarterlyrevenue, MARGIN=1, FUN=max)"

10
New cards

Scenario: Calculate the sum of all elements in the second column of matrix salesdata. Use apply().,""

apply(X=salesdata, MARGIN=2, FUN=sum)[2]

11
New cards

"Scenario: Create a data frame inventory with columns for Product (Pen, Paper) and Units (100, 50).","

inventory = data.frame(Product = c(""Pen"", ""Paper""), Units = c(100, 50))"

12
New cards

"Scenario: Access the Units value for ""Paper"" from the inventory data frame (assuming 'Paper' is the second row).","

inventory[2, ""Units""]"

13
New cards

Scenario: Access the column 'Product' from the inventory data frame using the dollar sign operator.,

inventory$Product

14
New cards

Scenario: A list projectfiles contains a data frame dfraw and a vector vdate. Access the third element of the vdate vector within the list.,

projectfiles$vdate[3]

15
New cards

Scenario: Load a file named 'clientdata.csv' into a data frame called clientdf.,"

clientdf = read.csv(file=""clientdata.csv"")"

16
New cards

Scenario: Export the clientdf data frame to a file called 'processeddata.csv' and explicitly prevent the row names from being saved.,

"write.csv(x=clientdf, file=""processeddata.csv"", row.names=FALSE)"