1

Download the 1 km² attribute for the German Census 2011 immigrant rate, which has the German name Auslaender_A. Then download the data for the vacany rate (German name: Leerstandsquote) in the same raster resolution. Make sure to properly define missing values.
The function for downloading is z11::z11_get_1km_attribute() and the one for listing all attributes of this size z11::z11_list_1km_attributes(). There you can also see both of the data names.

2

Crop both datasets to the extent of the city of Berlin.
You can use the osmdata:getbb() function to receive a proper polygon for this purpose. Make sure only to extract the multipolygon and to convert it to the EPSG:3035 CRS.

3

That’s an open exercise: How would you try to conduct a basic correlational analysis of both raster data attributes?
Remember that you can extract the whole raster data as a simple vector using raster::getValues()