I am trying to add a new row to my data frame which was a table before. When I try adding a new row by using rbind command it gives me a warning message and doesn’t add the vector I tried inserting. Please find my commands and output as below.
A9 <- BreastCancerData$V10
A9 <- table(A9)/nrow(BreastCancerData) //Generating a table of values
A9 <- as.data.frame(A9)//Table to Data Frame Conversion.
myvec <- c(9,0)
rbind(A9,myvec)[c(1,2,3,4,5,6,7,8,10,9),]
Output:
A9 Freq
1 1 0.823703704
2 2 0.051851852
3 3 0.047407407
4 4 0.017777778
5 5 0.008888889
6 6 0.004444444
7 7 0.013333333
8 8 0.011851852
10 <NA> 0.000000000
9 10 0.020740741
Warning message:
In `[<-.factor`(`*tmp*`, ri, value = 9) :
invalid factor level, NAs generated
Why not just do:
and save yourself some hassle? Or, if you want to be a bit sneakier,