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
-
0
votes2
answers70
viewsA: How to create/save a vector using for and Paste?
I’d like to rotate one for and save 3 different vectors with for example: vetor_1, vetor_2 and vetor_3. Each vector is receiving a different set of values. I can’t do this paste be the vector name,…
rasked 5 years ago Fabiano Briao 41 -
0
votes1
answer199
viewsCreate column with conditional values to those in another column
Assuming the following column with actions: ## code## Petr mils oibr I would like to know how to create another column where the values would be conditional to those of the column "code'. Example:…
-
0
votes2
answers304
viewsHow to filter data from R lines?
I want to use Selic’s data for an R simulation, but not the initial data, only after a certain date. The data are organized as below: selic <- structure(list(var_1 = c("jun", "jul", "ago", "set",…
-
0
votes0
answers113
viewsRemove PDF file table in R
I have a PDF file that contains a table, I need to remove it and turn it into data.frame. I’m trying to use the package pdftools. I’m trying to use the following code, which ends up returning me to…
-
0
votes1
answer105
viewsFilter columns conditionally to another column
I would like to select a single value in the dataframe below, according to the following parameters: 1) The values in column nJRS would be the reference; 2) The value of the column nJRS should…
-
0
votes2
answers123
viewsHow to turn column into row in dataframe
I have two dataframes and would like to transform the data of the two columns of the 2nd df into rows to be added in sequence of the data of the 1st df. To illustrate create the two df and the final…
-
0
votes1
answer49
viewsUpdate worksheet by another worksheet
I have two dataframes with identical columns, one being the database and another monthly updates. I need to update the database with these monthly updates. I thought of the following code:…
-
0
votes1
answer436
viewsR, Shiny and maps: How to render a map according to the choice in the dropdown_menu?
I am working on a Shiny app and would like the map to be rendered according to the user’s choice in a dropdown. I have three maps (M1, m2 and m3), what I need to put on the ui and server? Follows a…
-
0
votes0
answers28
viewsWindows does not find R environment variables running shinys by . bat(batch) or shell files
I have a Shiny saved on the network that I make available to users through shortcuts that run Shiny by shell on Windows (the shortcut is a file. bat on desktop to user) I have some access passwords…
-
0
votes1
answer406
viewsHow to uninstall R on linux?
I am trying to uninstall the R from my machine. As I use linux, I used the command sudo apt-get remove r-base and the operation was successfully completed. But after giving the R command on the…
-
0
votes1
answer31
viewsSelect the most recent date of each group in r
I have that data data;code 18/02/2020;C106 05/04/2018;C107 11/09/2016;C107 16/02/2019;C109 11/03/2020;C110 04/03/2020;C114 18/02/2020;C114 06/02/2020;C121 I would like to select the latest date of…
-
0
votes1
answer54
viewsHow to make a GLM with different sample n?
I want to correlate the variable number of leaves of the plant with the variables: temperature, root size, sun incidence, relative soil humidity and others. Only I have some NA in almost all…
-
0
votes1
answer28
viewsCreate a conditional to print the media and standard deviation on the screen
I would like to create a conditional for average and standard deviation of a given group. I usually do this by dividing subsets, but as there are many categories I thought would be better with a…
-
0
votes1
answer47
viewsHow can I add a filter to list only the countries above x cases?
confirmed <- read.csv('time_series_covid_19_confirmed.csv', stringsAsFactors = FALSE) library(dplyr) covid <- confirmed %>% select(Country.Region, X3.29.20)…
rasked 4 years, 7 months ago André Patriota 1 -
0
votes1
answer53
viewsAggregating data with different dates and considering other columns in R
I would like to aggregate the lines of dataframe TBCG2, when the DATA_INGRESSO_ORGAO is different (see column ID_SERVIDOR_PORTAL numbers 977, 1089, 1365, 1666, 2597, 2779 and 3036). I want to keep…
-
0
votes1
answer192
viewsA: Creating map by municipality
Hello, I need to create a map that shows the amount of CPF in Coop. per municipality (ex: blank cities = 0 CPF, dark green cities = 500 CPF). I did by State and it worked, but when I apply to…
-
0
votes1
answer32
viewsHow to use ggTS with ggplot?
Hello, anyone know, have you used ggTS function to make Temperature/Salinity graphs with ggplot? I’m not sure how to install to make it work together with ggplot.…
-
0
votes1
answer67
viewsEntire division returning a different result than expected
I’m having a problem with the entire division in python and R. The language returns a value other than "correct" in the entire division of 327 by 3.27 and the rest (%) different from 0 in these…
-
0
votes0
answers62
viewsHow to make a bar graph with ggplot2?
I have a graph generated by a package that would like to replicate it and make some changes to the colors, but I’m not able to understand the code behind the chart. Graph: Code used by the package:…
-
0
votes1
answer160
viewsProblems with the geobr package of R
I use the package geobr to make maps. However, from a few days to here, every time I have been drawing up the map of Brazil with all the municipalities, the map does not complete and is the same as…
rasked 4 years, 5 months ago claudiomar filho 9 -
0
votes0
answers198
viewsHow to import file. KMZ to R
Hello, good afternoon! I would like to import polygons saved in google Earth in formed . KMZ, for R, can even an example (https://gis.stackexchange.com/questions/247413/importing-kml-files-to-r) ,…
-
0
votes0
answers23
viewsDimensional Table/Fact in R
Currently I have 4 data.frames that have ID and other data, and I intend to use dimensional model (known as star) to create a fact table with all the Ids. But the only way I thought about developing…
-
0
votes1
answer115
viewsR write.table with rbind
Hello, I have the following variables: year, area and a series of data. At each loop of area and year, I make an average of my data. for(area in 1:10){ for(ano in 1:20){ calculo_coeficiente<-…
-
0
votes0
answers39
viewsR link between tables by date.frame
Hello! I have two tables in the database and they are linked by a FK, as I create a third data.frame with the data of both tables linked by FK. I mean, I have: dataframe1 <- tbl(con,…
-
0
votes1
answer756
viewsformat X-axis of bars in ggplot2
I generated a bar graph in ggplot2 , but the X axis data was not in the number sequence of "1 - 30", I would like to know how to get the sequence right? here are the Scripts c<- c ("Casal 1",…
-
0
votes1
answer46
viewsr Loop by script condition
It is possible to loop from this data? library(dplyr) mes <- c("jan","fev","fev","mar","jan","nov","mar","mar","mar","jan","nov","maio","maio","maio","nov","nov","mar","jan","mar","jan") a <-…
-
0
votes1
answer106
viewsPredict plot for adjusted Gamlss model
How do I make and plot the predict for this model Gamlss adjusted? My model is presented below. mod<- gamlss(cbind(nfr, nv-nfr)~tt+tr1+d2+d3+random(as.factor(p…
-
0
votes0
answers36
viewsDoubt about a GLMM
I’m running this model on R: modelogeral<-lmer(lognplanta~Clas_renda*sexo*idade*ocupacao*escolaridade*Clas_npessoas*(1|comunidade),data=bruno) The following message appears: Fixed-Effect model…
-
0
votes1
answer289
viewsRescue indexes from my data elements.frame
I have a data.frame that is filtered from another data.frame. (see image below) However, I would like to filter this data.frame again and retrieve its original indexes in a vector. Example: Let’s…
-
0
votes2
answers49
viewsConvert days to years using R lubridate
Assuming the following dataframe: library(dplyr) library(lubridate) df<-data.frame(inicio= ymd(19800101), fim=ymd(20200101)) %>% mutate(dif=fim-inicio) inicio fim dif 1 1980-01-01 2020-01-01…
-
0
votes1
answer56
viewsWrong numbering of data frame lines in R
I cleaned a dataframe and, after processing it, the result was a table with all the rows with the wrong numbering. Notice that the first line has the number 90, the second 92 and so on. I want it to…
-
0
votes1
answer68
viewsHow to store the results of a function in a data.frame?
Good afternoon I am using the R to make a temporal analysis of the Infant Mortality Coefficients (IMR) of each Administrative District (n = 93) of São Paulo between 2013 and 2019 The base table I am…
-
0
votes1
answer49
viewsI need to get my chart in descending order!
what I’m wearing is : tabyl(situacao$situacao) ggplot(situacao, aes(x=situacao))+ geom_bar(stat="count", width=0.7, fill="steelblue")+ theme_minimal() + theme(axis.text.x = element_text(angle =…
rasked 4 years, 2 months ago user205863 1 -
0
votes1
answer128
viewsHow to format the.Numeric() a comma number in R?
I have a dataframe with numbers separated by a comma but in the format integer but I need to change to numeric. When using the function as.numeric(MEU_NUMERO) the number gets distorted.…
rasked 4 years, 2 months ago andhherson 7 -
0
votes2
answers51
viewsHow to find out how many times a certain level is repeated in a specific column (factor) of a data.frame?
I am working with 4 data frames (W, X, Y and Z) that have the same number of variables. Factor (column/variable) 11 was classified into 3 different levels (1, 2, 3). I need to find out how many…
-
0
votes1
answer29
viewsError in R script syntax
all right? I reckon so Please, I can’t move forward by writing this command: flt <- filter(grade.ac,st_contains(ac,grade.ac,sparse = (FALSE)) The R informs: "Unmatched Opening Bracket "(" ...…
-
0
votes1
answer66
viewsProblems with the lme function with nested variables (any(notIntX <- ! apply(X, 2, const))
I’m trying to adjust a mixed effects model in which I have covariables that are nested (Varx5 | Varx6) and are considered fixed effects. However, I am trying to adjust the data and the following…
-
0
votes0
answers202
viewsAnimated Graphics - R
Hi, I need to make an animated chart that shows the top 10 states. I’m trying, but it’s showing the top 14 and it’s not in the order from the highest to the lowest. Below is the code used: #…
-
0
votes0
answers26
viewsDaily interpolation of growth data in R using grouping by variables
Good morning, I am trying to perform linear interpolation of tree growth, however I would like to interpolate using some variables such as group_by in dplyr. These variables are: Block (n=3),…
rasked 4 years ago T. W.G. de Oliveira 11 -
0
votes2
answers621
viewsRemove specific remarks from Data Frame in R
Good night, guys. I need a little strength from you. I have a data frame in the panel data format where my N are the municipalities of São Paulo and T are the years of my sample. To illustrate, my…
-
0
votes0
answers63
viewsHow to create a great reproducible example in R?
I already made one question previously on how to produce reproducible examples for questions involving the Shiny. Here at Stackoverflow in English there is guides and also questions whose theme are…
rasked 5 years, 7 months ago Flavio Barros 1,717 -
0
votes1
answer60
viewsHow to save a pdf of the statistical report generated with Expdes.pt package?
the code below generates a report in the R console which I want to export in a pdf, however I am not getting, I appreciate the help. library(ExpDes.pt) anova1 <- fat2.dbc(dados$fator1,…
-
0
votes1
answer26
viewsDate Below the chart
Hello, I have the following code my doubt is, using the function Legend has how do I put the dates below the chart? if not, what would be the best way to do that?…
-
0
votes1
answer241
viewsHow to update a dataframe column in R using joins without creating another object?
Rapazeada blz? Guy I am Newbie in R and I wonder if it is possible to update a data.frame in R by making key with another data.frame, the analogy in tsql would be this: Update a Set a.col1 = b.col2…
-
0
votes0
answers107
viewsA - How to divide polygon into equal parts
I have a polygon formed by the vertices > ver id x y 1 1 806648 9719778 2 2 806887 9719588 3 3 797995 9710368 4 4 797745 9710547 when plotting comes out the following picture that is , would be a…
rasked 5 years, 7 months ago Gustavo Mourao 19 -
0
votes1
answer126
viewsBar graph - Manual grouping of data
Good morning guys. I’m trying to make a bar graph with ggplot(), but I’m having a hard time with one detail. Basically I would like to manually group the data that gets inserted inside each bin of…
-
0
votes0
answers68
viewsError in lhs - rhs : non-numerical argument for binary operator
I’m trying to run the function ... m.ex=nls(dados$var1~y0*exp(r*dados$dias), data=dados, start = list(y0=10,r=0.005));m.ex ** ... in the data set:** str(data) 'data.frame': 24 obs. of 2 variables: $…
rasked 3 years, 8 months ago Thaissa Soares 1 -
0
votes1
answer42
viewsHow to insert year by year into a time series graph in ggplot?
I’m running the remote ggplot(Regulation, aes(Regulation$year, Regulation$rqe)) + geom_line() + geom_point(Colour = "blue")+ Labs(title = "REGULATORY QUALITY ESTIMATOR (1996-2017)", x = "YEAR", y =…
-
0
votes1
answer244
viewsAnnual percentage change in R with dplyr
I wanted to use the package dplyr to calculate the annual change in the IFGF from one year to the next and from 2006 to 2016. Any suggestions? I made some unsuccessful attempts like:…
rasked 5 years, 6 months ago João Sousa 11 -
0
votes1
answer46
viewsTime series, how to eliminate gaps between missing periods in ggplot2?
I need to present climate data during an evaluation period, but the time lapses, as observed in Figure 1, using the data (exe2) and the script (1). Naturally the ggplot plot the x-axis as continuous…