Question

In: Computer Science

This is R language Create a vector that contains the message part of each log entry...

This is R language

  • Create a vector that contains the message part of each log entry in logsin uppercase letters. In your solution, you might want to use the function toupper(). Simply print this vector to the console.

# Return vector with uppercase version of message elements in log entries


# Apply extract_caps function on logs

Solutions

Expert Solution

code

solution

//output

//copyable code

vapply(logs, `[[`, c('details','message'),FUN.VALUE=character(1))

toupper(vapply(logs, `[[`, c('details','message'),FUN.VALUE=character(1)))

# Apply extract_caps function on logs

extract_caps<-function(x){

toupper(x$details$message)

}

vapply(logs,extract_caps,FUN.VALUE=character(1))


Related Solutions

R programming language A) Create a function that accepts two arguments, an integer and a vector...
R programming language A) Create a function that accepts two arguments, an integer and a vector of integers. It returns the count of the number of occurrences of the integer in the input vector. 1]Input: num_count <-function ??? 2]Input: num_count(2,c(1,1,2,2,3,3)) 2] Output: 2 3] Input: num_count(1,c(1,1,2,2,3,1,4,5,5,2,2,1,3)) 3] Output : 4 B) Create a function that accepts 3 integer values and returns their sum. However, if an integer value is evenly divisible by 3, then it does not count towards the...
Use R code Create a vector V with 8 elements (7,2,1,0,3,-1,-3,4): Transform that vector into a...
Use R code Create a vector V with 8 elements (7,2,1,0,3,-1,-3,4): Transform that vector into a rectangular matrix A of dimensions 4X2 (4- rows, 2-columns); Create a matrix transpose to the above matrix A. Call that matrix AT; Calculate matrix products: A*AT and AT*A. Present the results. What are the dimensions of those two product matrices; Square matrixes sometimes have an inverse matrix. Try calculating inverse matrices (or matrixes, if you prefer) of above matrices (matrixes) A*AT and AT*A; Extend...
R Programming: create a vector for 1 to 31 and count the number of even and...
R Programming: create a vector for 1 to 31 and count the number of even and odds using ifelse()
Create a function that takes a vector of vectors as an argument. Each inner vector has...
Create a function that takes a vector of vectors as an argument. Each inner vector has 2 elements. The first element is the numerator and the second element is the denominator. Return the sum of the fractions rounded to the nearest whole number. Examples: sum_fractions({{18, 13}, {4, 5}}) ➞ 2 sum_fractions({{36, 4}, {22, 60}}) ➞ 9 sum_fractions({{11, 2}, {3, 4}, {5, 4}, {21, 11}, {12, 6}}) ➞ 11 Notes Your result should be a number not string. Code in C++...
Write a sequence of assembly language instructions to subtract each entry of an array A of...
Write a sequence of assembly language instructions to subtract each entry of an array A of five two’s complement 16-bit binary integers from the corresponding entry of an array B of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i]. Use the following data for the arrays A and B. A: 10, -15, 20, 4, -5 B: 25, -5, -30, 6, 10 please answer in...
PLEASE USE ASSEMBLY LANGUAGE The database students.db contains student records. Each record contains a name (30B...
PLEASE USE ASSEMBLY LANGUAGE The database students.db contains student records. Each record contains a name (30B ASCII), student ID (9B ASCII), 3 grades out of 100 (3B integers), and a letter grade (1B ASCII). For the file students.db described above, assume all records are ordered alphabetically based on the name field. A record for a new student has been entered and stored in memory. Determine how to insert the new record into the database (Hint: use string compares to determine...
The following R code sorts each vector in a list (lst) and stores the new list...
The following R code sorts each vector in a list (lst) and stores the new list in lst1. The code uses a for loop. lst <- list(c1=sample(1:10,10,replace=TRUE),c2=sample(1:20,10,replace=TRUE),c3=sample(1:10,8,replace=TRUE)) lst1 <- list() for(i in 1:length(lst)) { lst1[[i]] <- sort(lst[[i]]) } lst1 Which of the following options does the same thing as the given R code above ? lst <- list(c1=sample(1:10,10,replace=TRUE),c2=sample(1:20,10,replace=TRUE),c3=sample(1:10,8,replace=TRUE)) library(purrr) lst1 <- map(lst,sort) lst1 lst <- list(c1=sample(1:10,10,replace=TRUE),c2=sample(1:20,10,replace=TRUE),c3=sample(1:10,8,replace=TRUE)) library(purrr) lst1 <- map_dbl(lst,sort) lst1 None of the given options lst <- list(c1=sample(1:10,10,replace=TRUE),c2=sample(1:20,10,replace=TRUE),c3=sample(1:10,8,replace=TRUE)) library(purrr)...
QUESTION: In each part, find a formula for a vector field consistent with the description. Provide...
QUESTION: In each part, find a formula for a vector field consistent with the description. Provide at least one numeric example showing the consistency of the formula and the description (an example follows the descriptions). 1.All vectors are parallel to the x-axis and all vectors on a vertical line have the same magnitude. 2.All vectors point toward the origin and have constant length. 3.All vectors are of unit length and are orthogonal to the position vector at that point.
Suppose that each component of a certain vector is doubled. Part A By what multiplicative factor...
Suppose that each component of a certain vector is doubled. Part A By what multiplicative factor does the magnitude of the vector change? Express your answer using one significant figure. A2 = nothing A1 SubmitRequest Answer Part B By what multiplicative factor does the direction angle of the vector change? Express your answer using one significant figure. θ2 = nothing θ1
Data Structures for R studio Create a numeric vector containing 10 random numbers ranging from 1...
Data Structures for R studio Create a numeric vector containing 10 random numbers ranging from 1 to 10000. Validate that the object you created is a vector Give an example of where you might find this in a biologicall data set. Create a 10-member list containg both numeric and character data. Validate that the object you created is a list Give an example of where you might find this in a biologicall data set. Create a data frame that relates...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT