i am just getting into R and am having a hard time getting started. Currently I am trying to get my Data into a specific graph but i don't really know how to do it.
This is an Example Table similar to that in R just much smaller:
What I want is:
A graph that shows me the average of Cat B
A graph that shows me the average of Cat B but only from "A" in Cat A
A graph that shows me the average of Cat B but only from "B" in Cat A
I have tried working with plots and barplots in all kind of forms and the summary function. But to be honest I have no idea what i am doing and I am getting some usefull graphs but not the ones i want. I can't seem to get an average. How does that work?
really hoping somebody can help a newcomer out
Thanks.
Good luck diving in - if you are new to coding it can definitely be confusing at first.
I'd recommend taking a look at the Software Carpentry R tutorials - taking some time to work through some examples will help you feel a bit more confident : Programming with R
To make a plot of the average of Cat B this sounds like it will be a single point (e.g. mean of all the values in rows 2 to 9). Is that what you are trying to do?
Like all programming languages, it takes some time to get up and running in R. If you're coming to R from another programming language there can also be a bit of a learning curve because things are a little different here.
You can get your data into a data.frame named df with this:
The R function for calculating an average is mean(). To get the mean of all the values in CatB you can say mean(df$CatB), which passes the values in the CatB variable (i.e., column) of your data.frame and returns a single value. To get only certain values of the CatB variable you can subset your data.frame, limiting the selected values to just certain observations (i.e., rows).
The RStudio web site has great resources for learning R. Have a look and you'll soon be making progress.