8. Data interfaces in R.
8)Write an R program to demonstrate the data interface with a CSV file. [creating data for csv, analyzing, and writing csv file]
CODE:
csv_data=read.csv(file="sample.csv") print(csv_data) #print no. of column print(ncol(csv_data)) #print no. of row print(nrow(csv_data)) #Aggregate function min_pro=min(csv_data$projects) print(min_pro) B=max(csv_data$salary) print(B) new_csv=subset(csv_data,department=="HR" & projects<10) print(new_csv) write.csv(new_csv,"new_sample.csv", row.names=FALSE) A=read.csv(file="new_sample.csv") print(A)
OUTPUT :
[1] Id Name Department Salary Project
1 A HR 60654 14
2 B Technology 59640 3
3 C marketing 69040 8
4 D HR 65043 5
5 E Technology 59942 2
6 F IT 65000 5
7 G HR 69000 5
[1] 5
[1] 7
[1] 2
[1] 69040
[1] Id Name Department Salary Project
4 D HR 65043 5
7 G HR 69000 5
[1] Id Department Salary Project
4 HR 65043 5
7 HR 69000 5

.jpeg)