R Programming Тест Upwork

What is the use of the doBY package?

defines the desired table using function and model formula
defines the desired view using function and model formula
defines the desired controller using function and model formula
defines the desired data using function and class formula

What would the following code print ?
> x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
> ncol(x)

2
4
7
1

Which function gives the structure of a data frame “df”?

describe(df)
str(df)
df.structure()
summary(df)

In which of the following is HousePrice a data frame?
(1) HousePrice <- data.frame(home=statef, postCode=zip, price=fee)
(2) HousePrice <- read.table("house.data")
(3) HousePrice <- scan("house.data", list("", 0, 0))

1
2
3
1 and 2
2 and 3
1, 2 and 3

How can you merge two dataframes in R?

using cbind () functions
using the merge () function on common rows or columns
Using combine() function
Both 1 and 2

___regression is used to predict the binary outcome from the given set of continuous predictor variables?

Homogeneity
Logistic
Parametric  
Multivariate

What is the difference between matrix and dataframe?

Dataframe can contain only similar type of data but matrix can contain different types of data.
Dataframe can contain different types of data but matrix can contain only similar types of data
Dataframe and matrix are the same.
None of the mentioned.

What are the row names of the data frame?
Note: There may be more than one right answer.

names(dataset)
colnames(dataset)
row.names(dataset)
rownames(dataset)

What are the column names of the dataset?
Note: There may be more than one right answer.

names(dataset)
colnames(dataset)
row.names(dataset)
rownames(dataset)

Melt is used to convert wide data to _____ data?

long
dcast
variable
infr

Which code will rename the field old_name to new_name in the data frame called data?

colnames(data)[colnames(data)=="old_name"] <<- "new_name"
colnames(data)[colnames(data)=="old_name"] <- "new_name"
colnames(data)[colnames(data)=="old_name"] >- "new_name"
colnames(data)[colnames(data)="old_name"] <- "new_name"

While creating a data frame, the variables must have  __ length?

Same
Different
does not matter
None

What is the output of the following command?
> 2*1:10

[1] 2 3 4 5 6 7 8 9 10
[1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
[1] 2 4 6 8 10 12 14 16 18 20
[1] 2 4 6 8 10
[1] 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

What is the correct way of converting a factor to integer in R?

x <- factor(c(0, 4, 3, 3, 4))
str(x)

x1 = as.numeric(x)
str(x1)

a2 = as.numeric(as.character(a))
str(a2)

a2 = as.numeric(as.factor(a))
str(a2)

In an R list, '[[...]]' is ......

a general sub scripting operator.
the operator used to select a single element.
the assignment operator.
None of the above   ?

Which of the following determines the least-squares regression line ?

histo()
lm
barlm()
All of the mentioned

What is the output of the following commands?
> x <- c(1, 2)
> y <- c(x, 0, x)
> z <- 2*x + y + 1
> z

[1] Inf
[1] 4 7
[1] 4 7 3 5 6
[1] 4 7 3 0 0
[1] 4 7 3 4 7
Error

Does the following expression throw an error?
f2 <- function(a, b) {
  a * 10
}
f2(10, stop("This is not an error!"))

Yes
No
It depends.
Sometimes.

Point out the correct statement.

split() takes elements of the list and passes them as the first argument of the function you are applying
You can use tsplit() to evaluate a function single time each with a same argument
Sequence of operations is sometimes referred to as “map-reduce”
None of the mentioned

Which statement makes a mosaic plot ?

histogram()
mosaicplot()
bar()
plot-mosaic()

Which of the following is a valid body of split function ?

function (x, f)
function (x, drop = FALSE, …)
function (x, f, drop = FALSE, …)
All of the mentioned

What is the result of the following code?
> a <- array(c(0:1, 1:0), dim=c(2,2))
> a %*% a

[1] 1

     [,1]
[1,]    1

     [,1] [,2]
[1,]    0    1
[2,]    1    0

     [,1] [,2]
[1,]    1    0
[2,]    0    1

[1] 2

[1] 10

     [,1] [,2]
[1,]    0    0
[2,]    0    0

     [,1] [,2]
[1,]    1    1
[2,]    1    1

What would be the output of the following code ?
> x <- 1:4
> x > 2

1 2 3 4
FALSE FALSE TRUE TRUE
1 2 3 4 5
All of the mentioned

What is the result of the following R code?
> a <- array(0:7, dim=c(2,2,2))
> b<-a%*%a
> b[1]

0
4
16
25
36
49
98
140

Which of the following is lattice command for producing a scatterplot ?

plot()
lm()
xyplot()
All of the mentioned

Which of the following is lattice command for producing boxplots ?

plot()
bwplot()
xyplot()
All of the mentioned

What is the output of the following code?
> x <- c(0, 1, 2, 3, 4, 5, 6, 7)
> dim(x) <- c(2,2,2)
> x[1,1,2]

[1] 0
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7

How do you obtain the transpose of a matrix m in R?

t(m)
transpose(m)
m.t()
m.transpose()

____ loops over a list and evaluate a function on each element.

apply()
lapply()
sapply()
mapply()

Identify which of the following expressions will give an error in R:

_abc <- 1
"a + b" <- 1
"    " <- 1
":)" <- 1

What is the output of the following expression?
num <- 5; res <- 1; for (i in 1:num) { if (i%%2 == 0) {res <- res * i}}; res

1
5
8
20
60
120

What is the difference between seq(4) and seq_along(4)?

seq(4) produces a vector from 1 to 4 (c(1, 2, 3, 4)),  and seq_along(4) produces a vector of length(4), or 1 (c(1))
seq(4) produces a vector from 1 to 3 (c(0, 1, 2, 3)),  and seq_along(4) produces a vector of length(4), or 0 (c(0))
seq(4) produces a vector from 0 to 4 (c(1, 2, 3, 4)),  and seq_along(4) produces a vector of length(4), or 1 (c(1))
None of the above

fun1 <- function(data, data.frame, graph=TRUE, limit=20) { ... [ function body omitted] ... }
Which of the following does NOT involve a valid invocation of this function?

ans <- fun1(d)
ans <- fun1(d, df)
and <- fun1(d, df, limit=10)
None of the above

Point out the correct statement.

lapply() takes elements of the list and passes them as the first argument of the function you are applying
You can use lapply() to evaluate a function multiple times each with a different argument
Functions that you pass to lapply() may have other arguments
None of the mentioned

Which function is used to generate factor levels?

gen_levels()
gl()
gen_fact_levels()
factor_levels()

uniPlot uniforms and customizes plots of packages ............  ,   .......... and lattice?

uniCox, graphics
ggplot2, graphics
uniPlot, ggplot2
graphics, uniPlot

What is the result of the following R code?
> x <- c(0, 1, 2, 3, 4, 5, 6, 7)
> dim(x) <- c(2,2,2)
> x[,2,]

     [,1] [,2]
[1,]    0    4
[2,]    2    6

     [,1] [,2]
[1,]    1    5
[2,]    3    7

     [,1] [,2]
[1,]    0    4
[2,]    1    5

     [,1] [,2]
[1,]    0    2
[2,]    1    3

     [,1] [,2]
[1,]    2    6
[2,]    3    7

     [,1] [,2]
[1,]    4    6
[2,]    5    7

Using the __ the BY variable should be in the list.

aggregate() function
aggregated() function
aggregates() function
aggregateted() function

What is the result of the following R code?
> x <- array(0:7, dim=c(2,4))
> i <- array(c(1:2, 4:3), dim=c(2,2))
> x[i]

[1] 0 3
[1] 4 3
[1] 1 3
[1] 1 7
[1] 3 4
[1] 4 4
[1] 6 5

Data frames can be converted to a matrix by calling ___.

data.matr()
data.mat()
data.matrix()
All of the mentioned

What is the output of the following code?
> x <- outer(1:2, 1:2, FUN = "*")
> x

[1] 1

[1] 2

[1] 4

     [,1] [,2]
[1,]    1    2
[2,]    2    1

     [,1] [,2]
[1,]    1    2
[2,]    2    4

     [,1] [,2]
[1,]    1    4
[2,]    4    1

Which function is used to convert a list ‘a’ to a vector?

a.as_vector()
unlist(a)
a.vector()
vector(a)

Which of the following is an invalid assignment ?

> x <- list("Los Angeles" = 1, Boston = 2, London = 3)
> names(x) <- c("New York", "Seattle", "Los Angeles")
> name(x) <- c("New York", "Seattle", "Los Angeles")
None of the mentioned

Lst <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9))
What is the value of length(Lst)?

3
4
5
6
7

Lst <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9))
What is Lst[[1]]?

Fred
Mary
3
c(4, 7, 9)

Lst <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9))
What is the value of Lst[[4]][2]?

