Hi everybody!

I'm trying to write a script to plot a histogram, a boxplot and a 
qq-plot (under Windows XP, R2.10 if it matters)

What I want to do: define the variables (x and y) to be used at the very 
beginning, so that I don't have to change all occurrences in the script 
when I want to plot a different variable.

The dataset is called "ssfa". TO_POS is a categorical variable 
containing the tooth position for each sample. Asfc is a numerical 
variable. In my dataset, I have more variables but it wouldn't change; I 
want to plot one numeric vs one category. Do I need to supply some data? 
I don't think it's really necessary but let me know if you would like to.

The code of what I do up to now:
---
x <- ssfa$TO_POS
y <- ssfa$Asfc
hist(y, main="Histogram of Asfc", xlab="Asfc")
boxplot(y~x, main="Boxplot of Asfc by TO_POS", xlab="TO_POS", ylab="Asfc")
---

I would like something like: hist(y, main="Histogram of y", xlab="y") 
but that will add "Asfc" where I write "y".
And the same for boxplot(y~x, main="Boxplot of y by x", xlab="x", ylab="y")
I thought about something like:
---
cat <- "TO_POS"
num <- "Asfc"
x <- paste("ssfa$", "TO_POS", sep="")
y <- paste("ssfa$", "Asfc", sep="")
hist(y, main=paste("Histogram of ", cat, sep=""), xlab=num)
---
but it doesn't work since y is a string. I don't know how to get the 
syntax correctly. I am on the right path at least?!

Your help would be greatly appreciated!
Ivan*
*

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to