Error saying expected symbol in R

0 votes
myfunction <- function() (  
    x <- rnorm(100)  
    mean(x)   
)

When I attempt to copy this to the console it gives the following error:

Error: unexpected symbol in:
"x <- rnorm(100)
mean"

Then when I type myfunction into the console as instructed I get this:

function() 
x <- rnorm (100)
Nov 9, 2018 in Data Analytics by Ali
• 11,360 points
2,720 views

1 answer to this question.

0 votes

Write the code in the following way:

myfunction <- function() {  
    x <- rnorm(100)  
    mean(x)   
}
answered Nov 9, 2018 by Maverick
• 10,840 points

Related Questions In Data Analytics

0 votes
1 answer

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

Try formatting your code like this: myfunction <- ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,840 points
2,129 views
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

": cannot open the connection" Error in R

There can be two reasons for this ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,360 points
4,672 views
+2 votes
1 answer

“subscript out of bounds” Error in r programming

This error is likely to occur when ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,360 points
9,382 views
+1 vote
1 answer

What does “replacement has” Error mean?

This error occurs when one tries to ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,360 points
492 views
0 votes
1 answer

Errors saying "Error: unexpected '}' in "}"

This is a syntax error: Enclose your if ...READ MORE

answered Nov 8, 2018 in Data Analytics by Maverick
• 10,840 points
2,806 views
0 votes
1 answer

Error saying "Error in rnorm() : argument "n" is missing, with no default" in R

Hey @ali, rnorm() function requires an argument, ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,840 points
3,060 views
0 votes
1 answer

Error saying "Error in source("myfirst.R") : myfirst.R:14:2: unexpected '!' 13: 14: ë! ^"

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

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,840 points
763 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP