Вы находитесь на странице: 1из 6

6/14/2015 Coursera

FeedbackWeek2Quiz HelpCenter

YousubmittedthisquizonSun14Jun201510:56PMAEST.Yougotascore
of10.00outof10.00.

Question1
SupposeIdefinethefollowingfunctioninR

cube<function(x,n){
x^3
}

Whatistheresultofrunning

cube(3)

inRafterdefiningthisfunction?

YourAnswer Score Explanation

Awarningisgivenwithnovalue
returned.

Anerrorisreturnedbecause'n'is
notspecifiedinthecallto'cube'

Thenumber27isreturned 1.00 Because'n'isnotevaluated,itisnot


neededeventhoughitisaformal
argument.

Theusersispromptedtospecify
thevalueof'n'.

Total 1.00/
1.00

Question2
ThefollowingcodewillproduceawarninginR.

x<1:10

https://class.coursera.org/rprog015/quiz/feedback?submission_id=25669 1/6
6/14/2015 Coursera

if(x>5){
x<0
}

Why?

YourAnswer Score Explanation

'x'isavectoroflength10and'if'canonlytestasingle 1.00
logicalstatement.

Youcannotset'x'tobe0because'x'isavectorand0isa
scalar.

Therearenoelementsin'x'thataregreaterthan5

Theexpressionusescurlybraces.

ThesyntaxofthisRexpressionisincorrect.

Total 1.00/
1.00

Question3
Considerthefollowingfunction

f<function(x){
g<function(y){
y+z
}
z<4
x+g(x)
}

IfIthenruninR

z<10
f(3)

Whatvalueisreturned?

YourAnswer Score Explanation

16

https://class.coursera.org/rprog015/quiz/feedback?submission_id=25669 2/6
6/14/2015 Coursera

10 1.00

Total 1.00/1.00

Question4
Considerthefollowingexpression:

x<5
y<if(x<3){
NA
}else{
10
}

Whatisthevalueof'y'afterevaluatingthisexpression?

YourAnswer Score Explanation

10 1.00

NA

Total 1.00/1.00

Question5
ConsiderthefollowingRfunction

h<function(x,y=NULL,d=3L){
z<cbind(x,d)
if(!is.null(y))
z<z+y
else
z<z+f
g<x+y/z
if(d==3L)
return(g)

https://class.coursera.org/rprog015/quiz/feedback?submission_id=25669 3/6
6/14/2015 Coursera

g<g+10
g
}

Whichsymbolintheabovefunctionisafreevariable?

YourAnswer Score Explanation

f 1.00

Total 1.00/1.00

Question6
WhatisanenvironmentinR?

YourAnswer Score Explanation

aspecialtypeoffunction

acollectionofsymbol/valuepairs 1.00

alistwhoseelementsareallfunctions

anRpackagethatonlycontainsdata

Total 1.00/1.00

Question7
TheRlanguageuseswhattypeofscopingruleforresolvingfreevariables?

YourAnswer Score Explanation

dynamicscoping

https://class.coursera.org/rprog015/quiz/feedback?submission_id=25669 4/6
6/14/2015 Coursera

compilationscoping

lexicalscoping 1.00

globalscoping

Total 1.00/1.00

Question8
HowarefreevariablesinRfunctionsresolved?

YourAnswer Score Explanation

Thevaluesoffreevariablesaresearchedforinthe
environmentinwhichthefunctionwascalled

Thevaluesoffreevariablesaresearchedforinthe 1.00
environmentinwhichthefunctionwasdefined

Thevaluesoffreevariablesaresearchedforintheglobal
environment

Thevaluesoffreevariablesaresearchedforintheworking
directory

Total 1.00/
1.00

Question9
WhatisoneoftheconsequencesofthescopingrulesusedinR?

YourAnswer Score Explanation

Allobjectsmustbestoredinmemory 1.00

Robjectscannotbelargerthan100MB

Functionscannotbenested

Allobjectscanbestoredonthedisk

Total 1.00/1.00

https://class.coursera.org/rprog015/quiz/feedback?submission_id=25669 5/6
6/14/2015 Coursera

Question10
InR,whatistheparentframe?

YourAnswer Score Explanation

Itistheenvironmentinwhichafunctionwasdefined

Itisthepackagesearchlist

Itistheenvironmentinwhichafunctionwascalled 1.00

Itisalwaystheglobalenvironment

Total 1.00/1.00

https://class.coursera.org/rprog015/quiz/feedback?submission_id=25669 6/6

Вам также может понравиться