ga_data_order: Order DSL for GA4 OrderBy

Description Usage Arguments Details Value See Also Examples

View source: R/ga_data_order.R

Description

Use with ga_data to create orderBys

Usage

1
2
3
4
ga_data_order(
  x,
  type = c("ALPHANUMERIC", "CASE_INSENSITIVE_ALPHANUMERIC", "NUMERIC")
)

Arguments

x

Order DSL enabled syntax

type

Order Type

Details

The DSL rules are:

The dimension ordering have these effects:

Value

A list of OrderBy objects suitable for use in ga_data

See Also

https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1alpha/OrderBy

Other GA4 functions: ga_data_filter(), ga_data()

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
29
30
31
32
33
# session in descending order
ga_data_order(-sessions)

# city dimension in ascending alphanumeric order
ga_data_order(+city)

# as above plus sessions in descending order
ga_data_order(+city -sessions)

# as above plus activeUsers in ascending order
ga_data_order(+city -sessions +activeUsers)

# dayOfWeek dimension in ascending numeric order
ga_data_order(+dayOfWeek, type = "NUMERIC")

# you can also combine them with c()
a <- ga_data_order(-sessions)
b <- ga_data_order(-dayOfWeek, type = "NUMERIC")
c(a, b)

## Not run: 
# example of use
ga_data(
  206670707,
  metrics = c("activeUsers","sessions"),
  dimensions = c("date","city","dayOfWeek"),
  date_range = c("2020-03-31", "2020-04-27"),
  orderBys = ga_data_order(-sessions -dayOfWeek)
  )



## End(Not run)

googleAnalyticsR documentation built on Oct. 7, 2021, 9:06 a.m.