0

My original data frame has 311 columns and ~6,000 rows with the first column being the transaction date and columns 2:311 are the number of daily transactions. I am trying to extract specific column names to subsequently create new data frames based on a subset of the data.

I use the code below to specify which column in the dataframe:

Product <- colnames(Volumes[2])[1] #choosing product

This returns the following: DSL_BC_03AG

Once I have the result, I want it to be the name of a completely new . I have tried it multiple ways, all have failed. One approach I have tried is listed below:

colnames(Volumes[2])[1] <- as.data.frame(matrix(0, ncol = 2, nrow = 2))

I receive the following error:

Warning message: In colnames(Volumes[2])[1] <- as.data.frame(matrix(0, ncol = 2, : number of items to replace is not a multiple of replacement length

Any help is appreciated.

aynber
  • 22,380
  • 8
  • 50
  • 63
Confucion
  • 101
  • 1
  • 1
  • 4

0 Answers0