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
-
-1
votes1
answer209
viewsHow to winsorize database by group
How to market data when the database is per group? Example: Empresas Setores Receita Empres1 Comercio ### Empres2 Comercio ### Empres3 Comercio ### Empres21 Industria ### Empres22 Industria ###…
rasked 5 years, 6 months ago Luiz Claudio Louzada 1 -
-1
votes1
answer104
viewsTurn time series into base 100 on R
Is there a function that converts an entire time series to base 100 on the R? If it does not exist, what would be the solution to the problem? Thank you
rasked 5 years, 6 months ago Valmor Mantelli Jr. 23 -
-1
votes1
answer44
viewsHow to write multiple string (names) in R?
For example I want to write a second name nome<-c[scan("")] #insirindo uma sequencia de numeros idade<-scan() 1: 45 2: 65 3: 12 4: 32 5: 23 6: 78 7: 87 8: 98 9: 12 10: 555 11: #tecle enter…
-
-1
votes1
answer93
viewsHow to compare information from one table to another table
I have a very large spreadsheet in csv format with about 8 million lines and several columns, among them a column with people’s phone. I also have another spreadsheet, in excel, with 2 thousand…
-
-1
votes1
answer49
viewsHow to insert a die in the last row of the list in R?
I have a list with some data and I need to make the moving average of the last 3 data available, what I am not able to do is to include the value of this average in the last line of my list. I’ve…
rasked 5 years, 2 months ago Alexandre Sanches 1,223 -
-1
votes2
answers87
viewsSeparate data from a variable
I have a variable - (Municipality), which brings me the result (Açucena - MG). How do I separate in R the Municipality of the State? library(sidrar) Tab1612SojaRend <-get_sidra(1612,variable =…
rasked 5 years, 11 months ago Everton Toledo 113 -
-1
votes2
answers74
viewsSeparate a datraframe in subdatraframes based on a condition
I would like to generate subsets of a dataframe via loop. However, when executing this code I do not get the 5 objects. list <- list("CO", "N", "NE", "S", "SE") for (i in list) { df_name <-…
-
-1
votes2
answers64
viewsSUMMATION IN A COLUMN IN A LINE INTERVAL
I have the following database: I would like to add the INTE_C1 for each month. That is, for January add from 1/1/2000 to 1/31/2000...…
rasked 4 years, 11 months ago Beatriz Rocha 1 -
-1
votes2
answers61
viewsSearch for data frames by names in R
Good morning, I would like to create a function that I can use a data frame with a name that is saved in an object. Example: I have the dataframes: df1, df2, df3 All with columns: x, y and z df1 x y…
rasked 4 years, 11 months ago Gustavo Rodrigues 11 -
-1
votes4
answers264
viewsR - How to replace "." (dot) with " (space) in the column names of a Data.Table?
I have an extended date.table with 64 columns. The names of the columns are separated by points and I would like to separate by space. Example: Current: "Salary.January", "Salary.December",…
-
-1
votes2
answers1362
viewsWarning message: Those introduced by coercion
I’m having trouble formatting "Chr" to "num". When I load the table to column VA.VG comes as “chr”, when I execute the change the error appears: #carregar: > t2019_12 = read.csv…
rasked 4 years, 8 months ago João Victor 1 -
-1
votes1
answer36
viewsDoubt when counting table elements in Chr format
How can I count the arrival airports if they are described in the table in format ? I already used this code and did not get the expected result: destino_frequente <- flights %>%…
rasked 4 years ago Marcelo Duarte 21 -
-1
votes1
answer62
viewsRvest is returning the following error when reading a page: {xml_nodeset (0)}, how to resolve?
I would like to create a tool to make web scraping on the website of the Chamber of Deputies of Rio de Janeiro, but I am running into the problem of even being able to read the web page. Does anyone…
-
-1
votes1
answer226
viewsProblems plotting graph in R with ggplot2
I need to plot a graph from a file’s data. txt, the data import part is ok, however, when I use the ggplot function, it says that could not find "ggplot". Below is the code I’m trying to use:…
-
-1
votes2
answers35
viewsHow to export [[ ]] from a list in separate excel files using R?
I play here part of a dataframe I’m working on: producao<-data.frame( discente = c("ANA", "ANA", "ANA", "ANA", "ANA", "MIGUEL", "MIGUEL", "MIGUEL", "MIGUEL", "MIGUEL", "JAIME", "JAIME", "JAIME",…
-
-1
votes1
answer32
viewsHow to paint a graph in r from a specific value?
x <- seq(0, 15, length.out=10000) dat <- data.frame(x=x, px=dexp(x, rate = 1/5 )) library(ggplot2) ggplot(dat, aes(x=x, y=px)) + geom_line() I’d like to paint this chart from the value 10,…
-
-1
votes1
answer34
viewshow to determine the percentile that a given value has in a sample in R
Suppose I have a vector-shaped sample x <-c(2,3,68,253,1,35,3,35,01,24,04,36,254,2,28,12,4,54,66,775,6,45,33,68,71) I know if I make the command: quantile(x, 0.75) R returns me the percentile…
rasked 3 years, 6 months ago wesleysc352 113 -
-1
votes2
answers98
viewsHow to plot a graph of columns grouped with ggplot
How can I chart columns grouped by year? I have an extensive database with several variables and would like to plot a chart separately per year. How to do it? For some variables the chart is getting…
-
-1
votes1
answer36
viewsCreate an index by searching part of the text only
I would like to create an index by searching only part of the text. x <- c(4, 1, 6, "ab", 2, 1, "aa") which(x == "a") In the vector above, for example, I would like the return to be [1] 4 7 That…
rasked 3 years, 6 months ago Peterson Ribeiro 37 -
-1
votes1
answer27
viewsHow to rename a line?
I have the table: [,1] Inconclusivo ou indeterminado 1.229142 Negativo 60.131108 Null 11.536551 Positivo 27.103198 I would like to rename the line Null.…
-
-1
votes2
answers39
viewsHow to sort my bar chart per day of the week on R
Hello, Good afternoon. I need a help to sort by day of the week on R my bar chart, as below: The code I used is as follows:: date_manip %>% na.omit() %>% ggplot(aes(x=Dia_week), group=1) +…
-
-1
votes1
answer26
viewsModify data columns in R
I have an Excel spreadsheet with inflation expectations for 2021, 2022, 2023, 2024, 2025 over the last 30 days. When I import this spreadsheet, the dates are being considered as a column, and…
rasked 3 years, 3 months ago Marcos Vinicius Laplechade 9 -
-1
votes1
answer45
viewsAverage the sum of two columns and division of two columns
I want to average the sum of 2 columns of the following base: > dput(head(censo3)) structure(list(UF = c("Rondônia", "Rondônia", "Rondônia", "Rondônia", "Rondônia", "Rondônia"),…
rasked 5 years, 4 months ago Ingled M Cardoso 159 -
-1
votes1
answer96
viewsMultivariate analysis with only one table
1 I am trying to relate quantities of polykets in oyster samples from different locations, the locations and quantities are in the same table, I started by boxplot to have medias and variables in R,…
-
-1
votes1
answer397
viewsHow to create charts using time series showing every month on the x-axis in R?
Suppose I have the following time series: PREVISAO_VL_TR = ts(PREVISAO_VL_TR, start = c(2019,1), end = c(2019,12), frequency = 12 ) And that now I would like to create a chart of this time series:…
-
-1
votes1
answer33
viewsCreate a column with case_when with ranges error appears
I have this database and I intend to create a new column with this structuring (see image). For example, if the row in the Calendar_week column has a value between 36 and 45 the new Quartile column…
-
-1
votes1
answer46
viewsDate manipulation using dplyr and lubridate
I have a date frame whose columns have dates (%Y/%m/%d), times and averages per hour over 4 months (01/01/2020 - 01/04/2020). I wonder how I could calculate the average of these hourly values, for…
-
-1
votes1
answer329
viewsBasic division in training and testing in R
I have a database, where my variable resposta are dates and the explanatory is the flow of the source of a city. I generated a time series model as a way to try to understand how reliable my data…
rasked 4 years, 8 months ago Letícia Marrara 95 -
-1
votes2
answers95
views"proj_api. h not found in standard or Given Locations" when installing package in R
I’m trying to install the tmap in R and appears Installing package into ː/home/Americo/R/x86_64-pc-linux-gnu-library/3.6' (as ːlib' is unspecified) also Installing the dependencies ?lwgeom',…
-
-1
votes1
answer65
viewsGraph with error bar in R
Hello, I’m trying to make a graph on lines and error bars, but the errors are being plotted over the first line, and not on the second.... and my legend is not being printed. Could you see what is…
-
-1
votes1
answer58
viewsI need to join two columns of DATE and TIME with the class Posixct but returns me NA
I need to create a Datetime by joining these two columns with the class Posixct. But when returning the table the Datetime comes with NA. Edt. Following the suggestion of the friend below only…
rasked 4 years, 6 months ago Fran Oliveira 47 -
-1
votes1
answer338
viewsChange plotting order of an area chart in R
I am using the following code to try to plot a graph ggplot(final2, aes(x = final2$a, y =final2$somaacumulada,fill=final2$Country)) + theme_bw()+ geom_area(position = position_dodge(width = 0.8))…
-
-1
votes2
answers298
viewsHow to put Y-axis variables in ascending order in ggplot
I had to rename the Y variables of a ggplot, but I need them to be in ascending order so that the data correctly track its variables. I need you to start with #MB02 myc_t DateTime Receiver…
rasked 4 years, 6 months ago Francielle Oliveira 71 -
-1
votes1
answer111
viewsPlease I need to calculate the SD by several variable rows (columns),
I tried to loop, apply, as I am learning, I did not get the solution, the idea and creates a function that calculates the sd this function provides the calculation per line: f_sd_subgrupo <-…
-
-1
votes1
answer162
viewsRepeat the value of a line in the rows immediately below a dataframe in R
I need to write a function so that the values highlighted in yellow are repeated in the cells below, including overwriting those cells that already have values. Otherwise, the values to the left of…
-
-1
votes2
answers37
viewsWhy do R outputs numbers always come out with dot (.)?
When obtaining percentages and respective 95%CI the output I get as below: > observed<-c(95,1202,26,921) > require(DescTools) Carregando pacotes exigidos: DescTools >…
-
-1
votes2
answers104
viewsHow to identify the page number of a . pdf by something written on it?
I have a . pdf with 120 pages, each page is a certificate and the only difference between them is the name of the participant. I also have a . csv with the list of participants' names and e-mail…
-
-1
votes1
answer62
viewsDivide bibliographic references into columns in R
I am with df which contains several bibliographic references. My intention is to divide these references into the following columns: "Author", "Title", "Periodico", "Data of the Periodico" (volume,…
-
-1
votes2
answers38
viewsReorder Columns in graph made by ggplot
I’m producing a bar chart, but the ggplot places the bars in alphabetical order. I need the bars to appear with the names in the order I define. How should I do? Dice nif <- structure(list(Genes…
-
-1
votes1
answer37
viewsvarImp does not recognize gradient boosting model produced by Ret when I apply weights to target
I produced a gradient boosting model with the package caret and applied weights to the target variable. When I call the function varImp in the model it returns the error: Error in…
-
-1
votes1
answer41
viewsSend an e-mail to R
I’m trying to e-mail through the R with the package mailR. I put the information that the package requests, but testing with different emails, I end up getting the same error. My code:…
-
-1
votes1
answer155
viewsConverting a list of lists of vectors into a list of matrices - R
I’m working on an environmental model that returns a list of vectors. Each list corresponds to a point in space, and each vector is a time series of data for different variables. I’m trying to…
-
-1
votes1
answer54
viewsHow to annotate an individual chart using facet_grid?
I’m using the function annotate to try to number a figure with facet_grid, but the number goes on the two axes y. How do I write on only one side? https://1drv.ms/x/s! Avi1orbh4c0tjiyruc0ouxkny5fg?…
-
-1
votes1
answer25
viewsRselenium - How to click the check-box and then the Submit button
I’m trying to make a web scraping of the Central Bank website. To do this, I need to select an item from the drop-down menu, then mark a check box and then click the Submit button. But when I try to…
-
-1
votes2
answers44
viewsBarplot in R: Help with the arguments to create a more complete graph
Hello. I need to create the two charts below in this exact way. Certain adjustments, for example: the creation of a value of 7 in the x-axis, which has been omitted; the horizontal axis with traces…
-
-1
votes1
answer47
viewsif Else - Does the position of the keys "{}" make a difference in the result?
I’m making web Scrapping from a website. And for that I need to check if a data.frame exists or not. Besides not being working, I realize that I have different results only changing the position of…
-
-1
votes1
answer37
viewsHow to obtain bordering municipalities from a geom_sf + ggplot
library(tidyverse) library(geobr) Suppose I’m working with a Conservation Unit. Catimbau National Park (PE), for example. Low data by package geobr ucs<-read_conservation_units() parna_catimbau…
-
-1
votes2
answers42
viewsLoop is not walking, does not leave the first position
f3 <- function(n) { dados <- rnorm(n, mean = 0, sd = 1) matrizB <- matrix(0,2, n) for (i in 1:length(dados)) { s <- 1 if (i <= 0.2) { matrizB[1,] <- 1 matrizB[2,] <- 0.2 } if (i…
-
-1
votes1
answer51
viewsHow to round up a data.frame in R using the %> % dplyr operator?
I have a date.frame with many values with more than 2 houses after the comma, I would like to round to only 2 houses after the comma using preferably the operator %>%, if possible, as this…
rasked 3 years, 5 months ago wesleysc352 113 -
-1
votes1
answer46
viewsIterative link of tables in R
I am studying a topic of networks and need to represent all the connections between a Vertice and those connected to it, directly and indirectly, so I thought to make an iterative link between…