Hi, i am currently working on a dataset which has the following structure :
structure(list(code = c(NA, "613506", "651001", "615500", "615505",
"615506"), compte = c("Servicios exteriores", "6210010006 LOCATION FAIBLE VALEUR À
LONG TERME",
"6210030000 REDEVANCES POUR LICENCES", "6220000000 REPARATION IMMEUBLE,
INSTALLATIONS ET MACHINES",
"6220000002 REPARATIONS MACHINES", "6220000003 REPARATION MOBILIERE, PEINTURE
ET DECORATION"
), montant = c(0, 11516.63, 3733.12, 150.72, 0, 2.75)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
I want to sum the values in the second column according to the values of the first column (but only the first 3 digits, not the whole value), using the starts_with() function. I have run the following code :
sum(col_test[which(col_test[,1] == starts_with(606)),2])
yet it doesn't work as 606 is numeric and not a character. How can i proceed ?