i have dataframe (df):
df = structure(list(site = c(989l, 989l, 990l, 990l), filename = structure(1:4, .label = c("989_1.csv", "989_5.csv", "990_2.csv", "990_9.csv"), class = "factor"), sourcea = structure(1:4, .label = c("foldera/989/989_1.csv", "foldera/989/989_5.csv", "foldera/990/990_2.csv", "foldera/990/990_9.csv" ), class = "factor"), destination = structure(c(3l, 1l, 4l, 2l ), .label = c("folderb/989/989_5.csv", "folderb/990/990_9.csv", "folderc/989/989_1.csv", "folderd/990/990_2.csv"), class = "factor")), .names = c("site", "filename", "sourcea", "destination"), class = "data.frame", row.names = c(na, -4l))
'foldera' has series of subfolders containing number of files. wish copy subsets of these files other folders (shown here 'destination'). note: 1) destination varies file file, , 2) primary folders (folderb,folderc,and folderd) exist, subfolders not (e.g., folderc/989/).
i believe solution may involve file.copy() function, having no success.
file.copy(df$sourcea, df$destination)
results in
error in file.exists(from) : invalid 'file' argument
ideas?
edit: using column name 'source' causing problems - changed 'sourcea'.
i think it's because class of df$sourcea
'factor'
, copy.file
wants 'character'
.
Comments
Post a Comment