Does density() function in base R assume normality? I'm plotting a vector as a density plot and it seems that as I increased the bandwidth, the distribution looks more and more normally distributed. Does density function in R assume normality? If yes, is there any other method to plot non-normal data?
Code:
plot(density(data$somevector))

 A: The density function and generally kernel density estimation does not assume normality. However in order to estimate a density at good quality, it requires a reasonable bandwith; particularly with more data the bandwith should go down so that more detail in the density is visible. The default is to use a Gaussian kernel, and this will indeed make the density look more Gaussian if the bandwith becomes bigger and bigger (regardless of the true density), but that's not a reasonable thing to do, and in fact not what the function is doing as a default. The default is, according to the help page, chosen "for historical and compatibility reasons, rather than as a general recommendation", however it will at least have the bandwith go down for more observations in a more or less reasonable way (see help of bw.nrd).
So no, this does not require normality, and what you observed has nothing to do with "assuming normality", but rather with the fact that if you choose the bandwidth far too large, you only see the shape of the smoothing kernel, but not a reasonable density estimator for the data.
Edit: To explain the relation to normality a bit more: The density default uses the Gaussian distribution as "smoothing kernel". This means that in order to estimate the density at one point, the points surrounding it are taken into account with weights according to a window that looks like the Gaussian density, and a Gaussian with small variance is placed around it, which, together with other such small Gaussians around neighbouring points will approximate a flexible density (I'm not formally precise here, I hope this is intuitive). There is some theory that every density can be approximated arbitrarily well by a mixture of Gaussians, and one method to do this is to put together one small variance Gaussian for every data point. The variance (bandwidth) needs to be small however in order for this to work (the tricky thing is that it needs to be small, but not too small).
The Gaussian kernel is chosen not because of any "assumption" of Gaussianity, but rather because the Gaussian shape with a fairly wide area in the middle of a large density and then going down smoothly but quickly when moving away from the center has good properties for density estimation, although there are alternatives. However if you choose the bandwidth very very large, what will happen is that the area of a fairly large density of the Gaussian kernel "window" will cover all data points, all the Gaussians for the different data points will look fairly similar, and the speed at which the tails go down on the left and right side will no longer be determined by data but it will just look more or less like a Gaussian, as the raw kernel shape will then dominate the information from the data.
A: A mere illustration that the choice of the kernel $K$ in the kernel density estimator
$$\frac{1}{N}\sum_{i=1}^n \frac{1}{h_n}K\left(\frac{x-x_i}{h_n} \right)$$
has hardly any impact, when compared with the impact of the bandwidth $h_n$.

The data is made of 90 observations
x=c(rnorm(20),rt(df=3,n=30)+1,sqrt(rgamma(sh=4,n=40))-2)

and the bandwidths vary from $0.1$ to $2$ default bandwidth
b=c(.1,.5,1.5,2)
for(i in 1:4)lines(density(x,bw=b[i]))

