Learn R Programming

RAhrefs (version 0.1.4)

rah_condition: Single condition creation for an Ahrefs API query

Description

This function create an optional single condition for report querying. It can only be used in where and having parameters and should only be used inside rah_condition_set function.

Usage

rah_condition(column_name, operator, value, is_date = FALSE)

Arguments

column_name

character string. Proper name of the column of the raport to query from

operator

character string. See more in details

value

character string or numeric/integer. Contains the value for a condition

is_date

logical, defaults to FALSE. If provided value is a date character string, should be set to TRUE. Works only for dates in 'YYYY-MM-DD' format.

Value

character string with formatted condition

Details

This function should be ALWAYS used inside rah_condition_set function. Options include:

  • "SUBDOMAIN" (string) the condition is satisfied if a domain in the <column> is a subdomain of the provided <domain>, for example: rah_condition("url_to", "SUBDOMAIN", "dev")

  • "SUBSTRING" (string) the condition is satisfied if the provided <value> is a substring of the <column>, for example: rah_condition("url_to", "SUBSTRING", "ample")

  • "WORD" (string) the condition is satisfied if the provided <value> appears as a separate word of the <column>, for example: rah_condition("title", "WORD", "the")

  • "EQUALS", "UNEQUALS", "LESS_THAN", "LESS_OR_EQUAL", "GREATER_THAN", "GREATER_OR_EQUAL" (numeric/date) the condition is satisfied if a <column> is different to <value>, for example: rah_condition("domain_rank", "GREATER_OR_EQUAL", 5) OR for dates rah_condition("first_seen", "LESS_THAN", "2019-01-01", is_date = TRUE)

See Also

Other Ahrefs conditions: rah_condition_set

Examples

Run this code
# NOT RUN {
    
# }
# NOT RUN {
rah_condition(column_name = "first_seen",
                           operator = "GREATER_THAN",
                           value = "2018-01-01",
                           is_date = TRUE)
 
# }
# NOT RUN {
    
# }
# NOT RUN {
rah_condition(column_name = "links",
                           operator = "GREATER_THAN",
                           value = "10")
# }

Run the code above in your browser using DataLab