Categories
Mastering Development

Using a different color for a section of a line in ggplot

I am plotting a variety of lines for my plot, using ggplot, each with a specified color. I am plotting estimates as a function of Year (so, these are time series data). However, two of the lines that I plotted have overlap for the first 138 years. What I would like to do is shade […]

Categories
Mastering Development

Problems with shape files

I want to make a map with the coronavirus infected people by state in US . So the idea is to visualize a map with all states of US and see a range of infected people( i.e 500-2000 , etc) in all the map. This should be represented by different shades of one color. The […]

Categories
Development

How to sample 90/10 split% rows out of 2 columns

I have the following data frame: df <- structure(list(Col1 = c(10L,14L,9L,42L,67L,3L,54L,93L,34L,22L), Col2 = c(20L,34L,29L,7L,11L,67L,84L,73L,35L,58L)), class = “data.frame”, row.names = c(NA, -10L)) which looks like: Col1 Col2 10 20 14 34 9 29 42 7 67 11 3 67 54 84 93 73 34 35 22 58 I want to append a new column Col3 that […]

Categories
Development

R conditional calculation for variables

I am trying to create a conditional sum for each row in my data frame according two different lists objects. The idea is that check the row value/values (some of them are list object) and assign 1 or -1 for each value/values and find the total for it/them. For example; df row 7 has c(“cuneytozdemir”, […]

Categories
Development

ggplot – bar plot with overlaid line graph – grouping

I’ve seen this question answered a few times, but can’t seem to solve it using the advice on the various posts I’ve found. I have a sample data set attached (dput output at bottom). I’m trying this ggplot call to overlay a line graph of the ‘scrapcount’ column grouped by year, but getting a mix […]

Categories
Development

How can I rearrange the date from d-m-y to m-d-y in R?

I am having issues with the following R code. I am trying to rearrange csv date values in a column from day-month-year to month-day-year. To issues arise: the format is changed to year-month-day instead, and this error message appears when I attempt to plot the results: Error: Column New_Date is a date/time and must be […]

Categories
Development

gganimate change axes between frames

I am trying to plot the top 3 NHL scorers over time using gganimate. Currently, I have a column chart where the x axis shows player names and the y axis shows number of goals for each player. Here’s a static version of what I have: library(ggplot2) data <- data.frame(name=c(“John”,”Paul”,”George”,”Ringo”,”Pete”,”John”,”Paul”,”George”,”Ringo”,”Pete”), year = c(“1997”, “1997”, “1997”, […]

Categories
Development

Stacked Barplot using ggplot() for a counting table

I have a problem since 2/3 days and I really hope someone would be able to help me. I have a dataframe with the number of bacteria species in different samples and I want to represent them in a stacked barplot (with ggplot()). My dataframe is like this : > head(Table_count) taxonomy 1 Bacteria(100);Proteobacteria(99);Alphaproteobacteria(99);Rhodospirillales(99);Acetobacteraceae(99);Roseomonas(97); 2 […]

Categories
Development

Divide barplot into “subsections” with ggplot2

I want to divide my barplot into areas so that certain areas of the X-axis lie within those areas. I’ll try to attach two photos. The one with the green line is the one I want to reproduce (but the green line is not important to me) and the other one is my plot I […]

Categories
Development

How to apply a simple operation in a matrice with specific columns?

On this data frame DTA : structure(list(VARIETE = structure(c(6L, 7L, 35L, 13L, 1L, 5L ), .Label = c(“ADVISOR”, “ALBATOR”, “AMBOISE”, “APOSTEL”, “AUCKLAND”, “BERGAMO”, “CELLULE”, “CHEVIGNON”, “COMPLICE”, “CONCRET”, “CREEK”, “FILON”, “FRUCTIDOR”, “GEDSER”, “HYKING”, “HYNVICTUS”, “JAIDOR”, “JOHNSON”, “KWS DAKOTANA”, “KWS EXTASE”, “LEANDRE”, “LG ABSALON”, “LG ANDROID”, “LUMINON”, “MAORI”, “MUTIC”, “NEMO”, “PASTORAL”, “RGT CESARIO”, “RGT GOLDENO”, “RGT LIBRAVO”, […]