Mary
(4, 7, 9
7
9

Consider the following R code:
> Projects = list(site="www.upwork.com", sector="R coding", year=2016, month="September", number=10,  billedValue=c(100, 1000, 500, 550, 5000, 475, 50, 8750, 90, 270))
Choose all of the following that will  give the result:
[1] 1000
Note: There may be more than one right answer.

    > Projects[6][2]
    > Projects[[6]][[2]]
    > Projects[6][[2]]
    > Projects[[6]][2]
    > Projects$billedValue[2]
    > Projects[["billedValue"]][2]

What would be the output of the following code ?
> x <- 1:3
> names(x)

NULL
1
2
None of the mentioned

gzfile opens a connection to a file compressed with _____?

url
gzip
bzfile
gdata

What is the output of the following commands?
> x <- paste(c("X", "Y"), 1:2, sep='')
> x

[1] "X" "Y" "X" "Y"
[1] "X1" "Y1" "X2" "Y2"
[1] "X1" "Y2" "X1" "Y2"
[1] "X1" "Y2"
[1] "X" "Y"
[1] "X1" "X2" "Y1" "Y2"

How do you create log linear models in R language?

loglm () function
trace() function
print() function
logim() function

"%UpWork%" <- function(x, y) {upw <- x + y; upw}
ans <- c(1,2)%UpWork%c(2,3)
What is value of ans?

1 2 2 3
2 3
-1 -1
3 5
8

Point out the correct statement.

The elements of a logical vector cannot have the values TRUE, FALSE, and NA
Matrices are vectors with a dimension attribute
Numerical vectors are generated by conditions
All of the mentioned

What is the output of the following commands?
> n <- 10
> 1:n-1

[1] 1 2 3 4 5 6 7 8 9
[1] 0 1 2 3 4 5 6 7 8 9
[1] 1 2 3 4 5 6 7 8 9 10
[1] 0 1 2 3 4 5 6 7 8 9 10
[1] -1 0 1 2 3 4 5 6 7 8

Error is an indication that a fatal problem has occurred and __ of the function stops.

message
execution
warning
fatal

What would be the output of the following code ?
> m <- matrix(1:4, nrow = 2, ncol = 2)
> dimnames(m) <- list(c("a", "b"), c("c", "d"))
> m

  c d
a 1 3
b 2 4

  c d
a 1 2
b 2 3

  c d
a 1 3
b 4 2

All of the mentioned

Which code can be used for converting all variables?

col_names <- names(mydata)
mydata[,col_names] <- lapply(mydata[,col_names] , factor)

names <- c('Freezk' ,'Mahnosr')
mydata[,names] <- lapply(mydata[,names] , factor)
str(mydata)

mydata[sapply(mydata, is.numeric)] <- lapply(mydata[sapply(mydata, is.numeric)], as.factor)

col_names <- names(mydata)
mydata[,col_names] <- lapply(mydata[,col_names] , factor)

The ____ function takes an arbitrary number of arguments and concatenates them one by one into character strings?

copy()
multiscale()
bind()
traceback()

Point out the correct statement.

Empty vectors can be created with the vector() function
A sequence is represented as a vector but can contain objects of different classes
“raw” objects are commonly used directly in data analysis
None of the mentioned

What are the different types of sorting algorithms available in R?

Bucket
Selection
Bubble
Merge
All of the above

What does the following code return?
x <- 5
f1 <- function(x) {
  function() {
    x + 6
  }
}
f1(3)()

3
5
6
8
9
11
14

R is easily extensible through functions and ____?

Extensions
Classes
Methods
Librarys

Let v be a vector. What is the correct way of creating a factor from v?

factor(v)
create_factor(v)
v.factor()
v.create_factor()

What is the factor variable in R language?

Factor variables are categorical variables that hold either string or numeric values
Factor variables are used in various types of graphics and particularly for statistical modelling
Both 1 and 2
Factor variables are used in data types and classes

What can a factor hold?

Strings
Integers
Both strings and integers
None of the mentioned

The following vector represents the country of each of 10 freelancers on UpWork:   
> country <- c("UK", "Vietnam", "USA", "Russia", "Russia", "Egypt", "UK", "Vietnam", "Egypt", "USA")
The following vector represents the hourly rate of the same 10 freelancers:
> hourlyRate <- c(10, 20, 30, 40, 50, 50 ,40 ,30 ,20 ,10)
Which R command will show the average rate for each country?

> hourlyRate/length(country)
> mean(hourlyRate)/length(country)
> tapply(mean, hourlyRate, country)
> tapply(hourlyRate, country, mean)
> mean(hourlyRate/length(country))

What will be the output of the following code ?
> f <- function() {
+             ## This is an empty function
+ }
> f()

0
No result
NULL
All of the above

__ prints out the function call stack after an error occurs?

print()
output()
trace()
traceback()

Functions are defined using the _____ directive and are stored as R objects.

function()
funct()
functions()
All of the mentioned

How can you create scatterplot matrices?

pairs()  
splom()
plot()
Both 1 and 2

___ function returns a vector of the same size as x with the elements arranged in increasing order.

sort()
orderasc()
orderby()
None of the mentioned

Which statement changes the column name to h and f of a matrix m?

colnames(m) <- c("h", "f")
columnnames(m) <- c("h", "f")
rownames(m) <- c("h", "f")
None of the mentioned

What is the output of the following expression?
> c(list(1), "1")

[1] [[1]] "1"

[1] 1 1

[1] 1 "1"

[[1]]
[1] 1

[[2]]
[1] "1"

[[1]]
[1] 1

[[2]]
[1] 1

     [,1] [,2]
[1,]    1    1

     [,1] [,2]
[1,]    1    "1"

What is the result of the following R code?
> x <- array(0:7, dim=c(2,2,2))
> i <- array(c(1:2, 4:3), dim=c(2,2))
> x[i]

[1] 0 1 2 3
[1] 0 1 3 2
[1] 0 4 2 6
[1] 0 2 4 6
[1] 1 5 7 3
[1] 7 5 3 1

Data frames in R language can be merged manually using? Check all that apply.
Note: There may be more than one right answer.

cbind ()
merge ()
bind()
loglm()

Point out the wrong statement.

A formal argument can be a symbol, a statement of the form ‘symbol = expression’, or the special formal argument
The first component of the function declaration is the keyword function
The value returned by the call to function is not a function
None of the mentioned

What is the output of the following commands?
> x <- c(1:3, NA)
> y <- is.na(x)
> y

[1] TRUE
[1] FALSE
[1] FALSE TRUE
[1] FALSE FALSE
[1] TRUE TRUE TRUE TRUE
[1] FALSE FALSE FALSE FALSE
[1] FALSE FALSE FALSE TRUE

What is the result of the following R code?
> x <- 0:6
> y <- x[2 * 1:3]
> length(y) <- 2
> y

[1] 0 1 2 3 4 5 6
[1] 0 2 4 6 2 2 2
[1] 2 4 6 2 4 6 2
[1] 0 1
[1] 1 3
[1] 0 3
[1] 2 1

Which package in R supports the exploratory analysis of genomic data?

ecomic
adegenet
expoerety
adegen

What is the output of the following commands?
> x <- c(-1, 0, 1, 2, NA)
> (x+1)[(!is.na(x)) & x>0]

[1]  -1 0 1 2 NA
[1] 0 1 2 3 NA
[1] 0 1 2 3
[1]  1 2 3
[1] 0 1 2 3 NA+1
[1] 2 3

What is the result of the following code?
> x <- 0:3
> y <- as.character(x)
> z <- as.integer(y)
> z

[1]  0 3
[1] '3' '2' '1' '0'
[1] 3 2 1 0
[1] 1 2 3
[1] 0 1 2 3
[1] '0' '1' '2' '3'
[1] "0" "1" "2" "3"

What is the output of the following commands?
> x <- c(1, 2)
> y <- c(4, 5)
> pmax(x, y)

[1] 2
[1]  5
[1]  2 5
[1]  4 5
[1] 1 5

What is the output of the following expression?
> c(0, FALSE)

[1]  0 FALSE
[1] "0" "FALSE"
[1] 0 "FALSE"
[1] "0" FALSE
[1] "0" "0"
[1] 0 "0"
[1] "0" 0
[1] 0 0

What is the output of the following commands?
> x <- c(0, 1, 2)
> y <- x != 0
> y

[1] TRUE
[1] FALSE
[1] FALSE FALSE FALSE
[1] FALSE TRUE TRUE
[1] TRUE FALSE FALSE

What is the output of the following commands?
> x <- c(1, 2)
> y <- c(x, 0, x)
> prod(y)

[1] 0
[1] 5
[1] 6
[1] 1 2 0 1 2

What is the output of the following expression?
> x <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
> x[-(1:3)]

[1] 9 8 7
[1] 0 1 2
[1] 0 3 7
[1] 3 4 5 6 7 8 9
[1] 0 1 2 3 4 5 6

Which of the expressions below result in the following output?
> [1] "a b"

> `%/\\%` <- function(a, b){ return(paste(a, b))}
> "a" %/\% " b"

> `%-%` <- function(a, b){ return(paste(a, b))}
> `%-%`("a", " b")

> "a" + " b"

> a + b

Backbone.js Тест Upwork 2019