I'm completely new to R and I've been trying to cut a dataset into the fields that interest me then plot a barplot() of that.
The thing is, I've ran into errors and I cannot continue.
This is my code:
data = infert; # Get a local copy of infert so we can edit stuff.
data <- data[data$case == 0, ]; # Split the data to those that interest us,
# in this case, rows with column 'case' == 0.
data.freq = table(data); # Plot the graph.
barplot(data.freq);
The error I get when I source+run the script:
Error in barplot.default(data.freq) :
'height' must be a vector or a matrix
Which I guess is because the data matrix comes out X*1 instead of X*N? Or it misses a dimension somewhere else, due to me doing data[data$case == 0, ]
?
In any case, how can I get around that and plot a frequency graph of the infert data where infert$case == 0?
Additionally, are there any simplistic ways to plot the relative frequency graph?