Re: [R] Plotting graph problem!!
Yea,i am very new to R. Thanks a lot Jim Lemon! I appreciate it very much!! Hi Andrew, As you seem to be an R newbie and some of the replies may have been cryptic to a newbie, try this: boxplot(a$Life.Expectancies.at.Birth) To explain the above a little bit, when reading in a text file, R does some silent substitutions, like sticking full stops (.) in where there were spaces in the field labels. The dollar sign operator means "return the list element of "a" - a data frame column in this case - that has the name after the dollar sign. That gives the "boxplot" function a vector of numeric values and it knows what to do. These things are so familiar to most of us that we don't bother to explain them. You will probably encounter more of these little mysteries as you progress with R. Good luck. Jim -- View this message in context: http://r.789695.n4.nabble.com/Plotting-graph-problem-tp3389613p3390600.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Plotting graph problem!!
On 03/20/2011 04:33 AM, andrew456 wrote: Thanks a lot for teaching me!!! By the way,one more question,how do i plot a boxplot of that?? Hi Andrew, As you seem to be an R newbie and some of the replies may have been cryptic to a newbie, try this: boxplot(a$Life.Expectancies.at.Birth) To explain the above a little bit, when reading in a text file, R does some silent substitutions, like sticking full stops (.) in where there were spaces in the field labels. The dollar sign operator means "return the list element of "a" - a data frame column in this case - that has the name after the dollar sign. That gives the "boxplot" function a vector of numeric values and it knows what to do. These things are so familiar to most of us that we don't bother to explain them. You will probably encounter more of these little mysteries as you progress with R. Good luck. Jim __ 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.
Re: [R] Plotting graph problem!!
Thanks a lot for teaching me!!! By the way,one more question,how do i plot a boxplot of that?? On 19/03/11 15:04, Allan Engelhardt wrote: > You should probably tell us which part of > > a<- > read.csv("http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv";) > hist(a) Should be hist(a$Life.Expectancies.at.Birth), of course. Sorry. > > -- View this message in context: http://r.789695.n4.nabble.com/Plotting-graph-problem-tp3389613p3390021.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Plotting graph problem!!
I assigned the dataset to data1,then i tried typing hist(data1),it says: Error in hist.default(data1) : 'x' must be numeric how can I change the Locations to frequency so that it is in numeric form and I can plot the histogram? You should probably tell us which part of a<- read.csv("http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv";) hist(a) doesn't do what you expect. (Though often when people say "histogram" they want something else - what's with that anyhow?) Allan -- View this message in context: http://r.789695.n4.nabble.com/Plotting-graph-problem-tp3389613p3389830.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Plotting graph problem!!
> data1<-read.delim("C:\\Users\\wenyin\\desktop\\Life_Expectancies_2008.txt",header=T) > attach(data1) > names(data1) > table(Life.Expectancies.at.Birth) so this thing showed up: Life.Expectancies.at.Birth 42 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 2 2 1 4 4 1 2 2 5 5 1 2 3 5 3 2 6 6 3 3 1 5 6 7 8 6 72 73 74 75 76 77 78 79 80 81 82 83 13 11 14 9 8 2 5 3 12 8 5 2 -- View this message in context: http://r.789695.n4.nabble.com/Plotting-graph-problem-tp3389613p3389759.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Plotting graph problem!!
On 19/03/11 15:04, Allan Engelhardt wrote: You should probably tell us which part of a<- read.csv("http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv";) hist(a) Should be hist(a$Life.Expectancies.at.Birth), of course. Sorry. doesn't do what you expect. (Though often when people say "histogram" they want something else - what's with that anyhow?) Allan On 19/03/11 13:10, andrew456 wrote: http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv Life_Expectancies_2008.csv I am trying to plot a histogram base on the file i uploaded above. I am facing a trouble in sorting out the frequency of the life expectancies. I wanted to plot a graph of life expectancies at birth versus frequency,but i have no idea how to change the locations into frequencies taking the range of life expectancies at birth from 40 to 90. I tried using table(Life.Expectancies.at.Birth) to show the frequencies of each number and I do not know how to continue. -- View this message in context: http://r.789695.n4.nabble.com/Plotting-graph-problem-tp3389613p3389613.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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.
Re: [R] Plotting graph problem!!
You should probably tell us which part of a<- read.csv("http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv";) hist(a) doesn't do what you expect. (Though often when people say "histogram" they want something else - what's with that anyhow?) Allan On 19/03/11 13:10, andrew456 wrote: http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv Life_Expectancies_2008.csv I am trying to plot a histogram base on the file i uploaded above. I am facing a trouble in sorting out the frequency of the life expectancies. I wanted to plot a graph of life expectancies at birth versus frequency,but i have no idea how to change the locations into frequencies taking the range of life expectancies at birth from 40 to 90. I tried using table(Life.Expectancies.at.Birth) to show the frequencies of each number and I do not know how to continue. -- View this message in context: http://r.789695.n4.nabble.com/Plotting-graph-problem-tp3389613p3389613.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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.
Re: [R] Plotting graph problem!!
On Mar 19, 2011, at 9:10 AM, andrew456 wrote: http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv Life_Expectancies_2008.csv I am trying to plot a histogram base on the file i uploaded above. I am facing a trouble in sorting out the frequency of the life expectancies. I wanted to plot a graph of life expectancies at birth versus frequency,but i have no idea how to change the locations into frequencies taking the range of life expectancies at birth from 40 to 90. I tried using table(Life.Expectancies.at.Birth) to show the frequencies of each number and I do not know how to continue. You should show how you turned that data into an R object first. Then someone may offer a hint to take the next step in your homework. -- David Winsemius, MD West Hartford, CT __ 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.
[R] Plotting graph problem!!
http://r.789695.n4.nabble.com/file/n3389613/Life_Expectancies_2008.csv Life_Expectancies_2008.csv I am trying to plot a histogram base on the file i uploaded above. I am facing a trouble in sorting out the frequency of the life expectancies. I wanted to plot a graph of life expectancies at birth versus frequency,but i have no idea how to change the locations into frequencies taking the range of life expectancies at birth from 40 to 90. I tried using table(Life.Expectancies.at.Birth) to show the frequencies of each number and I do not know how to continue. -- View this message in context: http://r.789695.n4.nabble.com/Plotting-graph-problem-tp3389613p3389613.html Sent from the R help mailing list archive at Nabble.com. __ 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.