drive_reveal: Add a new column of Drive file information

Description Usage Arguments Value File path Permissions Publishing Parent See Also Examples

View source: R/drive_reveal.R

Description

drive_reveal() adds extra information about your Drive files that is not readily available in the default dribble produced by googledrive. Why is this info not always included in the default dribble?

drive_reveal() can also hoist any property out of the drive_resource list-column, when the property's name is passed as the what argument. The resulting new column is simplified if it is easy to do so, e.g., if the individual elements are all string or logical. If what extracts a date-time, we return POSIXct. Otherwise, you'll get a list-column. If this makes you sad, consider using tidyr::hoist() instead. It is more powerful due to a richer "plucking specification" and its ptype and transform arguments. Another useful function is tidyr::unnest_wider().

Usage

1
drive_reveal(file, what = c("path", "permissions", "published", "parent"))

Arguments

file

Something that identifies the file(s) of interest on your Google Drive. Can be a character vector of names/paths, a character vector of file ids or URLs marked with as_id(), or a dribble.

what

Character, describing the type of info you want to add. These values get special handling (more details below):

  • path

  • permissions

  • published

  • parent

You can also request any property in the drive_resource column by name. The request can be in camelCase or snake_case, but the new column name will always be snake_case. Some examples of what:

  • mime_type (or mimeType)

  • trashed

  • starred

  • description

  • version

  • web_view_link (or webViewLink)

  • modified_time (or modifiedTime)

  • created_time (or createdTime)

  • owned_by_me (or ownedByMe)

  • size

  • quota_bytes_used (or quotaBytesUsed)

Value

An object of class dribble, a tibble with one row per file. The additional info requested via what appears in one (or more) extra columns.

File path

When what = "path" the dribble gains a character column holding each file's path. This can be very slow, so use with caution.

The example path ~/a/b/ illustrates two conventions used in googledrive:

Permissions

When what = "permissions" the dribble gains a logical column shared that indicates whether a file is shared and a new list-column permissions_resource containing lists of Permissions resources.

Publishing

When what = "published" the dribble gains a logical column published that indicates whether a file is published and a new list-column revision_resource containing lists of Revisions resources.

Parent

When what = "parent" the dribble gains a character column id_parent that is the file id of this item's parent folder. This information is available in the drive_resource, but can't just be hoisted out:

If you really want the raw parents property, call drive_reveal(what = "parents").

See Also

To learn more about the properties present in the metadata of a Drive file (which is what's in the drive_resource list-column of a dribble), see the API docs:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Get a few of your files
files <- drive_find(n_max = 10, trashed = NA)

# the "special" cases that require additional API calls and can be slow
drive_reveal(files, "path")
drive_reveal(files, "permissions")
drive_reveal(files, "published")

# a "special" case of digging info out of `drive_resource`, then processing
# a bit
drive_reveal(files, "parent")

# the "simple" cases of digging info out of `drive_resource`
drive_reveal(files, "trashed")
drive_reveal(files, "mime_type")
drive_reveal(files, "starred")
drive_reveal(files, "description")
drive_reveal(files, "version")
drive_reveal(files, "web_view_link")
drive_reveal(files, "modified_time")
drive_reveal(files, "created_time")
drive_reveal(files, "owned_by_me")
drive_reveal(files, "size")
drive_reveal(files, "quota_bytes_used")

# 'root' is a special file id that represents your My Drive root folder
drive_get(id = "root") %>%
  drive_reveal("path")

googledrive documentation built on July 8, 2021, 5:07 p.m.