-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.R
More file actions
40 lines (37 loc) · 1021 Bytes
/
input.R
File metadata and controls
40 lines (37 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
USERINPUT <- function(){
#This function takes the input from command line seperated by enter.
#x will be a list, which is to be converted into numreric for computation purpose.
cat("Enter data seperated by enter: ")
x <<- list()
index <- 1
y <- readline("")
while(y != ''){
x[index] <<- y
index <- index + 1
y <- readline("")
}
}
READFROMCSV <- function() {
#This function reads the CSV file from Local Storage.
library(data.table)
fileData <<- fread(file.choose())
x1 <<- fileData$x1
x2 <<- fileData$x2
y <<- fileData$y
}
INPUT <- function() {
#This function lets the user choose from the option of READFROMCSV or USERINPUT.
cat('\f')
cat('\t\t***** CHOOSE DATA ENTRY METHOD ******\n\n')
cat('1. READ FROM CSV\n')
cat('2. COMMAND LINE INPUT\n')
inputchoice <- readline(prompt = "Enter the choice: ")
inputchoice <- as.integer(inputchoice)
if(inputchoice == 1){
READFROMCSV()
}
if(inputchoice == 2){
USERINPUT()
x1 <<- as.numeric(x)
}
}