Most voted "r" questions
R is an open-source environment and programming language for statistical computing, bioinformatics, and graphics. It is advisable to supplement your question with a minimum reproducible example.
Learn more…2,359 questions
Sort by count of
-
2
votes1
answer600
viewsHow to order x-axis that is date in ascending order?
I have a graph where the x-axis are the dates, but when ordering chronologically, because before it was in alphabetical order, the information of the graph is wrong because the data follows the…
-
2
votes2
answers649
viewsSum of vector in R
I have a vector of integer values in R, for example: y = c(rep(1:4, c(36,9,2,1)), 6, 6) and I need to make a sum within a function, like this: that is, I need to do…
rasked 5 years, 1 month ago user164705 23 -
2
votes1
answer101
viewsHow to save a rpart.Plot chart?
I am working with Décision Tree and at the end I have the chart that represents it. However, as it is a different object from other types of the ggplot or ggpubr family, I am not able to save by the…
-
2
votes2
answers92
viewsA - How to display repeat progress ? And processing time?
Hello ! I am importing a database by Chunks and making filters. I use this code that I took from someone here and adapted to my case: arq_grande <- file("cnpj_dados_cadastrais_pj.csv", "r")…
-
2
votes1
answer38
viewsHow to specify demand in lpSolveAPI in R?
I am trying to optimize profit by 4 different products, one that profits 600reais/unit other that profits 550/unit other that profits 400/unit and another that profits 300/unit. However, the demand…
rasked 5 years ago Vinicius Soares 31 -
2
votes1
answer149
viewsWeb Scraping on R
I have to download the table of this link: http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp I’m trying to use the package rvest, however, to no avail.…
-
2
votes1
answer405
viewsHow to rename caption and caption values in fviz_cluster()
I am working with k-Means and therefore need to generate intuitive graphics. However, the graph generated by the function fviz_cluster() is not responding to usual functions in ggplot objects. In an…
-
2
votes3
answers174
viewsA: Column average over the range of values in R
I made a distribution by quantis of the Hdis of all municipalities in Brazil. The distribution was as follows: 0% 25% 50% 75% 100% 0.418 0.599 0.665 0.718 0.862 In my dataframe, there is a column…
rasked 5 years ago Guilherme Marques 89 -
2
votes1
answer193
viewsChange y-axis scale to show decimal differences on a bar graph
I’m filling a bar chart, the differences between the bars are 0.1 how do I move the axis so that these differences appear ? fvcmt = c(95.2, 95.3, 95.4, 95.1, 95.1, 94.8, 95.1) fevmt = c(91.9, 92.1,…
-
2
votes1
answer250
viewsError: numeric send argument has no length one
I am trying to check the probability of the draw of number 5 in a bingo game. I would like some tips for those who are starting. Maybe the function lm is not ideal for this problem. The initial…
-
2
votes2
answers507
viewsZero left on R
I have a code that takes a txt file with ";" delimiter and swaps it with "/t". However, in these 90 files, there are fields with id = 01,02,03,04 ... When I change bounders the fields with the id…
rasked 4 years, 11 months ago Matheus Santos 21 -
2
votes1
answer55
viewsMerge date.frames into R
Hello. I have two data.frames. Follow: head(dadosFiltradosBand) rdf.schema.label genre_label 4 The Valentines (rock band) {Pop music|Rock music} 5 The Valentino Orchestra NULL 6 The Valentinos…
rasked 4 years, 10 months ago Mateus Dias 93 -
2
votes0
answers94
viewsLabel reversed Stacked Bar R
The feminine/masculine colors pros generos appear correctly on the chart, however, when I add "Labels" the amount that is gen F appears below and gen M appears in the middle p4 <- ggplot() +…
-
2
votes1
answer166
viewsHow to add two captions using geom_sf and geom_raster in ggplot?
I have these dice: structure(list(lon = c(-84.375, -84.125, -83.875, -83.625, -83.375, -83.125, -82.875, -82.625, -82.375, -82.125, -81.875, -81.625, -81.375, -81.125, -80.875, -80.625, -80.375,…
-
2
votes1
answer58
viewsDoubt with loop operations
I have this df: df_1 <- data.frame( x = replicate( n = 6, expr = runif(n = 30, min = 20, max = 100), simplify = TRUE ), y = as.factor(sample(x = 1:3, size = 30, replace = TRUE)) ) I would like to…
-
2
votes1
answer124
viewsGenerate a pop-up window in R
I have a code in R that generates an output message stating whether a series is updated or not. I run the code through a file. bat on Windows and it generates a txt file. I tried to generate a…
-
2
votes1
answer77
viewsHow does it work and how to use the Reprex function of R?
In researches right here in Sopt I saw suggestions of reproducible examples. One of them was the function reprex(), I researched about and saw that its use is specific for HTML, Github and here in…
-
2
votes2
answers87
viewsCreate a matrix without repeating the values of the date argument
Hello, I have the following code M <- matrix(data = c(1,2,3,4,5), nrow = 5, ncol = 5, T) It produces the following output: [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 1 2 3 4 5 [3,] 1 2 3 4 5…
-
2
votes1
answer219
viewsHow to read the School Census data in R (Enrollment)
I’m having trouble analyzing the 2019 school census data in R. I read some things on other forums and chose to use the ffbase package that deals with very large databases. Using the command below I…
rasked 4 years, 9 months ago user22021995 41 -
2
votes1
answer222
viewsDynamic table using database and Shiny
I’m creating a dynamic table using Shiny, but I have some questions: 1° how to integrate the column name of my database into a selectInput() so that only selected variables appear in the table and…
-
2
votes1
answer45
viewsDefine limitation on generated random numbers
I need to create a random investment portfolio with certain benchmarks. I initialized it with all 0. structure(list(Benchmarks = structure(c(2L, 7L, 6L, 10L, 12L, 11L, 13L, 14L, 15L, 16L, 17L, 1L,…
-
2
votes1
answer112
viewsCalling Loops dataframes in R
I have a series of data frames, which I will work on several times in some loops. The problem I find is that I cannot "call them" correctly to perform other actions, comparisons, etc. My code: list…
-
2
votes2
answers123
viewsHow to increase the number of iterations in R?
I’m working with a statistical model that adjusts a curve to the data of a particular disease. But when running the code I get that the number of iterations exceeded the maximum of 50. Below is the…
-
2
votes2
answers80
viewsOrganisation of the x-axis
I made a histogram in the R but I noticed that the axis has an error, it orders -0 as being greater than -2 and does not follow the sequence, as follows in the picture. I tried to filter it in the…
rasked 4 years, 7 months ago Giovanni Chiodini Dos Santos 29 -
2
votes0
answers177
viewsdifficulty installing pathtrackr in r on github
I am trying to install the pathtrackr package, I expected when running the code install_github("aharmer/pathtrackr", build_vignettes = TRUE) the package was installed, however when executing the…
-
2
votes1
answer699
viewsPlot of lines with months on the x-axis in ggplot - R
I’m taking R classes and an exercise came up to make a chart of lines on ggplot2 with data of flight delays per airport. On the X axis should stay the months (which are in numbers), but when…
-
2
votes1
answer54
viewsLocking the limit of one widget (Shiny) as a function of another
I tried to stop the limit of one widget based on the change of another. Suppose these two cases: First case: The sum of two buttons cannot exceed the value 100. For example, when I put the value 60…
-
2
votes1
answer47
viewsHow to turn a table with columns with days and rows with months into a regular time series?
I have an excel data table that was organized in a strange way. Columns are months and rows are days. In the file, after 31 days, resumes the account of the day. In this case, begins another year. I…
-
2
votes1
answer24
viewsHow to find time-series loopholes?
I have several time series with gaps. I mean, day has observation, spends a few days without, then back to observe and so continues with holes. The problem is that they put these series together in…
-
2
votes1
answer71
viewsShow only ggpairs upper or lower triangle
The ggpairs function of the Ggally package implements a version of the pairs for ggplot. The chart type displayed in the upper, lower and diagonal triangle of the matrix can be customized with the…
-
2
votes1
answer168
viewsDisplay data label in line chart in ggplot2
I have a line chart and I would like to put the label of the state corresponding to the line, but the label is coming out on each data available and not only the last one: Code I’m working on:…
-
2
votes1
answer81
viewsDoubts running ggplot 2: out-of-order data, and error bar
Hello. I’m trying to use ggplot2 to make a graph on R. This graph is a bar graph that deals with various concentrations (each concentration has a bar) on the X axis, which is associated with a…
-
2
votes1
answer150
viewsGraph of cases accumulated with ggplot2
I’m trying to make a chart according to the chart below days after 100 confirmed cases, in the case of my chart, I put as days after 10 confirmed cases: I’m using this code: library(tidyverse) dados…
-
2
votes2
answers51
viewsApply function by groups or factors to R
Dear and esteemed, I need to calculate the relative population growth of Brazilian municipalities, from one year to the next (final population minus the initial population, divided by the initial…
rasked 4 years, 6 months ago Gabriel Barni 21 -
2
votes1
answer48
viewsFunction to create charts per column
I’m using this code to plot age pyramids: p_etarias <- read.csv(file "C:\\Users\\User\\Desktop\\DemandasCEInfo\\20200327_CNSAÚDE\\Piramides\\R\\p_etarias.csv", sep = ";",dec = ",", header = TRUE)…
-
2
votes1
answer81
viewsHow to Store Data in Shiny Tables
I created a very simple Shiny that was simply for a "stock control". It has a table that starts with its products (columns) at zero value. The goal was every time you click the action button 1 it…
-
2
votes1
answer71
viewsHow to order by class and by descending order?
Suppose the following database: set.seed(1) df_1 <- data.frame(x = replicate(n = 3, expr = sample(x = 1:3, size = 10, replace = TRUE))) By the way, with the package dplyr I tried to:…
-
2
votes1
answer104
viewsLoop with dataframes in ordered logistic regression
I need to estimate an ordered logistic regression in which the database is divided into 417 dataframes giving a total of 33.7 GB. Merging all subsets into a single dataframe would make the option…
-
2
votes1
answer32
viewsHow to order one dataframe by order of another?
I have 3 dataframes with 2 columns and 5 rows each, as follows: Dataframe 1: estado casosNovos <chr> <dbl> 1 SP 3189 2 CE 1921 3 AM 1365 4 PA 1135 5 MA 938 I would like to order the DF2…
-
2
votes1
answer1724
viewsHow to change the color scale on a chart in R
I have a bar chart of Brazilian states. The color of the state bar is according to the region that it belongs to. The color scale was automatically set by ggplot2, I would like to exchange these…
-
2
votes1
answer44
viewsHow to use which.max in a long-format dataframe?
I have a DF in long format and tested the following code: library(tidycovid19) # Pacote do GitHub - https://github.com/joachim-gassen/tidycovid19 library(tidyverse) updates <-…
-
2
votes1
answer190
viewsLine operations of a Dataframe in R
I started using R recently. I would like to subtract corresponding lines from a Dataframe: The numbers in the ID column are fixed, but the data in the VALUE column is not. The idea would be to…
-
2
votes2
answers81
viewsggplot appears empty: data does not appear
I want to create a `ggplot with the frequencies at which the detections of a species of fish appear. But when I run, plot the graph without the detection frequency data, the frame is empty. How to…
-
2
votes1
answer44
viewsMasked objects when loaded. Does this make it impossible for the package to perform its function? How to resolve?
I’m having trouble executing some Spacialpoint Dataframe object commands. When I load the packets, two of them appear masked by others. I know that masking occurs when two packages have functions…
rasked 4 years, 5 months ago Fran Oliveira 47 -
2
votes2
answers172
viewsError when trying to run nls
The following error appears: "Error in numericDeriv(form[[3L]], Names(Ind), env, ifelse(internalPars < : Obtained missing or infinite value when evaluating the model" When I try to run an nls by…
rasked 4 years, 5 months ago Milton de Paula 305 -
2
votes2
answers72
viewsHow to use the rm function without erasing everything, leaving only one or two vectors?
I don’t want to exclude vec1 and a from my Workspace. I tried vec1 <- c(1,2,3) vec2 <- c(2,3) a <- 2 b <- 3 x <- vec1 y <- a cleanmem <- function(x,y){ mem = vector() mem <-…
rasked 4 years, 5 months ago Fabiano Briao 41 -
2
votes2
answers59
viewsChi-Square calculation for proportions
I have a DF with death proportions in population A and B. I want to do the test to verify the independence of the populations. Follow my DF: DATE<-…
rasked 4 years, 5 months ago Bruno Avila 867 -
2
votes2
answers81
viewsHow to join more than two dataframes in R?
I have a list of 12 DF's that I need to put together in a single DF. The structure of all is equal, only differing the name of the second column, so the basic structure is: Column 1 is the date and…
-
2
votes1
answer113
viewsHow to specify facet_grid columns in ggplot2?
I’m using Google’s mobility data to compile some charts, I needed to make a 5x5 chart, where in the rows would be the states and in the columns, the locations. I tried to use the facet_grid, but it…
-
2
votes1
answer241
viewsConfidence interval using ggplot2
How to include 95% confidence interval in graph columns using ggplot2? Data frame I’m using x<-c(0.005, 0.178, 0.031, 0.058, 0.032, 0.196, 0.123, 0.159, 0.474, 0.153, 0.003, 0.012, 0.097, 0.022,…