Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 6 characters in body
Source Link
CroatiaHR
  • 645
  • 7
  • 27

I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. I expect it to be appended on each row, so that later when I look at the data, I would know from which file is the given row originating.
But it seems that it is not working as expected.

data <- data.frame() for (file in files){ name = strsplit(file, split = "\\.")[[1]][1] data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols( a = col_double(), b = col_double(), )) %>% mutate(name = name)) } 

I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.

I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. I expect it to be appended on each row, so that later when I look at the data, I would know from which file is the given row originating.
But it seems that it is not working as expected.

data <- data.frame() for (file in files){ name = strsplit(split = "\\.")[[1]][1] data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols( a = col_double(), b = col_double(), )) %>% mutate(name = name)) } 

I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.

I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. I expect it to be appended on each row, so that later when I look at the data, I would know from which file is the given row originating.
But it seems that it is not working as expected.

data <- data.frame() for (file in files){ name = strsplit(file, split = "\\.")[[1]][1] data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols( a = col_double(), b = col_double(), )) %>% mutate(name = name)) } 

I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.

added 142 characters in body
Source Link
CroatiaHR
  • 645
  • 7
  • 27

I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. ButI expect it to be appended on each row, so that later when I look at the data, I would know from which file is the given row originating.
But it seems that it is not working as expected.

data <- data.frame() for (file in files){ name = strsplit(split = "\\.")[[1]][1] data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols( a = col_double(), b = col_double(), )) %>% mutate(name = name)) } 

I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.

I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. But it seems that it is not working as expected.

data <- data.frame() for (file in files){ name = strsplit(split = "\\.")[[1]][1] data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols( a = col_double(), b = col_double(), )) %>% mutate(name = name)) } 

I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.

I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. I expect it to be appended on each row, so that later when I look at the data, I would know from which file is the given row originating.
But it seems that it is not working as expected.

data <- data.frame() for (file in files){ name = strsplit(split = "\\.")[[1]][1] data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols( a = col_double(), b = col_double(), )) %>% mutate(name = name)) } 

I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.

Source Link
CroatiaHR
  • 645
  • 7
  • 27

Appending file name to data frame in R

I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. But it seems that it is not working as expected.

data <- data.frame() for (file in files){ name = strsplit(split = "\\.")[[1]][1] data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols( a = col_double(), b = col_double(), )) %>% mutate(name = name)) } 

I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.