1

Hi i have an error whenever i am trying to create a tabular using multicolumn. i want to make first column empty but i am getting an error. Could anyone help?

<<Q4o3,echo=FALSE>>=

#Data for the second quarter of 2019 by each month 
O3_2019_4th = c(35.5,37.4,34.4,29.8,26.1,16.9,14.7,6.4,8,6.7,6.2,17.1,31.2,23.9,36.6,20.1,15.4,28.6,18.7,16.8,7.8,6.2,5.6,7.3,8.9,8.9,33.6,33.6,17.5,7.8)

O3_2019_5th = c(10.7,21.2,37.7,39.3,39,27.8,31.1,29,14,12.5,33.2,36.6,25.8,10.6,5.2,6.3,6.7,12.2,16,10.9,36.9,39.6,31.7,37.5,18.9,10.6,4.2,3.4,28.1,35.8,15)

O3_2019_6th = c(8.3,6.3,8.4,4.7,3.7,8.5,10.8,9.8,10.2,9.4,4.4,7.9,10.3,25.3,30.1,48.1,28.1,9.3,5.5,5.3,7.8,7.4,8,6.4,5.8,7.2,8.6,11.9,12.3,11.6)

o3a1=mean(O3_2019_4th)
o3a2=mean(O3_2019_5th)
o3a3=mean(O3_2019_6th)

o3a4=sd(O3_2019_4th)
o3a5=sd(O3_2019_5th)
o3a6=sd(O3_2019_6th)

o3a7=min(O3_2019_4th)
o3a8=min(O3_2019_5th)
o3a9=min(O3_2019_6th)

o3a10=max(O3_2019_4th)
o3a11=max(O3_2019_5th)
o3a12=max(O3_2019_6th)

o3a13=mode(O3_2019_4th)
o3a14=mode(O3_2019_5th)
o3a15=mode(O3_2019_6th)

o3a16=var(O3_2019_4th)
o3a17=var(O3_2019_5th)
o3a18=var(O3_2019_6th)

o3a19=median(O3_2019_4th)
o3a20=median(O3_2019_5th)
o3a21=median(O3_2019_6th)

#Data for the second quarter of 2020 by each month 
O3_2020_4th = c(3.1,34.3,27.7,18.9,21.2,18.3,7.7,32.4,34.7,44.6,28.3,34.2,40.1,34.5,28.7,19,18.6,12.8,11.9,6.6,6.6,25.5,20.6,12.7,11.9,35.5,29.6,40.2,38.8,27.1)
            
O3_2020_5th = c(13.1,9.9,10.8,7.6,8.8,7.5,8.5,8.1,7.9,9.8,8.7,18.6,33.9,32.3,17.9,7.5,9.6,10.9,15,23.6,10.9,13.5,27.4,31.8,13.7,8.2,6.5,19.1,21,4.2,7.9)

O3_2020_6th = c(5.3,9.3,9.3,10.1,9.6,8.7,7.9,8,8.6,7.8,7.3,11.6,16,10.8,7.4,7.2,8.6,8.8,9.18,8.8,8.9,9.6,9.8,8,8.4,9.6,7.8,7.5)

o3b1=mean(O3_2020_4th)
o3b2=mean(O3_2020_5th)
o3b3=mean(O3_2020_6th)

o3b4=sd(O3_2020_4th)
o3b5=sd(O3_2020_5th)
o3b6=sd(O3_2020_6th)

o3b7=min(O3_2020_4th)
o3b8=min(O3_2020_5th)
o3b9=min(O3_2020_6th)

o3b10=max(O3_2020_4th)
o3b11=max(O3_2020_5th)
o3b12=max(O3_2020_6th)

o3b13=mode(O3_2020_4th)
o3b14=mode(O3_2020_5th)
o3b15=mode(O3_2020_6th)

o3b16=var(O3_2020_4th)
o3b17=var(O3_2020_5th)
o3b18=var(O3_2020_6th)

o3b19=median(O3_2020_4th)
o3b20=median(O3_2020_5th)
o3b21=median(O3_2020_6th)


@

