A file format that is getting increasingly common with geo-spatial gridded data is the hdf format. Hdf stands for hierarchical data format. For instance MODIS data have been delivered in hdf format since its beginning, Landsat has adopted the hdf format for delivering some of its Level 2 surface reflectance data recently. This data format has an architecture that makes it very convenient to store data of different kind in one file, but requires slightly more effort from the scientist to work with conveniently.

Windows

The rgdal package does not include hdf drivers in its pre-built binary. Data can therefore not be read directly from hdf into R (as object of class rasterLayer). A workaround is to convert the files externally to a different data format. Since you probably have gdal installed on your system (either via FWTools or OSGeo4W), you can use the command line utility gdal_translate to perform this operation. One easy way to do that is by calling it directly from R, via the command line utility.

library(gdalUtils)
# Get a list of sds names
sds <- get_subdatasets('full/path/filename.hdf')
# Isolate the name of the first sds
name <- sds[1]
filename <- 'name/of/output/file.tif'
gdal_translate(sds[1], dst_dataset = filename)
# Load the Geotiff created into R
r <- raster(filename)

And if you want the filename argument to be generated in a more automated fashion, you can use

filename <- rasterTmpFile()
extension(filename) <- 'tif'

Linux

library(gdalUtils)
# Get a list of sds names
sds <- get_subdatasets('full/path/filename.hdf')
# Any sds can then be read directly using the raster function
r <- raster(sds[1])