A Data Science Central Community
I do have more than 200 names. The example stated above is just an example. I have more than 1000 names in my database.
Do you have any idea how to plot the graph base on first letter of the name?
I just drop an one of examples to do it.
Assuming "testdata.csv" has CSV format data.
dat <- read.csv("testdata.csv")
dat$Name.first <- toupper(substr(dat$Name,1,1)) # extract first letter into $Name.first
dat$Name.first <- factor(dat$Name.first, levels = LETTERS, ordered = TRUE) # convert the letters to factor
plot(dat$Name.first, dat$Age) # plot :)
Hi, however the y axis graph wont show the name of the person?
I'm writing a few of example for plotting with names. However I believe it must be impractical way to show more than 1000 of names on the graph.
##  - plot name text.
text(dat$Name.first, jitter(dat$Age), dat$Name, cex=0.8,col="blue")
library(lattice) # library 'lattice' is required for xyplot()
##  plot by name on Y axis.
xyplot(Name ~ Age , dat )
##  plot by name based on first letter.
xyplot(Name ~ Age | Name.first , dat )
What if in my data, it happened to have two 'Angel'.
how do I plot only the Angel and its age data?
Two 'Angel' that you mentioned would be 'Angel' and 'Amelia', they are same of 20-years and had been seen in same point. The function jitter() is used to avoid overlapping, but it seems doesn't work at the time you're running the script.
It's easy way to extract only record that satisfy the condition, e.x.) name is "Angel".
dat.subset <- subset(dat, Name == "Angel")
You're able to plot with new data frame.
Another scenario was what if i wants to plot only variable that is less than 200?
I used the plot(data.table$money > 200) however I felt that it wasn't the graph i wanted.