dataframe - How to make specific table in R? -


given x <- c('typea', 'typeb', 'typec') , number n, want make table:

type   file      path_to_file typea  typea_1   /home/lynnyi/typea/typea_1.txt typea  typea_2   /home/lynnyi/typea/typea_2.txt ... typea  typea_n   /home/lynnyi/typea/typea_3.txt typeb  typeb_1   /home/lynnyi/typeb/typeb_1.txt ... typeb  typeb_n   /home/lynnyi/typeb/typeb_1.txt typec  typec_1   /home/lynnyi/typec/typeb_1.txt ... typec  typec_n   /home/lynnyi/typec/typeb_1.txt 

i know how use various sapplys value of each of columns, i.e. ['typea_1',...,'typea_n',.......,'typec_n'] , ['/home/lynnyi/typea/typea_1.txt', .... ... , '/home/lynnyi/typec/typec_n.txt']

but lose ability join them based in type , num...

how have them in 1 table / data frame?

thanks!

if n same types, can done follows:

x <- c('typea', 'typeb', 'typec') n <- 10  types <- sort(rep(x, 10)) files <- paste(types, rep(1:n, 3), sep = "_") paths <- paste("/homme/lynnyi", types, paste0(files, ".txt"), sep = "/")  data <- cbind(types, files, paths) 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -