I have a dataframe data in R of dim 102500 rows by 41 columns.
Each 41 lines is a frame measured at different time intervals (ie 2500 frames). I need to do heatmap in each data frame, and at the end visualize it as a 3D to show each layer separably by going through the layers.
Could you please explain what the end result is supposed to look like. I don't understand the 3D part as you said you want to create 41 heatmaps and use the heatmap1 function although there is a profileplot3d function in that package as well, which does look confusion I must say.
I also suggest you read how to create a reprex, as your code now is very confusing. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:
I don't think this is what you want, but here is some code I wrote based on your question:
library(NeatMap)
#Generate a dummy matrix
m1 = matrix(1:(41*2500*41), nrow=41*2500, ncol=41)
#Split into 41 matrices of each 2500 rows
m1 = lapply(1:41, function(x){
m1[(1+2500*(x-1)):(2500*x),]
})
#Generate a heatmap for every of the 41 matrices
heatmaps = lapply(m1, heatmap1)
#Render a heatmap
heatmaps[[1]]
Please elaborate and update the code, and we can work from there.
Thank you for your response. I attached a picture as an example of what my data is supposed to look like at the end. In this picture, you're just able to see 1/2500 part of the entire data. It mean it includes the data from 41 columns and 41 rows (out of 102500 rows). But as you go through the movie, you can see the different layers of the dateset (2500 different layers).
I used your code (with a little bit of change to split the data into 2500 matrices of each 41 rows), and I tried to use the matrix to use it in my data (which I called it snap) as follow:
Thank for your input. I think I'll be able to use it for my data visualization. I tried to replace my data (snap) with the part that you populated your data as follow:
you don't need your own version of matvals_k, that was just so I could populate a1 with something more interesting than all zero.
if your data is snap you should use
a1 <- array(snap, c(41, 41, 2500))
and delete the rest until
# first frame is a1[,,1] , second frame is a1[,,2]
num_frame <- reactiveVal(1)
well, one thing to watch out for is that the way snap is populated, is cut to the dimensions correctly
41x41x2500 assumes a particular layout that may be incorrect. it might be 2500,41,41 or 41,2500,41
Theres not principled way for me over here to know that...
I'll try both to see how do they look. But basically snap is a csv format, that has 102500 rows and 41 columns. I've been trying to split the 102500 rows to 2500 data frames (2500 X 41 rows).
I'll play around with the codes to see if I can get my desire outcome. Thank you very much again.