I used the following code:
data<-read.csv('/Users/mf/Desktop/acceptor.csv')
just_nums<-sapply(data,is.numeric)
just_nums_data<-data[,just_nums]
str(just_nums_data)
heatmap(just_nums_data)
But got this output:
data<-read.csv('/Users/mf/Desktop/acceptor.csv')
just_nums<-sapply(data,is.numeric)
just_nums_data<-data[,just_nums]
str(just_nums_data)
'data.frame': 622 obs. of 16 variables:
ID : int 1 2 4 5 6 7 8 9 10 11 ...
QnWeight_initial : int 158 165 137 129 155 150 119 153 137 153 ...
QnWeight_initial_mg : num 15.8 16.5 13.7 12.9 15.5 15 11.9 15.3 13.7 15.3 ....
Days_till_1st_Wrkr : int NA 21 NA 26 NA 23 22 20 22 NA ...
Days_before_max_Wrkr_Eclosion : int NA 12 NA 7 NA 10 11 13 11 NA ...
Wrkr_Eclosion_Bin : int NA 3 NA 1 NA 1 2 3 2 NA ...
QnMass_At_Wrkr_Eclosion : int NA 83 NA 73 NA 67 53 78 56 NA ...
ColonyMass_At_Wrkr_Eclosion : int NA 117 NA 53 NA 91 85 111 96 NA ...
Adult_Wrkrs_At_Wrkr_Eclosion : int NA 9 NA 5 NA 1 7 3 2 NA ...
Mature_Brood_At_Wrkr_Eclosion : int NA 25 NA 13 NA 17 18 27 28 NA ...
Sum_wrkrsPlusBrood_At_Wrkr_Eclosion: int 0 34 0 18 0 18 25 30 30 0 ...
QnMass_2wksLater : int NA 124 NA NA NA 111 NA NA NA NA ...
QnMass_4wksLater : int NA 117 NA NA NA 88 NA NA NA NA ...
ColonyMass_4wksLater : int NA 571 NA NA NA 736 NA NA NA NA ...
QnMass_2mnthsLater : int NA 118 NA NA NA 86 NA NA NA NA ...
ColonyMass_2mnthsLater : int NA 445 NA NA NA 1817 NA NA NA NA ...
heatmap(just_nums_data)
Error in heatmap(just_nums_data) : 'x' must be a numeric matrix
I guess my confusion lays in the fact that the type “int” satisfies is.numeric() but doesn’t count as numeric when it is passed to heatmap(). Is this what is wrong?
heatmaprequiresxto be a numeric matrix (see?heatmap).is.numeric(x)or more specifically a
numericobject with 2 dimensionslength(di <- dim(x)) != 2 || !is.numeric(x))data.frameis not a numeric matrix, even if all the columns are numericFor example:
So, you would need to run