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
votes1
answer27
viewsFind higher row value and return the column title of a data frame
i have a wide format data frame with 5 variables (Município, Agropecuária, Indústria, Serviços Públicos and Serviços Privados). I would like to create a sixth variable called Predominante with the…
-
0
votes1
answer22
viewsHow to use graphs built by the ggplot function on a Shiny DASHBOARD
I have some graphics ready generated by the ggplot package and am trying to build a Rdashboard Shiny and take advantage of these visual products. However, it is being much more complicated than I…
-
0
votes1
answer42
viewsCreate a repeat function using two data frames
I need the average of each variable (X1,x2,X3,X4) according to the month it belongs to. The value of this average will be recorded in (Y1,Y2,Y3,y4) according also to the month belonging to the…
-
0
votes1
answer29
viewsProblems with predictions using Predict.Gam() and geom_smooth(method="Gam")
Hello, I’m having trouble reproducing the predicted values, using ggplot()+geom_smooth(method="gam"), when I run the command for the graph, it plots a line of prediction, y~s(x,bs="cs") that I can’t…
-
0
votes1
answer27
viewsCompare line values in a data frame - R
I have a data frame with more than 1 million lines and I need to count the number of occurrences of a variable. However, the value found has to be inserted in a new "Qtde" column and the values have…
-
0
votes1
answer50
viewsIs there any function in R, whose return is identical to the return of excel’s SEERRO() function?
I am trying to generate a general function, which runs several regression models. The problem is that when a model gives error, the main function stops. I would like to use a parole that in case of…
-
0
votes1
answer33
viewsHow to remove cluster data in the ggplot?
I have the data set below, where I plot the values on a date axis, as there can be equal dates in the database, by default ggplot does the grouping of this data, but the correct visualization would…
-
0
votes0
answers41
viewsFor loop inside another For loop
I’m having a problem iterating a dataset. The main idea was to separate the main dataset into others, one for each team, from a for loop. Then apply another for loop to traverse the rows of each set…
-
0
votes1
answer56
viewsName columns generated by Summarise() and use division in the same function
df is the data frame with the data that I will work with df <- data.frame(matrix(NA,nrow = 30, ncol = 6)) colnames(df) <- c("ano","mes","x1","x2","x3","x4") df$ano <-…
-
0
votes0
answers31
viewsError with Google credentials on Rstudio
I am new to programming in R and am trying to run a code R where access google drive and google Earth engine. However, two situations are happening: first on my personal laptop at home I run the…
-
0
votes2
answers39
viewsPicking a vector within an R matrix
I’m doing an exercise* for my R studies and I’m not able to properly manipulate matrices. The problem is very simple, apparently. I have a matrix’m' m <- rbind( c(1,1), c(1,2), c(3,3), c(2,0)),…
-
0
votes1
answer25
viewsHow to verify if an ID has different information in a period of time?
I have the following database: cnpj_root, affiliate (1 = matrix, 2 = affiliate), Uf, active_em_2017, active_em_2018, active_em_2019, active_em_2020 (NA= inactive, 1 = active). What I need: identify,…
-
0
votes0
answers14
viewsError inserting special characters in gmailr::gm_subject()
I prepared a script to automate the sending of emails using the gmailr. However, when I put some special character in the Email Subject, it sends only a sequence of codes instead. Example: Script:…
-
0
votes1
answer30
viewsHow to arrange the order of the wrong captions using ggplot2 in R
I’m trying to generate a graph of 19-station IQA monitoring stations. But when I graph the order of the groups are wrong, because they are like this: 1, 10, 11 , 12, 13, 14, 15, 16, 17,18, 19, 2, 3,…
-
0
votes0
answers23
viewsKeep the original class of a value imported from SQL to R
I imported a table from an SQL database, but R is automatically converting the values from a column of character for num and I need him to preserve them in class character. It seems that this occurs…
-
0
votes1
answer43
viewsReplace NA, based on other data frame by equal columns. R
I have two tables of data. I would like to replace the Nas in Table1 with the values in Table2 using two reference columns that are in the two tables. I would like to replace only os Nas. Example:…
-
0
votes0
answers38
viewsScraping site ANBIMA on R
Talk people! I’m trying to extract the information from the investment bonds on ANBIMA’s website, but I’m not getting it. This is the example of the page I want to get the information.…
-
0
votes0
answers47
viewsFunction to calculate higher percentage of hires per region in R
Hello, I am trying to make a function that returns the highest percentage (Taxas_in) of hires in a region (Local), and the output would be the sector (Activity) and the respective rate with the…
-
0
votes1
answer33
viewsFunction in R is not taking the parameter correctly
I am creating a function, but when calling the function, the parameter is not working when performing FILTER and SUM. To select the column or to perform an n() type count, it works correctly.…
-
0
votes2
answers41
viewsR, How to calculate the mean of a variable x for each group of other variables
I wanted to make a table more or less like this: A column with the nominal variables and their groups and another column with the average of a variable x for each group of each variable. With dplyr…
-
0
votes1
answer21
viewsChange scale on R
I’m trying to put a scale on the chart, but it gets like this: I’d like you to stay 0, 0.05, 0.5, 1, 5, 10, 50 and 100, not this way they are on the X axis. The code I used was this: plot(model2)…
rasked 3 years, 4 months ago Brenda Tortelli 1 -
0
votes1
answer30
viewsHiding values from the chart
I would like to leave plotted in the graph below only the values referring to the months of JAN and FEV of the x-axis. The idea is to keep every month of the X-axis evident in the graph and over…
-
0
votes1
answer33
viewsPlot multiple columns at the same time
I need to plot all columns of a table relative to a specific column. Dataset: df <- read.table( text = "c1 c2 c3 x 2 4 5 0 3 5 2 0 6 7 8 0 1 2 5 1 2 5 6 1 3 3 3 1", header = TRUE) I need to plot…
-
0
votes1
answer71
viewsChanging chart data label
I would like to leave the bar data label of graph "1" equal to graph 2, removing the background color from the label and coloring the numbers. I’m using the argument geom_label on both charts, but…
-
0
votes1
answer90
viewsTurn igraph.vs into dataframe
After obtaining the list of paths originating from a given vertex (e.g. A) through all_simple_paths: library(igraph) ligacoes <- data.frame(origem = c("A","A", "B", "B", "D"),…
rasked 3 years, 3 months ago user250908 77 -
0
votes1
answer17
viewsProblem generating column chart grouped in R
Hello! I have a problem to generate a chart in R. I would like to make a chart of columns grouped using the following data described in the image below. In this case the bits would be for each of…
-
0
votes1
answer20
viewsFailure with st_intersection() function
library(sf) library(geobr) library(tidyverse) I’m having trouble using the st_intersection() package sf for certain data loaded with the package geobr. For example, if I try to make an intersection…
-
0
votes1
answer31
viewsGLM with non-significant P values
My dataset has four variables: a dependent (Y), and three independent (X1, X2 and X3): > dput(dados) structure(list(Y = c(29.1, 27.7, 28.2, 28.1, 27.3, 25.9, 27.2, 30.6, 27.6, 28.4, 26.6, 28.1),…
-
0
votes1
answer37
viewsHow to change the order of the ggplot2 bar graph?
I’m trying to change the order of the bars so that they appear in the same order as in fill (from top to bottom: a, b, c). df3<-data.frame(Locus =rep(c("gene1","gene2"), 3), variable = c("a",…
-
0
votes0
answers25
viewsFunction to view all adjustment quality statistics of trained RNA repeats
I’m training several Rnas with 100 reps each. I need a function that shows all adjustment quality statistics for all repeats. # RNA 1 set.seed(5) RNA1 <- neuralnet(paste("Ht_norm ~ ", Quant.var),…
rasked 3 years, 3 months ago Matheus Pacheco 21 -
0
votes1
answer34
viewsGroup vertices as a function of Weights
Based on a link df I want to select all possible paths consisting only of vertices whose links check a certain condition in this case value >=3 library(igraph) library(dplyr) df <- data.frame(…
-
0
votes1
answer36
viewsHow to layer in ggplot2 with two graphs of different quantities?
I’m starting with programming and I’m trying to plot a graph overlaying data extracted from two dataframes. The code is as follows:: #Real Gross Domestic Product - GDP USgdp <-…
-
0
votes0
answers29
viewsError: Too Many Ties in knn
I am trying to make a classification in a database using the KNN, without success with the following code: #Fase 2: KNN #Preparação df para o KNN dfNormal = df dfNormal[, -length(df)] =…
rasked 3 years, 3 months ago Cézar Azevedo 23 -
0
votes0
answers38
viewsExcel export
It needed to export some elements of R: distribution tables, Plots, etc to excel in order to "fill" predefined and formatted spaces (namely as regards colors, font etc.) in excel. How can I do?…
-
0
votes1
answer40
viewsHow to group and count lines in a database in R?
Using this database: https://drive.google.com/file/d/10eODosCJsh4fVAMY-anP-jYeWZk63L-v/view?usp=sharing, need to calculate the average of pregnant women in the 6 municipalities with more records…
rasked 3 years, 2 months ago FELIPE GABRIELLI 13 -
0
votes0
answers14
viewsExecution interrupted
I’m trying to run a script, but the following error is appearing: udunits system database read from C:/Users/André/Documents/R/win-library/4.1/udunits2/share/udunits/udunits2.xml summarise() has…
-
-1
votes1
answer475
viewsGraphics in pdf in R
I have the following exercise and I am in doubt on item b in bold. Perform a data analysis, using lm(), between two variables, as we did in the room, but you should import data from any source,…
-
-1
votes2
answers1264
viewsCalculation at a specific value of a dataframe?
Possessing this data set: Índice Produto Classificação Comum Quilo 1 2 ABACAXI HAVAI A GRAUDO 3,32 2,2 2 3 ABACAXI HAVAI B MEDIO 2,81 1,8 3 4 ABACAXI HAVAI C MIUDO 2,21 1,4 4 5 BANANA MACA - 4,5 1 5…
rasked 7 years, 8 months ago Danilo Imbimbo 533 -
-1
votes1
answer1011
viewsChange column type in Data in R Studio
I would like to know where I can get a material about data modeling in R Studio... I need to modify some columns, changing from text to value, for example, but I don’t know which command to use.…
-
-1
votes2
answers300
viewsHow to create a data frame of a database based on the difference of two dates in a column of another categorical variable in the R software
I have the following database as an example and the result I expect: In the case the values in the new dataframe refer to days, which is the difference of the last date of a category from the first…
-
-1
votes1
answer114
viewsError loading average of a column
I switched the value of NA to zero, turning it into Character because I couldn’t calculate the average. When trying to calculate the average again appeared the following error: Warning message: In…
rasked 6 years, 7 months ago Jessiane de Holanda 1 -
-1
votes1
answer60
viewsHow to make two loops for the same code just go varying the column of the courses and the columns of the questions?
I have a data.frame with lots of code in the rows and lots of columns of questions, I’m doing the simple frequency of each question I would like to know how to vary the courses and questions at…
-
-1
votes1
answer2736
viewsAdd rows and columns in R
Good morning, I have been using R for a short time and have been learning in practice. I have now come across a difficulty with a table. How can I add all rows of certain columns and display the…
-
-1
votes1
answer699
viewsHow to create a Plot with two or more histograms side by side:
I need to plot these two histograms side by side. hist(DEM) hist(Tdem) I can only plot individually.
rasked 6 years, 2 months ago Alan Ribeiro 1 -
-1
votes1
answer543
viewsAxis x minute by minute
I need to identify and quantify time intervals greater than 5 minutes in a long column. "Time" column. The following dput: structure(list(Time = structure(c(1541062677, 1541062678, 1541062680,…
rasked 6 years ago Júlio Azambuja 1 -
-1
votes1
answer202
viewsThe graph doesn’t appear when I put Shiny to run
I have this code for a Shiny app. Apparently there is no error in the code and when I select only the graph I can plot, but when I put to run the graph does not appear . cat(getwd()) library(shiny)…
-
-1
votes2
answers40
viewsDataframe using R
I am with multiple files . xls and all have the same layout. I want to leave them in a single dataframe, for example: df1 nome idade sexo Fulano 22 M df2 nome idade sexo Fulana 27 F dfJuncao nome…
-
-1
votes1
answer71
viewsHow to make a program in R that provides the result below?
I have a question regarding to make an algorithm that provides the result of the equation below.…
rasked 5 years, 8 months ago Fidel Henrique Fernandes 119 -
-1
votes1
answer94
viewsHow to omit Chunks in Rmarkdown?
This question requires the use of images to understand. R Markdown is like this: I need to wear a shortcut, without having to click the arrows next to the hashtags, to do this: How to do this for a…
-
-1
votes1
answer373
viewsInsert variable names in the first line of the dataframe
I want to insert the name of the variables as the first line of my datafrane. For example: X11.3116555055603 X16.8234904296696 1 14.79609 10.37313 2 10.02141 16.38942 3 12.10137 18.75196 4 14.29997…