-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRToolsPres.R
36 lines (28 loc) · 949 Bytes
/
RToolsPres.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
# R Tools Template
# Alex Looi
graphics.off();
rm(list=ls());
############################################################################
# using the library RCUrl
install.packages("RCurl")
library(RCurl)
web= "https://looixiv.github.io/Bio381/Fish_data.txt"
getData = function(web, delimiter){
output = getURL(web) # gets the data
# return the output
X <- read.table(textConnection(output),sep=delimiter,header=T,fill=T)
return(X)
}
############################################################################
# read user input
read_dw = function(){
w = readline("Enter Web Address") # input of the user URL (where to DL data)
d = readline("Enter Delimiter")
if(d == "\\t" || d == "\"\\t\"" || d== "tab")
d="\t"
output=c(w,d)
return(output) # return the web URL
}
inputs = read_dw() # getting user input
data = getData(inputs[1], inputs[2])
write.csv(data,"Test Data",row.names=F) # output the data to your directory