I have 4 columns: Vehicle ID, Vehicle Class, Vehicle Length and Vehicle Width. 
Every vehicle has a unique vehicle ID (e.g. 2, 4, 5,...) and the data was 
collected every 0.1 seconds which means that vehicle IDs are repeated in 
Vehicle ID column for the number of times they were observed. There are three 
vehicle classes i.e. 1=motorcycles, 2=cars, 3=trucks in the Vehicle Class 
column and the lengths and widths are in their respective columns against every 
vehicle ID. I want to subset the data by vehicle class and then find the 
proportions of each vehicle model (unique length and width) within every class. 
For example, for the Vehicle Class = 2 i.e. car, I want to find different 
models of cars (unique length and width) and their proportions with respect to 
total number of cars. Here is what I have done so far:To subset data by Vehicle 
Classcars <- subset(b, b$'Vehicle class'==2)
trucks <- subset(b, b$'Vehicle class'==3)
motorcycles <- subset(b, b$'Vehicle class'==1)To find the number of 
carsnumofcars <- length(unique(cars$'Vehicle ID')) # 2830
numoftrucks <- length(unique(trucks$'Vehicle ID')) # 137
numofmotorcycles <- length(unique(motorcycles$'Vehicle ID'))# 45The above code 
worked but I could not find the proportions by using the code below:by (cars, 
INDICES=cars$'Vehicle Length', FUN=table(class$'Vehicle width'))R gives an 
error stating that it could not find 'FUN'. Please help me in finding the 
proportions of each model within all classes of vehicles.

Umair Durrani

email: umairdurr...@outlook.com
                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to