get_gfdata: Download Preliminary and Raw 'GreenFeed' Data via 'API'

View source: R/get_gfdata.R

get_gfdataR Documentation

Download Preliminary and Raw 'GreenFeed' Data via 'API'

Description

Downloads preliminary and raw 'GreenFeed' data from the 'C-Lock Inc.' server via an 'API'. Retrieves data based on specified parameters (login, date range, and units), and provides a CSV file with the 'GreenFeed' preliminary data.

Usage

get_gfdata(
  user,
  pass,
  d = "visits",
  exp = NA,
  unit,
  start_date,
  end_date = Sys.Date(),
  save_dir = tempdir()
)

Arguments

user

a character string representing the user name to logging into 'GreenFeed' system

pass

a character string representing password to logging into 'GreenFeed' system

d

a character string representing data type to download (opts: "visits", "feed", "rfid", "cmds")

exp

a character string representing study name or other study identifier. It is used as file name to save the data

unit

numeric or character vector, or a list representing one or more 'GreenFeed' unit numbers

start_date

a character string representing the start date of the study (format: "dmy")

end_date

a character string representing the end date of the study (format: "dmy")

save_dir

a character string representing the directory to save the output file

Value

A CSV file with the specified data (visits or raw) saved in the provided directory.

Examples


# Please replace "your_username" and "your_password" with your actual 'GreenFeed' credentials.
# By default, the function downloads the preliminary 'GreenFeed' data,
# if raw data is needed use options: "feed", "rfid", or "cmds"

get_gfdata(
  user = "your_username",
  pass = "your_password",
  d = "visits",
  exp = "StudyName",
  unit = c(304, 305),
  start_date = "2024-01-01",
  end_date = Sys.Date(),
  save_dir = tempdir()
)


greenfeedr documentation built on April 4, 2025, 12:22 a.m.