Select the first 8 plots of sample using plot

The following R code plot 83 different trace plot of I would like to only view the first 8. How can i do this please? Sorry, this is probably very obvious but cannot get to work.

plot(samples_thin, trace = TRUE, density = FALSE)

Many Thanks

assuming that 'samples_thin' is a list containting 83 items, i would try

plot(samples_thin[1:8], trace = TRUE, density = FALSE)

Thanks! samples_thin is a list. I get the following error message:

Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y'

I don't know how samples_thin is created , nor what it does/should contain.
The error message is telling you that it can only plot objects with x and y components.

You have several options if you wish to receive further support. The most complete would be to provided a reproducible example : FAQ: How to do a minimal reproducible example ( reprex ) for beginners

Barring that, if you could share some of the code relating to the creation of samples_thin, that might give enough flavour to make some guesses.

Additionally, you can use
str() to print to console a string representation of samples_thin , maybe calling it on samples_thin[[1]] just to get the first member would be enough.

furthermore you could use the dput() function , on your objects, (mentioned in the reprex doc) as a way of sharing samples_thin with us. again we probably dont need all of it, just a portion.

1 Like

Using this code works:

plot(samples_thin[,1:8], trace = TRUE, density = FALSE)

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