R Scatterplot/bubble chart with dot size based on observation number

tlorin

I know this question has been somewhat answered here, here and here.

In all of these examples the dot/bubble size is based on a third factor such as size.

However, in my data, I only have 2 variables, xval and yval.

library("ggplot2")
xval <- c("0","0.5","0.25","0","0")
yval <- c("1","0.5","0.25","0.25","1")
df.test <- data.frame(xval,yval)
df.test
p <- ggplot(df.test, aes(x = xval, y = yval)) + geom_point()
p

Here is df.test

  xval yval
1    0    1
2  0.5  0.5
3 0.25 0.25
4    0 0.25
5    0    1

and here is p

enter image description here

What I would like is each dot/bubble size to depend on the number of occurrence of the observations of this coordinate. For instance, (0,1) would be to be twice as big as the others dots. I would like to avoid adding a 3rd column to my data frame, and leaving R doing it automatically.

I don't know if this can be done without having to play too much with the data... Any insight would be much appreciated :)

Warner

Use geom_count()

xval <- c("0","0.5","0.25","0","0")
yval <- c("1","0.5","0.25","0.25","1")
df.test <- data.frame(xval,yval)
df.test

ggplot(df.test, aes(x = xval, y = yval)) + geom_count()

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Animated dot histogram, built observation by observation (using gganimate in R)

R dot plot with custom dot size

Number of Observation and variables are not equal in data frame R

How to expand the number of rows per observation in R

Observation number as marker in PCA using Plotly in R

R ifelse based on an observation meeting two criteria

Create variable based on next observation in R

Create a variable based on lagged observation values in R

Conditional formatting of decimals in tick labels based on number size in ggplot r

Network graph using R: Node size based on number of connected edges

PySpark:number group of group type based on observation sequence

How to count the number of observation that fall in quarter based on start and end date?

Visualization of coefficients in R (dot-chart)

How to find number of observation between first observation and first two consecutive negative observations in r

R - rbinom; what does the probability of success define if there is N number of observation?

R reshape a data frame to get the total number of appearance of an observation

calculate count of number observation for all variables at once in R

SQL script in R giving only limited number of observation

R - Creating a new column based on a conditional observation and applying it to the master df

How to add a variable based on order of observation in a dataframe - R

Create new columns based on part of an observation in another column in r

Basemap - draw points on map depending on coordinates; dot size = number of occurences

Pie chart based on table in R

Replace observation number with another

Add Dot to Line Chart using ggplot2 in R

How to display the dot of a decimal based on the locale but without being in a decimal number?

Center Text QML type based on the dot of a decimal number

How to find number of observation between first observation and observation with maximal value

Plot one dot per each observation in a day

TOP Ranking

HotTag

Archive