apply() and calculating proportion of first row for all dataframe rows

前端 未结 4 793
后悔当初
后悔当初 2021-01-15 02:18

I have a dataframe as shown below listing the number of injuries by vehicle type:

trqldnum <- data.frame(motorveh=c(796,912,908,880,941,966,989,984),
             


        
4条回答
  •  心在旅途
    2021-01-15 03:03

    How about

    sweep(trqldnum,2,unlist(trqldnum[1,]),"/")
    

    ?

    The unlist is required to convert the first row of the data frame into a vector that can be swept ...

提交回复
热议问题