I have a variable list called working_dir
that consists of the name of files I want to import
working_dirs
$`./.\\dataset/UCI HAR Dataset/test/Inertial Signals`
[1] "body_acc_x_test.txt" "body_acc_y_test.txt" "body_acc_z_test.txt" "body_gyro_x_test.txt"
[5] "body_gyro_y_test.txt" "body_gyro_z_test.txt" "total_acc_x_test.txt" "total_acc_y_test.txt"
[9] "total_acc_z_test.txt"
$`./.\\dataset/UCI HAR Dataset/train/Inertial Signals`
[1] "body_acc_x_train.txt" "body_acc_y_train.txt" "body_acc_z_train.txt" "body_gyro_x_train.txt"
[5] "body_gyro_y_train.txt" "body_gyro_z_train.txt" "total_acc_x_train.txt" "total_acc_y_train.txt"
[9] "total_acc_z_train.txt"
I want to import each of the files with read.table()
and name it with the name of the file. My idea is to use mapply()
and pass each argument into assign()
function. something like
mapply(assign , working_dir, read.table(working_dir , header = T))
However I know this syntax is incorrect. What are they ways to achieve this?