forked from manjushajoshi/R-code
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPullingdatainR.R
More file actions
47 lines (47 loc) · 1.3 KB
/
PullingdatainR.R
File metadata and controls
47 lines (47 loc) · 1.3 KB
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
#Try command one by one
#to check current working directory
getwd()
#to set th directory in which the textsample file is stored
# setwd("/home/manjusha/data/")
#on windows
#setwd("C:\Downloads\data")
#To read file content in variable fdata
fdata<- scan("textsample.txt", what="")
#To see the first few entires of the file
head(fdata)
# To ocnvert all words in lower cases
fdata<-tolower(fdata)
#table command to count frequncy of the words in file
ft<-table(fdata)
#T see the pie graph of the words based on the frequency
pie(ft)
#Max will return the maximum frequncy found
max(ft)
#See some starting values of ft
head(ft)
#plot dots for words Vs frequency
dotchart(ft)
#To read csv file use the command
read.csv("test.csv",header=FALSE)
#read.table is another command
read.table("test.csv",header=TRUE)
#To fetch data directly from web
data1<-read.table( "http://lib.stat.cmu.edu/datasets/csb/ch3a.dat")
head(data1)
#other way
data2<-read.csv( "http://lib.stat.cmu.edu/datasets/csb/ch3a.dat")
head(data2)
#to read xls file
install.packages("gdata")
library(gdata)
read.xls("test.xls")
#to open R data editor
x<-edit(as.data.frame(NULL))|
#To see data sets in R
data()
#To open specific data
data(Airpassengers)
#To see help of the data
help(AirPassengers)
#to view the data
head(AirPassengers)