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
answer34
viewsOperation with 2 columns dynamically
Be the data frame v1 v2 v3 v4 v5 a x 2 1 4 b y 4 3 5 c z 6 5 6 Calculate, for example: P1=v3+v4 P2=v4+v5 is trivial, because I can do this for each one manually, so I would have: v1 v2 v3 v4 v5 p1…
-
2
votes1
answer724
viewsBarplot no Rstudio - 2 Columns
I’m trying to plot the data below in R with the barplot but it must be wrong in something, you can help me? dados_estado_civil <- "Estado_Civil Set Out AMIGADO 2494 3857 CASADO 2500 3291 SEPARADO…
-
2
votes1
answer609
viewsHow to insert caption into ggplot maps?
How do I insert the legend and scale the map to degrees? library("rgeos") library("maptools") library("ggplot2") library("mapproj") cores1 = c('brown2', 'aquamarine2', 'darkgray','darkolivegreen1',…
-
2
votes1
answer292
viewsproblem with R enconding
I was asked to do text analysis and I’m having trouble with coding, someone knows how to convert these strings with accent directly? Example of how the file appears: vocês dizerem que não!!! Até…
-
2
votes1
answer612
viewsHow to make a map of Brazil
I’m trying to make a map on the R for the first time. I did all the necessary process with the data and am following the instructions of a script available here but he does not recognize the object…
-
2
votes1
answer176
viewsConvert char to time
I need to convert a field from a char file to something that is calculable to average. It is a field that refers to hours originally. system.time(cpc_call<-fread("ACIONAMENTO_CALL.csv",header = T…
-
2
votes1
answer259
viewsHow to handle errors during web scraping?
Hello, everyone. During the Web Scraping process, I started to come across some errors that occur during the request process. Currently, I have identified 4 types of frequent errors: Error in…
-
2
votes1
answer1242
viewsRemoving regulartable decimal places() flextable package {R}
I am making a report in . rmd to export to . docx and to mount the tables I am using the package "flextable" , which works for this type of export. The problem is that when I go to assemble the…
-
2
votes2
answers79
viewsJoin for unequal records in R
I have two data frames called employees and employees. nome.empregado <- c('Renato', 'Miguel', 'Paulo', 'Patrícia', 'Inês', 'Saulo', 'Diego', 'Maria', 'Jose', 'Julia', 'Tiago') idade <- c(30,…
-
2
votes2
answers737
viewsHow to replace a space by semicolon between two words with gsub()
I have a problem to solve and I can’t write the correct regex. I want to add the semicolon between two emails: ex <- "[email protected] [email protected]" #resultado esperado: [1]…
-
2
votes3
answers152
viewsAggregate string in R
I have the following basis: cidade a b c AGRONOMICA CRESO NA NA AGRONOMICA NA SICOOB NA ALFREDO CREDIVERTENTES NA NA ALMIRANTE SICOPER NA NA ALMIRANTE NA SICRED NA ALTO SICOPER NA NA ALTO NA SICOOB…
-
2
votes1
answer243
viewsRepresent the x-axis of the histogram as the frequency distribution classes?
I’m having problems when I’m doing a histogram of this frequency distribution. Class Limits f Rf Rf(%) cf(%) [22.691,25.57) 17 0.01 1.29 17 1.29 [25.57,28.45) 25 0.02 1.90 42 3.19 [28.45,31.33) 64…
-
2
votes1
answer40
viewsCalculate the variance of the values related to a group interval? In soft R
Example have the database as follows: MES RESP 1 4.67 1 5.11 2 5.22 2 4.99 3 4.60 3 5.39 4 4.98 4 5.29 5 5.82 5 5.01 6 5.90 6 4.22 7 4.40 7 4.69 How do I calculate the Variance, Mean, Standard…
-
2
votes1
answer214
viewsSimilarity of Texts
Good evening, you guys, I would like a help from you, because I am starting in R, and I have a demand, where I have to signal the lines where there are similar phrases. For that, I’m using the…
-
2
votes1
answer97
viewsDetermine circle size in GGPLOT2 chart caption
Hello! I put these commands in the R: library(ggplot2) lm_smooth <- geom_smooth(method = lm, size = 1) qplot(percwhite, percbelowpoverty, data = midwest, weight = popdensity, size = popdensity) +…
-
2
votes2
answers160
viewsRenaming all Environment objects with a specific name
The Environment is: but I want to convert into: where dataset is the specific name.…
-
2
votes1
answer85
viewsGraphic with same color lines for factors
I have a date frame (DF) of consumption per animal and per day Below is the data below of only two animals Animal Dia Consumo 5 9 2533.96 5 10 2329.06 5 11 2943.79 5 12 3361.62 5 13 2890.82 5 14…
-
2
votes1
answer415
viewsHow to change dates from the American format y/m/d to d/m/y in an R dataframe?
I have a dataframe where the dates are in American format and I would like to know how to transform this column to the Brazilian format day-month-year. I tried the package lubridate and the function…
-
2
votes2
answers119
viewsConvert all Environment files to '.Rda' and then load them at once with a loop
I want to convert ALL dataframes of my Environment into file type .Rda. My goal is, after this action, to restart the R and load all of them at once with a loop for.
-
2
votes1
answer80
viewsError in R with list2env function
I try to convert my list (which contains 12 dataframes and approx. 20,000 lines each) into separate dataframes: list2env(mylist,envir=.GlobalEnv) but, the following error message appears: names(x)…
-
2
votes1
answer126
viewsReplace NA with data from another column
I would like to replace NA by the content of another column. I have the following data: NOME TIPO VALOR ABC INTERNACAO 10 ADD 20 AFF CONSULTA 30 DDD EXAME 40 RTF 50 DRGG EXAME 60 How would you…
-
2
votes1
answer200
viewsMultiple Linear Regression in R
Hello, I have data (https://drive.google.com/open?id=1JdgsnJn5VrkL8j1BsfWzqYW9fMGXND6U) of a completely randomized experiment, in which the fungal growth in response to the application of different…
-
2
votes1
answer146
viewsBar Graph in ggplo2, geom_bar()
I made this chart with geom_bar(), would like the bars to be glued to the bottom line, indicated by the arrows. How could you do? Have some function parameter theme() that can solve this problem?…
-
2
votes1
answer92
viewsDoubts ggplot in bars
Hello, I’m trying to plot a bar graph geom_bar, where X corresponds to the days of the month, in this case February, and y refers to the value of two variables v1 e v2 for the day in mode position =…
-
2
votes1
answer80
viewsFilter lines without knowing the column name in R
Hello, how can I select a row from a data frame that contains an expression but I don’t know which column that expression will be in?
rasked 6 years, 2 months ago Jessica Voigt 883 -
2
votes1
answer160
viewsHow do I get R to repeat a request?
I’m trying to extract data from the firefly from the R for this, I used the "firefly" package, and I took an example of code from here: https://brunaw.github.io/vagalume/vagalumeR.html The problem:…
rasked 6 years, 8 months ago André Kaique 23 -
2
votes1
answer43
viewsGLMM - Prediction with ID
Friends, I have different companies with different characteristics and each company has the same positions I selected the data of several members of each position of each company and noted…
-
2
votes1
answer158
viewsHow to Insert selectInput across the datatable
I’m using the Shiny. How can I display a selectInput, with options from 1 to 5, in all cells of a DT::datatable? All I’m getting is the tag div, through the vlr[i] within the for. library(shiny)…
-
2
votes1
answer693
viewsSubtitles by GGPLOT2
I have this graph created by the geom_bar function(): I would like to separate the two boxes where are plotted to Fill, as follows: How do I do this? which parameter of the Theme() function can I…
-
2
votes1
answer120
viewsCalculating rates in R
I have the following dataframe: data <- data.frame(Individuo=c("1","2","3","4","5","6"), Sexo=c(2,4,4,2,4,2),Ocupaçao=c(1,1,2,2,1,2), Raça=c("Branco","Negro","Pardo","Branco","Pardo","Branco"),…
-
2
votes1
answer56
viewsNotification from one date to another R
DF = data idade dt nome 2 02-02-2016 Marq 8 05-05-2010 Andre 24 06-06-1994 Sudre 23 25-05-1995 Jaq This is my df, I need to get the name of the person when she turns 24. For example, when she’s 90…
-
2
votes0
answers117
viewsHow to see graph of residues in the R?
These are the given commands, basically: library(psych) library(readxl) library(minqa) library(car) COMDINHEIRO_UFESpro_capm <- read_excel("COMDINHEIRO_UFESpro_capm.xlsx")…
rasked 6 years, 8 months ago Rodolfo Marchesi 29 -
2
votes1
answer73
viewsError with lapply function
I try to perform the following function: result<-lapply(mylist,function(x)cbind(x,var=tapply(x[,c(3)],x[,c(1)],sum))) But this mistake arises: Error in data.frame(..., check.names = FALSE) :…
-
2
votes1
answer99
viewsData frame handling
Hello, I’m trying to manipulate a database with 300+ observations, but each observation has a different number of columns. The problem is that from a certain point, the columns start to repeat…
-
2
votes2
answers3944
viewsHow to transpose rows into columns in a data frame?
I have a time series with daily precipitation data between 1961 and 2017, as an example below. I need to group these data by month over the years. I was able to transpose the "month" column of the…
rasked 6 years, 7 months ago Andreia Almeida 183 -
2
votes2
answers44
viewshow to implement the jaccknife method if two terms are removed (in R)
I created the following code to calculate the variance using the jackknife method. However, instead of taking one term at a time, I now need to take it out two by two. I know it’s something basic,…
-
2
votes2
answers98
viewsLanguage R - Use of function to prevent code repetitions
Staff I am developing a program in R language, the same compares data from two data.frame and writes in a third, the program presents several conditional structures of the type else if within two…
-
2
votes1
answer99
viewsHow to run a looping in R and store the results of a summary in a vector
I asked a previous question in this forum (Random choice of lines in an array in R) where it needed to randomly choose p lines (p < m), without replacement, of this matrix. Thus creating a matrix…
-
2
votes1
answer94
viewsGeneration of samples in R
I have a dataset with 200 observations. I generated a sample with no reset of size 100 with the following commands: library(car) require(car) (amostra1= some(dados,n=100,replace=F))…
-
2
votes1
answer55
viewsA: Spatial analysis with spatstat, sidebar does not show correct values
I’m trying to create a map with the package spatstat of R so that the sidebar shows the values of the third (preferably) or fourth column of my data frame and that the colors tmb reflect that third…
-
2
votes1
answer212
viewsHow to ignore an error in R?
I created a function inside, however, if at some point an error occurs, it is not important to me and I want it to continue until the end, ignoring the error. valor<-1 Erro<-function(valor){…
-
2
votes1
answer404
viewsHow do you return multiple objects in a function of r?
The basic structure of a function in R is: function( arglist ) expr return(value) My question is how to return multiple information. For example: funcao<-function(a,b,c){ if(c==1){d<-a+b}…
-
2
votes1
answer549
viewsReading PDF in R
I am doing a job for college and would like to get the income and audience of each game of the Brazilian championship of recent years. CBF graduates into a series of links, an example is the…
-
2
votes1
answer326
viewsHow to adjust margins on R markdown
I’m creating a document in R Markdown, but when I generate the markdown it occupies the entire area of the browser, getting bad reading. I would like to know how to adjust the margins, so that it…
-
2
votes3
answers397
viewsHow to categorize values in a Data Frame in R?
In a Data Frame I have a column with the social vulnerability index (IVS), varying from 0 to 1 by county. I need to group some values to stay as the example: #Como Está #Como preciso que fique…
-
2
votes1
answer57
viewsI cannot maintain the format of a date received from a dataframe
I have a dataframe with a date string and another time column: And I want to concatenate the date with the time to stay in the string format "2016-12-25T08:38:00" Initially I was trying this way:…
-
2
votes1
answer454
viewsPanel graphics in ggplot2
I have 25 species and would like to write only a script in which I could have a separate chart for each species (in total would be 25 small charts, in a grid 5x5). I would also like to make two…
-
2
votes1
answer334
viewsFunction`recode` (dplyr) does not accept numerical ranges
Consider the vector: x<-runif(30,20,100) I would like to categorize this vector with the function recode of package dplyr. Ranges can be arbitrary. For example: from 20 to 50 = 1 from 51 to 75 =…
-
2
votes2
answers222
viewsreshape2::melt counter function (unstack)
I’m working with data.frame and it is organized in long format. However I would like to put in wide format according to a variable (FAT2) so that the provisions of the columns would remain: AVA,…
-
2
votes1
answer65
viewsGraph is not exiting in output
library(shiny) ui <- fluidPage( titlePanel("Funcao Poder"), sidebarLayout( sidebarPanel( sliderInput("n1", "Tamanho da amostra:", min = 1, max = 50, value = 30), sliderInput("n2", "Tamanho da…