I am new to R and would like to use it for my data analysis and visualization.
I have a dataframe with about 38575 rows (pixels) and 600 columns. Each column contains the intensity of an analyte, resulting in a spectrum per pixel. I also have x and y coordinates for each pixel to create a data cube(array), in the sense that if I say image_cube[1,1,] gives me the first spectrum and if I say image_cube[,,1], I get an image of all pixels showing the intensity for the first analyte. Not all pixels have a spectrum and they are not in the dataframe, these should just be empty pixels (black).
EDIT
I tried to use the following code with ROI data being the big dataframe and sample_overview the variable containing x and y coordinates for each pixel:
ROI_cube <- array(rep(0, 311*381*603), dim=c(311, 381, 603))
for (i in 1:dim(ROI_data)[1]) {
ROI_cube[sample_overview[i,2], sample_overview[i,1],] = ROI_data[i,]
}
But I get the following error:
Error in ROI_cube[sample_overview[i, 1], sample_overview[i, 2], ] <- ROI_data[i, :
incorrect number of subscripts