Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #I_1
- >x = scan("sample1.txt")
- > stem(x)
- #I_2
- > tablou=read.csv("unemploy2012.csv", header=T, sep=";");
- > rate=tablou[['rate']];
- > interval=c(0,seq(4,14,2),300);
- > hist(rate, breaks=interval, right=F);
- #I_3
- > tablou=read.csv("life_expect.csv", header=T, sep=",");
- > country=tablou[['country']];
- > male=tablou['male'];
- > male=tablou[['male']];
- > female=tablou[['female']];
- > interval=seq(min(male),max(male), length=8);
- > hist(male, breaks=interval, right=F);
- > interval=seq(min(female),max(female), length=8);
- > hist(female, breaks=interval, right=F);
- #II_1
- >x=scan("sample1.txt");
- >mean(x);
- >median(x);
- #II_2
- tablou=read.csv("life_expect.csv", header=T, sep=",");
- country=tablou[['country']];
- barbati=tablou[['male']];
- femei=tablou[['female']];
- mean(barbati);
- median(barbati);
- mean(femei);
- median(femei);
- #II_3
- modul = function(a){
- return(names(which(table(a)==max(table(a)))))
- }
- modul (c(1,1,1,3,4,4,4))
- #III_1
- outliers_mean=function(esantion){
- m=mean(esantion);
- s=sd(esantion);
- esantion_nou=vector();
- j=0;
- for (i in 1:length(esantion))
- if (esantion[i]<=m-2*s || esantion[i]>=m+2*s){
- j=j+1;
- esantion_nou[j]=esantion[i];
- }
- return (esantion_nou);
- }
- sample = c(1, 91, 38, 72, 13, 27, 11, 85, 5, 22, 20, 19, 8, 17, 11, 15, 13, 23, 14, 17)
- outliers_mean(sample)
- #III_2
- outliers_iqr=function(esantion){
- q1=as.vector(quantile(esantion))[2];
- q3=as.vector(quantile(esantion))[4];
- iqr=q3-q1;
- esantion_nou=vector();
- j=0;
- for (i in 1:length(esantion))
- if (esantion[i]<=q1-iqr*1.5 || esantion[i]>=q3+iqr*1.5){
- j=j+1;
- esantion_nou[j]=esantion[i];
- }
- return (esantion_nou);
- }
- #III_3
- outliers_mean(esantion);
- outliers_iqr(esantion);
- summary(esantion);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement