1

My real data has 91 continuous categorical values with counts ranging from 1,230 to 300,239. So that means I have a table with 91 categories and 91 corresponding y values counting how many points fall within that categories. How would I go about creating a density function for this data since R's density function takes in non tabulated data? Or how do I un-tabulate my data?

How do I get the function to accept data that looks like this?

y<-c(2,3,1)
x<-c(0,1,2)
fakedata<-cbind(x,y)
fakedata_density<-density(fakedata, from=0, to=2, n=3)

For example, if you have non tabulated data than the density function will produce a different image like the example below that uses the same data but different format.

data<-c(1,1,1,0,0,2)
data_density<-density(data, from=0, to =2, n=3) #A kernel is produced for 
#each categorical value 0, 1, and 2. 

plot(data_density)# this works
Meli
  • 345
  • 5
  • 15
  • Just to be clear density(fakedata, from=0, to =2, n=3) does not produce the correct result. The desired result is below with the same data but different format. Thank you. – Meli Nov 10 '15 at 03:50

0 Answers0