[R] build a literature database
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Wed Nov 4 10:28:13 CET 2020
On 04/11/2020 4:22 a.m., John wrote:
> Hi,
>
> I 'd like to create a table for literature review. Is there any good
> data structure (database) I may use? Now I just use a simple dataframe as
> follows, but in the second item I swap the order of year and author, and it
> records 2013 as author and "XH" as year. Is there any better structure ?
> If not, how may I fix the current condition?Thanks!
>
>
> df <- data.frame(author = NA, year = NA, title = NA, country = NA, sample =
> NA, data = NA, result = NA, note = NA, stringsAsFactors=FALSE)
> df[1, ]<-c(
> author = "Moore",
> year = 2020,
> title = "Statistics and data analysis",
> country = "Colombia",
> sample = NA,
> data = "firm level",
> result = NA,
> note = NA)
>
> df[nrow(df)+1,]<- c(year = 2013,
> author = "XH",
> title = NA,
> country = NA,
> sample = NA,
> data = NA,
> result = NA,
> note = NA)
If you changed the last statement to
df <- rbind(df, data.frame(year = 2013,
author = "XH",
title = NA,
country = NA,
sample = NA,
data = NA,
result = NA,
note = NA))
it would correctly sort out the reordered columns.
As to a better data structure: bibliographic data is hard, because
different forms of publication should have different fields. I'd
suggest storing the data in some existing format rather than rolling
your own. For example, the utils::bibentry function is quite a bit like
BibTeX.
Duncan Murdoch
More information about the R-help
mailing list