I have the following data set:
\(
\begin{tabular}{|l c r|}
\hline
X & Y & Type \\
\hline
32 & 48.5 & A \\
36.3 & 42.9 & A \\
45.8 & 75.8 & A \\
60.5 & 5457.6 & B \\
12 & 6666 & B \\
24.2 & 48.5 & C \\
271 & 2796.6 & C \\
\hline
\end{tabular}
\)
Now I have to draw histogram of the variable Y by the variable Type.
\(
\begin{tabular}{|l c r|}
\hline
X & Y & Type \\
\hline
32 & 48.5 & A \\
36.3 & 42.9 & A \\
45.8 & 75.8 & A \\
60.5 & 5457.6 & B \\
12 & 6666 & B \\
24.2 & 48.5 & C \\
271 & 2796.6 & C \\
\hline
\end{tabular}
\)
Now I have to draw histogram of the variable Y by the variable Type.
Code:
data <- data.frame(X=c(32,36.3,45.8,60.5,12,24.2,271),
Y=c(48.5,42.9,75.8,5457.6,6666,48.5,2796.6),
Type=c("A","A","A","B","B","C","C"))
data
with(data, hist(Type~Y) )
Error in hist.default(Type ~ Y) : 'x' must be numeric
>