R Console (32-bit) File Edit Misc Packages Windows Help RCAUserslWDesktoplCourse
ID: 3674900 • Letter: R
Question
R Console (32-bit) File Edit Misc Packages Windows Help RCAUserslWDesktoplCoursera21mycod.R - R Editor File Edit Packages Help yfunction dir ) character (0) > read.csv ("mydata.csv") Error in file (file, "rt"): cannot open the connection In addition: Warning message: In file (file, "rt" x-rnorm (100) an (x) cannot open file 'mydata.csv: No such file or directory >getwd () 1] "C:/Users/V/Desktop/Coursera2" >utils:: :menuInstallPkgs () - Please select a CRAN mirror for use in this session Error in contrib.url (repos, type) trying to use CRAN without setting a mirror > getwd ) 1] "C:/Users/V/Desktop/Coursera2" > myfunction dir ) 11 "mycod.R" > source ("mycod.R" rror in eval (expr, envir, enclos) object 'myfunction' not foundExplanation / Answer
We can customize functions to server our special needs. If you often need to perform a particular group of steps, you can package them into a function, so that they are easier to re-use, comparing to copy-paste-modify a big chunk of lines every time.
name <- function(argument_1, argument_2, …){
commands
return(value) # not required
}
THe function here is
myfunction <= function(){
x= rnorm(100)
mean(x)
}
ehich writes the random numbers
Here a small chnage in theabove code
use browsre to open a interctive console and
myfunction <= function(){
x<-rnorm(100)
browsre()
return mean(x)
}
this could be work now.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.