\textbf{Substance O3}\\

\begin{table}[h]
\begin{tabular}{llllllll}

 & \multicolumn{2}{1}{4th month} & \multicolumn{2}{1}{5th month} & \multicolumn{2}{1}{6th month} \\
  & 2019 & 2020 & 2019 & 2020 & 2019 & 2020 \\
mean               & \Sexpr{o3a1}  & \Sexpr{o3b1}  & \Sexpr{o3a2}  & \Sexpr{o3b2}  & \Sexpr{o3a3}  & \Sexpr{o3b3} \\
median             & \Sexpr{o3a19} & \Sexpr{o3b19} & \Sexpr{o3a20} & \Sexpr{o3b20} & \Sexpr{o3a21} & \Sexpr{o3b21}\\
standard deviation & \Sexpr{o3a4}  & \Sexpr{o3b4}  & \Sexpr{o3a5}  & \Sexpr{o3b5}  & \Sexpr{o3a6}  & \Sexpr{o3b6} \\
min                & \Sexpr{o3a7}  & \Sexpr{o3b7}  & \Sexpr{o3a8}  & \Sexpr{o3b8}  & \Sexpr{o3a9}  & \Sexpr{o3b9} \\
max                & \Sexpr{o3a10} & \Sexpr{o3b10} & \Sexpr{o3a11} & \Sexpr{o3b11} & \Sexpr{o3a12} & \Sexpr{o3b12}\\
mode               & \Sexpr{o3a13} & \Sexpr{o3b13} & \Sexpr{o3a14} & \Sexpr{o3b14} & \Sexpr{o3a15} & \Sexpr{o3b15}\\
variance           & \Sexpr{o3a16} & \Sexpr{o3b16} & \Sexpr{o3a17} & \Sexpr{o3b17} & \Sexpr{o3a18} & \Sexpr{o3b18}             
\end{tabular}
\end{table}
3
  • You have not provided a usable example (You do not say but I think this is R? not a TeX file?) But I would guess that your issue is not with the table but with \textbf{Substance O3}\\ where the trailing \\ will give the warning in the title. Nov 19 '20 at 8:57
  • @Lee probably something like in the answer below -- I have removed the \Sexpr since it is not defined
    – js bibra
    Nov 19 '20 at 8:57
  • most likely a duplicate of tex.stackexchange.com/a/334249/1090 Nov 19 '20 at 8:59
-1

enter image description here

\begin{table}[h]
    \begin{tabular}{llllllll}
        
        & \multicolumn{2}{c}{4th month} & \multicolumn{2}{c}{5th month} & \multicolumn{2}{c}{6th month} \\\cmidrule{2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
        & 2019 & 2020 & 2019 & 2020 & 2019 & 2020 \\\cmidrule{2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}\rowcolor{black!20}
        mean               & {o3a1}  & {o3b1}  & {o3a2}  & {o3b2}  & {o3a3}  & {o3b3} \\
        median             & {o3a19} & {o3b19} & {o3a20} & {o3b20} & {o3a21} & {o3b21}\\\rowcolor{black!20}
        standard deviation & {o3a4}  & {o3b4}  & {o3a5}  & {o3b5}  & {o3a6}  & {o3b6} \\
        min                & {o3a7}  & {o3b7}  & {o3a8}  & {o3b8}  & {o3a9}  & {o3b9} \\\rowcolor{black!20}
        max                & {o3a10} & {o3b10} & {o3a11} & {o3b11} & {o3a12} & {o3b12}\\
        mode               & {o3a13} & {o3b13} & {o3a14} & {o3b14} & {o3a15} & {o3b15}\\\rowcolor{black!20}
        variance           & {o3a16} & {o3b16} & {o3a17} & {o3b17} & {o3a18} & {o3b18}             
    \end{tabular}
\end{table}
2
  • 3
    That probably won't remove the underful box warning in the title (which is unlikely to have come from the table, see my comment under the question) Nov 19 '20 at 8:58
  • 1
    I've tried this, it gives me an error 'undefined control sequence'
    – James
    Nov 19 '20 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.