View source: R/create_time_trends.R
create_time_trends | R Documentation |
create_time_trends()
quickly creates time trends based on a
character columns from inputted data. This function is useful for
statistical analysis when you want time trends. The function will
only operate on 'data.tables' by reference.
create_time_trends(
.data,
time.col,
select.column,
quadratic.time.trends = FALSE,
remove.first.trend = FALSE
)
.data |
a |
time.col |
a time column; can be of any type. 'time.col' will
be ordered using |
select.column |
a column with cross-sectional units that will be used to create the time trends. Think fixed effects such as cities, regions, counties, etc. |
quadratic.time.trends |
a |
remove.first.trend |
removes the first time trend so that only
|
A data.table with the same number of rows, but the time
trends included. The format of the time trend columns will be
tt.select.column_value
(linear trends) or
tt2.select.column_value
(quadratic trends) where
select.column
is the name of the character column
requested from the user and value
is the value of the of
the character column for that time trend
dummy_cols
For creating dummy columns
Other dummy functions:
dummy_cols()
,
dummy_rows()
## For unicode meanings, see
## https://gist.github.com/ChandlerLutz/cca06fb35003713efae87c0322ac193e
clean_readxl_backslashes("\\n")
clean_readxl_backslashes("\\u00ad")
clean_readxl_backslashes("\\u2013")
clean_readxl_backslashes("\\u2013")
crime <- setDT(expand.grid(city = c("SF", "SF", "NYC"),
year = c(1990, 2000, 2010),
crime = 1:3, stringsAsFactors = FALSE))
crime2 <- copy(crime)
print(create_time_trends(crime2, time.col = "year",
select.column = "city"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.