-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathRegression.R
64 lines (46 loc) · 2.57 KB
/
Regression.R
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"
NOTE: First Column is treated as 1 in the Selection of Data:
1 - Please make sure your csv file contains only numeric variables with headers for the code to run.
Column(Instance) 1 Column(Instance) 2 . . . . Column(Instance) n
Row(Variable) 1 (Value) (Value) . . . . (Value)
Row(Variable) 2 (Value) (Value) . . . . (Value)
. . . .
. . . .
. . . .
. . . .
Row(Variable) n (Value) (Value) . . . . (Value)
2 - To run the code, select the whole code and run as source (top right in this window) & enter parameter values in the console below
In this case select
a - the dataset to work with
b- Type of separator and range of columns for numeric data
3 - After the regression values are calculated you can view the results in the console below (or environment window to the right)
"
cat("\f") # Clear old outputs
rm(list=ls()) # Clear all variables
#------------------------------------------------
"SELECTION OF DATSET AND PARAMETERS"
#-----------------------------------------------
#User input for data
print(paste("Please select Input CSV", " The different samples in columns and the measured variables in the rows."), quote = FALSE)
fname <- file.choose()
#ask user for type of Separator:
ask_sep <- as.character(readline(prompt = "ENTER either of the types of Separator ',' or ';' : "))
#Input file read
file1 <- read.csv(fname, sep=ask_sep)
cat("\f") # Clear old outputs
#Extract continuous variables:
start_num <- as.integer(readline(prompt = "Enter value for START of range of numerical variable: "))
cat("\f") # Clear old outputs
end_num <- as.integer(readline(prompt = "Enter value for END of range of numerical variable: "))
#Sub space the numeric data frame:
data_csv <- file1[,start_num : end_num] #all cont. variables
cat("\f") # Clear old outputs
#------------------------------------------------
"CALCULATION FOR REGRESSION"
#-----------------------------------------------
# Linear Regression
data_csv <- as.data.frame(t(data_csv))
lm1 <- lm(data_csv)
summary(lm1)
print(lm1)
print(paste("FINISHED"), quote = FALSE)