Question: I have this basic code that is meant to ask the user how many integers to input, get the user to input specified numbers for each integer and then reprint the integers the user typed in, except instead of printing the integers it just prints 0's

```
int getInts(int * integersArray, int numInput);

int main() {
    int * integersArray;
    int numInput;
    int i;

    numInput = getInts(integersArray, numInput);

    for (i = 0; i < numInput; i++) {
        printf("%d ",integersArray[i]);
    }

    return 0;
}

int getInts(int * integersArray, int numInput) {
    int i;

    printf("Please enter the number of integers you want to input\n");
    scanf("%d", &numInput);

    integersArray = (int *) malloc(sizeof(int) * numInput);

    for (i = 0; i < numInput; i++) {
        printf("please enter integer %d: ", i+1);
        scanf("%d", &(integersArray[i]));
    }

    return numInput;
}

```

Answer: 
Here is the `lattice` version. Essentially you define a vector of colors, which I did outside the `histogram()` function. In the `histogram()` function you use a `panel.function` which will allow you to make each panel look different. You call `panel.histogram` and tell it to pick a color based on `packet.number()`. That function just returns an integer indicating which panel is being drawn, panel 1 gets red, panel 2 gets blue etc.

```
Para = as.vector(rnorm(100, mean=180, sd=35))
Year = as.vector(c(rep(1,25),rep(2,25),rep(3,25), rep(4,25)))
df = as.data.frame(cbind(Para,Year))

colors<-c("red","blue","green","purple")  #Define colors for the histograms

print(histogram(~Para | Year, data = df,  scales=list(cex=c(1.0,1.0)), 
    layout=c(4,1), type="count", xlab=list("Parameter", fontsize=16), 
    ylab=list("Frequency", fontsize=16), 
    strip=function(bg='white',...) strip.default(bg='white',...), 
    breaks=seq(0,300, by=50), ylim=seq(0,35,by=10),
    as.table=TRUE, groups=Year,col=colors, #passing your colors to col

    panel=function(x, col=col,...){
    panel.histogram(x,col=col[packet.number()],...) #gets color for each panel
    }
))

```
You may try a `ggplot` alternative:

```
library(ggplot2)
ggplot(data = df, aes(x = Para, fill = factor(Year))) +
  geom_histogram() +
  facet_wrap(~ Year) +
  scale_fill_manual(values = c("red", "blue", "green", "purple"))

```

![enter image description here](https://i.stack.imgur.com/ep6M0.png)

To colour the strip background by Year, you may have a look [**here**](https://stackoverflow.com/questions/19440069/ggplot2-facet-wrap-strip-color-based-on-variable-in-data-set) for some ideas.