This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to write an R script that takes from the user a list of numbers and do some mathematical operations on it ?

i want to know how to write R script that takes from the user a list of numbers and outputs the following of the list:

  1. Mean and median.
  2. Standard deviation and range.

i want it to receive any input data from the keyboard and display data on the screen.

here the script that i used :

num <- readline (prompt = "list of numbers")

num <- as.numeric(num)

result.mean <- mean(num)

print (result.mean)

result.median <- median(num)

print(result.median)

result.sd <- sd(num)

print(result.sd) 

but it didnt work and i'm sorry if the script not in correct format but i dont know how to display it .

script r

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
code_formatting

thanks alot

0 answers

No answers yet.

Log in to answer this question.