Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- csvFileName = "/home/majikstone/GoldenCheetah/export_mid2018_2019_Bike.csv";
- wheelC = 2.12;
- textYValB = 1.5;
- textYValC = 1;
- textYValD = 0.4;
- binVal = c(30/30,30/27,30/25,30/23,30/21,30/19,30/17,30/15,46/21,46/19,46/17,46/15,46/14,46/13,46/12,46/11);
- binBreaks = binVal - 0.001;
- binMax = 46/11+0.5;
- binBreaks = c(binBreaks,binMax);
- binTextB = c("30/30","30/27","30/25","30/23","30/21","30/19","30/17","30/15","46/21","46/19","46/17","46/15","46/14","46/13","46/12","46/11");
- binTextC = c("1.00","1.11","1.20","1.30","1.43","1.58","1.76","2.00","2.19","2.42","2.71","3.07","3.29","3.54","3.83","4.18");
- textYB = textYValB * c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
- textYC = textYValC * c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
- textYD = textYValD * c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
- textX = c(1:length(binVal));
- for (i in c(1:length(binVal)-1))
- {
- textX[i] = i;
- }
- textX[length(binVal)] = (binVal[length(binVal)] + binMax)/2;
- csvMat <- read.table(file=csvFileName,header=FALSE,sep=";",dec=",");
- message("File loading complete!");
- speed = as.numeric(csvMat$V1);
- cadence = as.numeric(csvMat$V2);
- cadenceFilter = 50;
- speedFilter = 4;
- ratioFilterMin = 1.0;
- ratioFilterMax = 46/11+0.5;
- filtCadence = cadence[cadence > cadenceFilter];
- filtSpeed = speed[cadence > cadenceFilter];
- cadence = filtCadence;
- speed = filtSpeed;
- filtCadence = cadence[speed > speedFilter];
- filtSpeed = speed[speed > speedFilter];
- cadence = filtCadence;
- speed = filtSpeed;
- gearRatio = 100 * speed / (6 * cadence * wheelC);
- gearRatio = gearRatio[gearRatio >= ratioFilterMin];
- gearRatio = gearRatio[gearRatio <= ratioFilterMax];
- message("Data processing complete!");
- gearHist = hist(gearRatio,breaks=binBreaks,plot=FALSE);
- percentages = diff(gearHist$breaks) * gearHist$density * 100;
- percText = sprintf("(%.1f %%)",percentages);
- textYB = textYB + percentages;
- textYC = textYC + percentages;
- textYD = textYD + percentages;
- x11(width=8,height=8);
- textX = barplot(percentages, ylim=c(0,max(percentages)+5),
- col=rgb(0,0.5,0), border=rgb(0,0.75,0),
- main="Gear ratio histogram", xlab="Gear ratio", ylab="Time %");
- text(x=textX,y=textYB,labels=binTextB,adj=c(0.5,0.5),cex=0.8,col=rgb(0,0,0.5));
- text(x=textX,y=textYC,labels=binTextC,adj=c(0.5,0.5),cex=0.8,col=rgb(0,0,0.3));
- text(x=textX,y=textYD,labels=percText,adj=c(0.5,0.5),cex=0.9,col=rgb(0,0.75,0));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement