I am relatively new to R (~ 3 months) and therefore I just use all data types. While lists are a very useful way to store heterogeneous data in one place, they are also extremely inflexible for function calls, and they make me sad.
For the work that I do, I often use lists because I need to keep a bunch of vectors of different lengths. For example, I track performance statistics for about 10,000 different vehicles, and there are certain vehicles that are so similar that they can essentially be considered the same vehicles for certain analyzes.
So, let's say we have this list of car identifiers:
List <- list(a=1, b=c(2,3,4), c=5)
For simplicity.
I want to do two things:
Tell me which list item has a particular car. Therefore, when I say R, I work with vehicle 2 , it should tell me b or [2] . I feel it should be something simple, how can you do
match(3,b) > 2
Convert it to a data frame or something similar so that it can be saved as a CSV. Unused strings can be empty or NA . What I should have done so far:
for(i in length(List)) { length(List[[i]]) <- max(as.numeric(as.matrix(summary(List)[,1]))) } DF <- as.data.frame(List)
Which seems silly.
source share