I am stuck on a problem where I create a nested list. My code looks like this:
steps = ["one", "two"]
whats = ["dog", "cat"]
keys = ["young", "old", "justborn"]
sol<-list() for (step in steps) {
sol[step]<-list()
for (what in whats) {
tmp <-list()
for (key in keys){
tmp[key] <- data$value
}
(sol[sol$step==step])[what] = tmp #Here error occurs
}
}
The error that I get is the following:
number of items to replace is not a multiple of replacement length
At that moment the output for tmp
is the following:
> tmp
$after
[1] "12"
$message
[1] "Good job"
$solution
[1] "Friday"
I have seen that there are a lot of posts with the same error messages, but I still cannot figure out what is my problem. Many of the solutions that I have seen on other posts are based on having NA but my data set does not have any.