0

Lets say I have an array, dummy_array, whose elements correspond to a date. For each date I want to record a number of items; such as list, dummy_list_1; matrices, dummy_matrix_1; and arbitrary values, dummy_val_1. For example lets say I wanted to record the average temperature (scalar), average wind velocity (vector) etc at some fixed location every day. I would like to be able to access the data by assigning each element in the array a set of attruibutes

dummy_array(date) - average_temperature
                  - average_wind_velocity

Can I use attributes to do this? I know that I can fix attributes to the dummy array, so I could have for example

dummy_array - average_temperature(date)
            - average_wind_velocity(date)

An this is easy to implement using

attr(dummy_array, "average_temperature") <- some_vector
attr(dummy_array, "average_wind_velocity") <- some_other_vector

However I need to set up the first approach so that I can pass the element to a routine and be able to process/update everything in parallel. How can this be done?

user2350366
  • 491
  • 1
  • 4
  • 20
  • I don't understand what you are asking. An actual [reproduicble example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) would be helpful with sample data. If `dummary_array` is an array (or vector in R I guess), it doesn't make sense to have `dummy_array(date)` since it's not a function. Perhaps you can edit your question to make it more clear what you are trying to do. – MrFlick Mar 23 '17 at 14:23
  • Based on your description, I don't think you want to use attributes. You could bundle the all of the items into a list element and create a list (same length as your array) of those list elements. Accessing list elements is much simpler than accessing multiple attributes. If A is the array and L is the list, the information for A[1] would be located in L[[1]]. – dcarlson Mar 23 '17 at 14:26

0 Answers0