Error in source("myfunction.R") : myfunction.R:2:3: unexpected symbol 1: 2: R version

0 votes
myfunction <- function(y){
     y <- rnorm(100)
     mean(y) 

}

myfunction()
[1] 0.05248908
dir()
[1] "myfunction.R"
source("myfunction.R")
Error in source("myfunction.R") : myfunction.R:2:3: unexpected symbol 1: 2: R version

I just started learning R programming, any help will be appreciated.. thank you

Oct 30, 2018 in Data Analytics by Ali
• 10,430 points
283 views

1 answer to this question.

0 votes

Try formatting your code like this:

myfunction <- function() {
  y <- rnorm(100)
  mean(y)
}
answered Oct 30, 2018 by Maverick
• 10,040 points

Related Questions In Data Analytics

0 votes
1 answer

Error saying expected symbol in R

Write the code in the following way: myfunction ...READ MORE

answered Nov 9, 2018 in Data Analytics by Maverick
• 10,040 points
177 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
116 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
160 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points
87 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
104 views
0 votes
1 answer
0 votes
1 answer

"Error in eval(ei, envir) : object 'RDX2' not found" when trying to source the code in R

This is a very common issue that ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,040 points
794 views