How to rename the rownames of a dataframe with matching characters from another dataframe?

At its simplest

cars <- cars[1:32,]
head(cars)
#>   speed dist
#> 1     4    2
#> 2     4   10
#> 3     7    4
#> 4     7   22
#> 5     8   16
#> 6     9   10
rownames(cars) <- rownames(mtcars)
cars
#>                     speed dist
#> Mazda RX4               4    2
#> Mazda RX4 Wag           4   10
#> Datsun 710              7    4
#> Hornet 4 Drive          7   22
#> Hornet Sportabout       8   16
#> Valiant                 9   10
#> Duster 360             10   18
#> Merc 240D              10   26
#> Merc 230               10   34
#> Merc 280               11   17
#> Merc 280C              11   28
#> Merc 450SE             12   14
#> Merc 450SL             12   20
#> Merc 450SLC            12   24
#> Cadillac Fleetwood     12   28
#> Lincoln Continental    13   26
#> Chrysler Imperial      13   34
#> Fiat 128               13   34
#> Honda Civic            13   46
#> Toyota Corolla         14   26
#> Toyota Corona          14   36
#> Dodge Challenger       14   60
#> AMC Javelin            14   80
#> Camaro Z28             15   20
#> Pontiac Firebird       15   26
#> Fiat X1-9              15   54
#> Porsche 914-2          16   32
#> Lotus Europa           16   40
#> Ford Pantera L         17   32
#> Ferrari Dino           17   40
#> Maserati Bora          17   50
#> Volvo 142E             18   42

See the FAQ: How to do a minimal reproducible example reprex for beginners for your case. I can't cut and paste your code and get workable objects. Only need as much data as illustrates the problem.