You are on page 1of 4

R CSV files

By
Sunil Kadam
wt1=c(25,56,87,65,34,99,35,87,77,87)
table(wt1)
cumsum(table(wt1))
hist(wt1)
range(wt1)
l1=20
maxl2=100
step1=20
x_br1=seq(l1,maxl2,by=step1)
int1=cut(wt1,x_br1,right = FALSE)
Y1=table(int1)
df_wt$cumfq=cumsum(df_wt$Freq)
df_wt
mean(wt1)
median(wt1)
m1=names(table(wt1))[table(wt1)==max(table(wt1))]
m1
# Reading data from CSV files
d2=read.csv("input.csv")
d2
nrow(d2)
ncol(d2)
# Structure of CSV dataframe
str(t1)
# Calculations on CSV files records
max(d2$Age)
# Extracting records from data
a1=subset(d2,Age==max(d2$Age))
a1
a1=subset(d2,name=="sunil")
a1
a1=subset(d2,Age>=25)
a1
mean_age=mean(d2$Age)
mean_age
d2$Dept
subset(d2,Dept=="IT")
# Adding Records to existing data with rbind()
newd2=data.frame(Roll_no=c(106,107),name=c("sana","bina"),Age=c(25,24),Dept=c("IT","HR"))
combine_d2=rbind(d2,newd2)
combine_d2
# installing libary MASS
library("MASS")
# one of file in MASS

ships
# Structure of file ships

str(ships)
# Analysis of ships
max(ships$incidents)
max(ships$service)
summary(ships$service)
# extracting field from ship to new variable
tys=c(ships$type)
tys
table(tys)
cumsum(table(tys))
table(yrs)
summary(yrs)
hist(yrs)

You might also like