Reading .csv files as Dataframe I am trying to import the NYSE_2001 folder as a dataframe
When I use lapply, it imports the files as a Large List of 261 elements
Is there a way to convert this large list into a dataframe?
Answers and follow-up questions Answer or follow-up question 1
Yes, the next step is to combine that list of 261 elements into a dataframe.
You would use the function rbind().
To apply rbind() to all elements of a list use do.call(). See Section '188.8.131.52 Applying functions to lists'
in the book for an example with do.call and rbind.
Michel Ballings Answer or follow-up question 2
When I run a do.call(rbind) on the data the output is 139817 obs. of 1 variable. I do not think this is how the data is supposed to be
structured. I looked on google and in the textbook for a way to split the dataframe into 7 columns and could not find how.
Do you have any suggestions? Answer or follow-up question 3
What does the data look like in the list?
I expect it to be single columns too. That means that the problem is not with do.call(rbind, yourlist)
but with the statement that you use to read in your data. A common problem is using the wrong separator.
Whenever you write a line of code, always check the output of that line before running the next line of code.
Michel Ballings Answer or follow-up question 4
Once I have the data read in correctly, and separated into 7 variables, I am having a hard time naming the columns.
I am using colnames(X) <- c('Symbol','Date','... etc but it is giving the following error "attempt to set 'colnames' on an object with less
than two dimensions" Answer or follow-up question 5
I can't solve this problem without seeing your code. Please come to my office hours.
Michel BallingsSign in to be able to add an answer or mark this question as resolved.