Files
car_sharing_2023/calculate_data.R
T

13 lines
328 B
R
Raw Normal View History

2024-01-10 22:54:51 +01:00
# Read the data
2024-01-10 22:05:50 +01:00
df <- read.csv('cleaned.csv')
2024-01-10 22:54:51 +01:00
# Calculate the amount of km driven per row
2024-01-10 22:05:50 +01:00
df$diff <- c(0, diff(df$Km_End))
2024-01-10 22:54:51 +01:00
# Calculate the sum of driven km per driver
by(df$diff,df$FahrerIn, sum)
# Calculate the usages of driven km per driver
by(df$diff,df$FahrerIn, length)
write.csv(df, file="cleaned_with_difference.csv")