Plotting functional data and using the package "hyperSpec"


Problems creating a hyperSpec object

Hello everyone,

I am currently trying to develop my plotting skills…again-.- Functional data such as this figure is what I want to plot most of the time. Usually I am doing this just by using ggplot2 and wrangling the data into the correct format. But now I stumbled across the package “hyperSpec” which is obviously designed for people like me. This package is actually using the environment of ggplot2…The problem is that I am struggling with creating the basic object needed to use this package. I do not know how my data should look like, even after reading the manual:frowning: Page 3 explains how to create such an object but I failed to understand that…

Can anyone help me with that?

Thanks for trying…



Hi Rene,

What do your data look like? The figure you refer to is nice and easy to make using plot(..., type="l") and adding other lines using lines(...). So I’m guessing you have some unusual data format.

Knowing what kind of data you have would also help troubleshoot your hyperSpec object issue.



Hi Rene,

Take a look at some of the other vignettes included in the package, listed here (there’s more than one ‘manual’ that goes with the package). Several seem to contain worked examples, so you can look at the worked examples and see how the data is formatted. For example, flu.pdf

A slight complication was that when i looked for the rawdata that supposedly comes with the package, it wasn’t where it was supposed to be! But that’s easily overcome. Download the package source, then look in folder vignettes/rawdata/. Then work through some of the examples. With these files you should be able to run all the examples in the package and from that see what structure you need.


Thanks for your help…I was somehow distracted by other tasks so I took me a while to respond. Plotting the data is not the problem…I know that this can be solved easily with your solution or ggplot. Attached an excerpt of my datatable in wide-format…to plot it in ggplot I would transform it to long-format…

I think that Dan’s tips are quite helpful to create a basic object in hyperSpec…I am just keen to use this package…it seems to have useful functions.

My data has two statuses…Healthy/Infected. One sample is a f(Wavelength)…350nm - 2500nm.