I'm a student in biology. I have a problem with the class in R. I have created this class: (this class is just a test, it do nothing)
Chromosome <- setRefClass('Chromosome',
fields = list(genes='list',genes_range='list',fitness='numeric'),
methods = list(get_fitness=function(object){
fitness <<- 2
},
mutate=function(object){
print('mutate')
})
)
a <- Chromosome(genes=list('just','a random value'),genes_range=list('lplpk',15),fitness=1)
and when i try to run this code I have this error:
Error in initialize(value, ...) :
invalid names for slots of class “Chromosome”: genes, genes_range, fitness
But if i replace the Chromosome by chromosome there is no problem. Do you have any idea on why there is this problem? Now the code works, but I still don't know why I can't use a 'C' for chromosome.