题目
题目

COMM_V 205 101 102 103 2025W1 In-class Exercise (ICE) 15

简答题

Again, suppose we have a vector name containing names of 50 students. grade is another numeric vector containing final marks of those students. We run the following code: dat <- tibble(name, grade) dat$grade[2] <- as.character(dat$grade[2]) is.numeric(dat$grade) The output should be

查看解析

查看解析

标准答案
Please login to view
思路分析
We start with a vector named name containing 50 student names and a numeric vector grade with their final marks. The code creates a tibble dat combining name and grade. Next, the line dat$grade[2] <- as.character(dat$grade[2]) attempts to replace the second element of the grade column with......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

What result is returned if you execute the following code? TRUE + (!FALSE) + 1L + 1

typeof(TRUE + 5L) != typeof(TRUE + 5) This will return [Fill in the blank] as an output.  

Suppose we create the vector below. v <- c(1, "2", "3", 4, 5, "6") Which of the following options will return 5? Note that in R, strings are always surrounded by quotation marks. That is, 5 is a number and "5" is a string.  Hint: Remember the coercion in a vector creation.

A little bit of an overview for the implicit coercion in Arithmetic Operations with Vectors: If the vector's data type does not fit in the arithmetic operation, R will coerce its data type similar to atomic values in the context of arithmetic operations. The order  logical --> integer --> double. Assume again that today's temperatures for the cities are given. However, suppose weather forecasts just changed. You were told that tomorrow's temperature in Canadian cities will be 2 degrees Celsius cooler than today. However, temperature in American cities will be 1 degree Celsius warmer than today. Note that we are only provided with either American or Canadian cities. What would be the tomorrow's temperature in Celsius in these cities? Complete the code below: today_temp_C - 2*(country [ Select ] = == != ! = "Canadian") + 1*(country [ Select ] = == != ! = "Canadian") You can only use logical comparison operators or arithmetic operators in each blank above. Assume that the formula above is correctly completed. Answer the following two questions regarding the data type of the segment of the the completed formula? What is the data type of the outcome of the expression in the second parenthesis when the blank there is correctly filled; That is (country XXX "Canadian") ? [ Select ] logical integer double character What is the data type of the outcome of the expression in the second term of the entire line of code when the blank there is correctly filled; That is 2*(country XXX "Canadian") ? [ Select ] logical integer double character Last two blanks are intended to show you how implicit coercion has taken place.

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!