arindam fadikar
2011-Jan-30 10:48 UTC
[R] how to enter frequency type data in R with class intervals
Dear all, Given data of a continuous frequency distribution with class intervals .. how to enter such data so that we can use the normal mean, median and mode functions to calculate them and also can draw histogram .. for example how to enter this data in R Height range[image: ↓]<http://en.wikipedia.org/wiki/Frequency_distribution#> Number of students[image: ↓] <http://en.wikipedia.org/wiki/Frequency_distribution#> Cumulative number[image: ↓] <http://en.wikipedia.org/wiki/Frequency_distribution#> 4.5–5.0 feet 25 25 5.0–5.5 feet 35 60 5.5–6 feet 20 80 6.0–6.5 feet 20 100 -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]]
David Winsemius
2011-Jan-30 16:18 UTC
[R] how to enter frequency type data in R with class intervals
On Jan 30, 2011, at 5:48 AM, arindam fadikar wrote:> Dear all, > > Given data of a continuous frequency distribution with class > intervals .. > how to enter such data so that we can use the normal mean, median > and mode > functions to calculate them and also can draw histogram .. > > for example how to enter this data in R > > Height range[image: > ?]<http://en.wikipedia.org/wiki/Frequency_distribution#> Number > of students[image: ?] > <http://en.wikipedia.org/wiki/Frequency_distribution#> Cumulative > number[image: ?] <http://en.wikipedia.org/wiki/ > Frequency_distribution#> 4.5?5.0 > feet 25 25 5.0?5.5 feet 35 60 5.5?6 feet 20 80 6.0?6.5 feet 20 > 100The textConnection function allows you to simulate file input from material cut and pasted from text sources: > dtabl <- read.table(textConnection("4.5?5.0 feet 25 25 \n5.0?5.5 feet 35 60 \n5.5?6 feet 20 80 \n6.0?6.5 feet 20 100"), header=FALSE, stringsAsFactors=FALSE) > names(dtabl) <- c("Interval", "units", "Freq", "Cum_Freq") > dtabl Interval units Freq Cum_Freq 1 4.5?5.0 feet 25 25 2 5.0?5.5 feet 35 60 3 5.5?6 feet 20 80 4 6.0?6.5 feet 20 100 You may need to remove extraneous linefeeds inserted by our mail clients. -- David Winsemius, MD West Hartford, CT