1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
"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)"
"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)
"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)"
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)"
"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)
"Scenario: Using a vector scores (10, 15, 20, 25, 30), extract only the scores that are less than 20.",
scores[scores < 20]
"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)]"
"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)"
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)"
Scenario: Calculate the sum of all elements in the second column of matrix salesdata. Use apply().,""
apply(X=salesdata, MARGIN=2, FUN=sum)[2]
"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))"
"Scenario: Access the Units value for ""Paper"" from the inventory data frame (assuming 'Paper' is the second row).","
inventory[2, ""Units""]"
Scenario: Access the column 'Product' from the inventory data frame using the dollar sign operator.,
inventory$Product
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]
Scenario: Load a file named 'clientdata.csv' into a data frame called clientdf.,"
clientdf = read.csv(file=""clientdata.csv"")"
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)"