Problems with importing data set

When I import an .Rdata-file, I can usually see a nice table. Now, there's no table and I don't know how to import my data file in such a way that I can actually use my data for analysis (see picture below). What can I do to make it work?

(I have hardly any R experience so I have no clue what I'm doing and this question is quite possibly very stupid but I could not find the answer anywhere on the internet so please help me. And I'm sorry if I put this message in the wrong part of the forum.)

Your data are stored in a List which is a collection data where each element can be a different type of object. The List is called sugar and contains two things: a vector of 266 numbers called ash and a matrix of numbers that has 266 rows and 472 columns called NIR. You can get the individual components of the List like this.

My_ash <- sugar$ash
My_NIR <- sugar$NIR

However, it is likely that the components ash and NIR belong together. Do you know how the List sugar was made?

Thank you for your answer!

When I use the code you provided, where am I supposed to be able to view the components? When I run the code, nothing shows up.

I do not know how it was made, my university provided me with it and I have to use it for an assignment.

If you successfully run the code then My_ash and My_NIR will appear in the same pane on the right where you can see sugar. Are you sure you ran the code? If you type it into the Script pane on the upper left, individual lines can be run by placing the cursor on the line and pressing CTRL + Enter.

O, I did run it, but I didn't look in the correct spot >.< Thanks haha

I was so confused with this data set, as in previous assignments I only had to use 'regular' csv-tables.

So now I tried to do the analysis with the data the way it is. The first question is: Estimate the prediction error for a lasso model where lambda is chosen using cross validation. Report the (i) MSE and (ii) the optimal lambda (the minimum value).

So I started by entering:

folds <- split(sample(1:nrow(sugar)), 1:10)

In my script.

Result in the console:
Error in 1:nrow(sugar) : argument of length 0

Does this 'argument of length 0' have anything to do with the way the data is stored?

If you are using a lasso model then my guess is that the dependent variable is the ash part of sugar and independent variables are in NIR. Either of the following should return 266



My_NIR <- sugar$NIR

You can probably use My_ash and My_NIR in your fitting, though I do not know what functions you will use.

Yes, nrow(sugar$NIR) returns 266 and I'm using a lasso model :slight_smile: And NIR=fluorescence spectra. Goal is to predict ash content from the spectra. So ash is indeed the dependent variable.

I honestly have hardly any clue what I'm doing, as I'm not very good at this whole distance learning thing, I miss my on campus education, but your help is highly appreciated!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.