Create and fill a list with duplicates of a data frame in R? -
i'm building naive bayes classifier in r, language not familiar with.
i've got multiple csv files testing trained classifier, become data frames when read r. there 20 possible categories given document can classified into, , each test file contains many documents, need array of 20 copies of test file calculate probabilities 20 categories , choose best 1 each document in test file.
so once i've read csv file r , have data frame, how create array or list 20 copies of data frame?
df <- read.csv(text='a,b\n1,a\n2,b\n3,c\n'); df; ## b ## 1 1 ## 2 2 b ## 3 3 c rep(list(df),20); ## [[1]] ## b ## 1 1 ## 2 2 b ## 3 3 c ## ## [[2]] ## b ## 1 1 ## 2 2 b ## 3 3 c ## ## ... (snip) ... ## ## [[19]] ## b ## 1 1 ## 2 2 b ## 3 3 c ## ## [[20]] ## b ## 1 1 ## 2 2 b ## 3 3 c
Comments
Post a Comment