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
votes0
answers26
viewsR and SQL - How to join a data.frame in R with a table in SQL?
I have a table in Postgresql that contains the column "cnae". I also have a data.frame in the R with columns "cnae" and "Description". I need to move the "Description" column up to the table in…
-
1
votes1
answer42
viewsMean by line range
I’m working on the R with only 1 column, it has 3651 lines and need to make several averages along the column. I need the average every 5 lines. I am working with atmospheric pressure data. and they…
rasked 4 years, 9 months ago Kamila Almeida 11 -
1
votes0
answers101
viewsDynamic Valuebox R
good morning! I’m doing my first R Dashboard using the flexdashboard package on R markdown and Shiny. When selecting the filter in (Selectinput) my (Value Box) is static, as I do to make it dynamic…
-
1
votes0
answers58
viewsLoop entire script -- more than one R variable
I have a script with five variables. Suppose the variables and their data types/classes are the following: var1(date) var2(date) var3(date) var4(date) var5(Numeric) I would like to import a…
rasked 4 years, 8 months ago Fernando Vieira 71 -
1
votes1
answer33
viewsObtaining vehicle forecast (Interpretation of output)
Hello, I am starting in the use of the programming in R for the realization of a project in which I am involved. The question is the following: I have data of counting vehicles hour by hour from…
-
1
votes0
answers83
viewsHow to invert the values of a column in a Dataframe in R?
For example, the column in my Data Frame has values from 1 to 7; I want to replace 1 by 7, 2 by 6, 3 by 5, and so on. How to do this in R? variable = 1,2,2,4,3,6,7 desired result = 7,6,6,4,5,2,1…
rasked 4 years, 8 months ago Daniel Max 11 -
1
votes2
answers283
viewsx-axis for time series in ggplot
I have a graph with the following syntax in ggplot n <-data.frame(x = c(NEP$NEPeleitoral), y = c(NEP$`NEP parlamentar`), z = c(NEP$anoeleicao)) ggplot(n, aes(x = n$z, y = n$x)) +…
-
1
votes2
answers308
viewsReplace numeric values of one vector with another value in a data frame
i would like to replace (replace) the values of a given index (vector) which find corresponding in a dataframe (tbl) by another value determined by me. I tried the following # Criando um index…
-
1
votes2
answers124
viewsR - problems converting txt to read in R
I have a '.xls' that I passed to '.txt' for the R reading, no problem. The point is that by opening '.txt' in R with read.table, it shows me as a single table, in a single R position. > x V1 1 X…
-
1
votes2
answers242
viewsFormat latitude and numerical longitude coordinates in R
I received a data frame with the coordinates of the schools of the city of São Paulo. They were separated by dot in the thousands, as a number -23,456,789. Thus, R reads the value as Chr. There were…
-
1
votes1
answer393
viewsCorrelation graph with coefficients and significance together
I am trying to represent a correlation matrix that contains the correlation coefficients and significance in the same graph.I have read in another post that with the corrplot it would not be…
rasked 5 years, 8 months ago Rodrigo Lopez 11 -
1
votes2
answers840
viewsGroup data by a certain column in the R
I took some data because it is 1704 Obs. of 6 variables. So I selected the first 80 lines. Follow the code below: structure(list(country = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,…
rasked 5 years, 8 months ago Fidel Henrique Fernandes 119 -
1
votes1
answer114
viewsHow to filter data by a text pattern in R
I have a database with data of Brazilian cities and states, I would like to filter only the states, all follow a pattern of having a "br_states_" before the name of the state. I tried to use the…
-
1
votes1
answer243
viewsHow to use filter_functions?
I try to use the functions filter_ (all, at, if), but unsuccessfully, mainly for strings. Consider the data set below: set.seed(1234) data_1 <- data.frame( a = c(paste('group', 1:6, sep = '_')),…
-
1
votes1
answer47
viewsCurve does not fit on the Lines
I’m trying to include the curve predicted in my graph, but it doesn’t fit. I’m using the following argument: plot(df$n.kill, df$body) lines(df$n.kill,predict(fit,df$n.kill)) Dice:…
rasked 4 years, 6 months ago Milton de Paula 305 -
1
votes1
answer40
viewsaccent str_extract()
I need to do an analysis of books in Brazilian Portuguese. To organize a frequency list of words per book I am using the commands: GS.tidy <- GS %>% unnest_tokens(word, text) MM.tidy <- MM…
-
1
votes1
answer63
viewsTidyr spread does not return to original data
Consider the data.frame: df_1 <- data.frame( a = replicate(6, runif(30, 20, 100)), b = rep(c(LETTERS[1:5]), times = 1, each = 6) ) Use of gather: library(tidyverse) library(magrittr) df_1…
-
1
votes0
answers32
viewsIs there any functional difference between bind_rows (dplyr) and rbind.Fill (plyr) in R?
I would like to know if using one function instead of another there would be some differential in relation to the final dataframe to be produced. There were situations I tried to accomplish…
-
1
votes1
answer48
viewsHow to make a double filter on a long-format dataframe
I have a DF in long format with data from several countries. I would like to make a filter to fetch the last available value of the variable total_tests of each country, those without data are…
-
1
votes2
answers58
viewsHow can I filter the first occurrences of a certain variable in my R data frame?
I am working with all the Ufs in Brazil: date <- c("03/06/2020", "03/06/2020", "05/06/2020", "06/06/2020", "07/06/2020") uf <- c("RJ", "SP", "RJ", "SP", "RJ") confirmed <- c("0", "1", "1",…
rasked 4 years, 5 months ago Rodolfo Bramont Eiriz de Souza 13 -
1
votes0
answers23
viewsexclusion of a column element in a dataframe
Hello, I have the following dataframe: Município (Código) Município Valor 2 1100015 Alta Floresta D'Oeste - RO 408765 3 1100023 Ariquemes - RO 477322 4 1100031 Cabixi - RO 126630 5 1100049 Cacoal -…
rasked 5 years, 8 months ago Ingled M Cardoso 159 -
1
votes1
answer43
viewsSum of values in two different columns based on other columns in R
Hello, I’m trying to make the sum of goals made and goals suffered from a set of dice, someone can help me? Basically I have the data as follows: Mandante Gols Feitos Gols Sofridos Visitante…
-
1
votes1
answer49
viewsPerformance of conditionals in R: how to accelerate this process?
I am working with a data.frame with more than 29 million lines, and I need to do some validations exchanging the data if necessary, but I am using ifelse which is extremely slow, there is some way…
-
1
votes1
answer78
viewsHow to replace lost data frame values with the average of each column in R?
I have this table: tabela<-data.frame(v1 = c(1,NA,3,5,4), v2 =c(NA,NA,1,2,4), v3 = c(6,5,4,7,NA)) I need the lost values of each column to receive the average values of that column. How to do…
-
1
votes0
answers21
viewsExclude line from a dataset not contained in another [R]
Hello, I am doing a work on HDI and Covid and I need to join two columns, the problem is that both are with number of different lines, and the reason is the number of municipalities in which each…
-
1
votes0
answers95
viewsR Shiny - publication problems
Good afternoon, I’m having trouble publishing a fuzzy logic system with R Shiny. The system runs normally in R environment, but when publishing the system returns me the error message: The…
-
1
votes1
answer160
viewsHow to decompose a time series using a frequency of 6 months?
I have a sample of data with the period of one year. I Gero the time series without problems with the frequency = 12, but when will I use the decompose it shows the following error message: Error in…
rasked 5 years, 8 months ago Izak Mandrak 1,059 -
1
votes1
answer41
viewsProblems with NA in R
Good evening everyone, I want to write a function in R that checks the even elements and display them on screen later. From that I wrote the following code: pares <- function(v){ for(i in v){ if…
rasked 4 years, 4 months ago antonioguedes 13 -
1
votes2
answers52
viewsR regression on same line data
I have the following data: mes <- c("jan","fev","mar","abr","maio","jun","ago","set","out") a <- c(32.3,32.7,32.6,33.1,33.0,33.5,33.4,33.4,34.9) b <-…
-
1
votes1
answer47
viewsHow to consolidate data set with dplyr?
Hello, I have a data set sinan18 that contains information about food outbreaks in Brazil. Formatting the original table - which is huge with dplyr, I arrived at the following result: >…
-
1
votes1
answer28
viewsWhy does R have multiple folders for Libraries?
I upgraded the version of R to 4.0 and am having problems with some libraries. Trying to fix it, I found the command .libPaths() > .libPaths() [1]…
-
1
votes1
answer42
viewsProblem with "ifelse" - Object cannot be coerced to type 'double
Good afternoon. I’ve been researching the error, but I haven’t found a solution. I tried to transform the object a but I was unsuccessful. Any hint? I have the following problem: class(ativos) [1]…
rasked 5 years, 8 months ago Gabriel Guilherme 31 -
1
votes0
answers27
viewsConvert pdf to TIFF
I need to convert a pdf to an image .TIFF. I’m using the code below: library(pdftools) library(tiff) convertidoTIFF <- pdf_convert(pdfTeste, format = "tiff") length(convertidoTIFF) armaz <-…
-
1
votes1
answer51
viewsWeb Scrapping R
I tried several ways but I can’t make Scrapping from the following table: http://www2.bmf.com.br/pages/portal/bmfbovespa/boletim1/TxRef1.asp. Until now through the following code: library("rvest")…
-
1
votes0
answers42
viewsHow to load objects in the UI in Shiny
Hello, good morning, good morning! I have no knowledge of the shiny, and I’m having trouble executing some actions. I’d like him to execute one reactive by means of the selectInput, radioButtons,…
-
1
votes1
answer68
viewsgrouby of cells of a dataframe returns Error in Eval (substitute (expr), send, Enclos): non-numerical argument for binary operator
I want to calculate the differences between cells in a dataframe of a column. > head(df_benchmark) Date .STOXXR 1 2000-01-03 478.52 2 2000-01-04 459.53 3 2000-01-05 448.19 4 2000-01-06 446.24 5…
-
1
votes0
answers36
viewsProblems in UI interaction with conditioning
Hello, good morning! I’m having trouble calculating soil variables. the code keeps saying: argument is of length zero. The control has to work as follows: 1 select the crop, in the tab "Culture"…
-
1
votes0
answers36
viewsExchange map results using leaflet and state_popup
I have a database of medical appointments by city. I use the leaflet and state_popup function to display the results on a map, as described below: pal <- colorBin("Blues",domain =…
-
1
votes0
answers39
viewsHow to optimize search parameters in r?
I’ve been waiting for hours for my code to finish running. I imagine there must be a smarter way to do this, after all I don’t need to visit every point when I have a monotonous function around a…
-
1
votes0
answers53
viewsHow to make a dendograma from qualitative variables in R?
Good morning. Please, I need a script or explanation of how to make a dendograma/cluster from qualitative variables. I saw somewhere that it is possible to do that using the output of ANACOR, but I…
rasked 4 years ago Pedro Alexander Velasquez Vasc 35 -
1
votes1
answer90
viewshow to create a frequency histogram with preset non-uniform intervals?
How can I make a histogram on Rstudio with the frequency on the y-axis and on the x-axis non-uniform predefined intervals, for example: 0-50, 50-150, 150-500, 500-2000. I have a hypothetical…
-
1
votes1
answer133
viewsProblems with xml to transform into data.frame in R
Good night I need an xml collaboration, I have little knowledge for R in this I have the following xml structure To help me, please copy to a txt and save in xml format to use…
-
1
votes1
answer43
viewsCharacters KWIC Quanteda
Hello I am using R together with Quanteda to survey KWIC in a corpus of the agency Lupa. I have problems with the characters. I import the corpus as follows: corpus.fake.df <-…
rasked 5 years, 7 months ago user135517 -
1
votes1
answer826
viewsHow to filter data in a data.frame using a certain amount of time in R?
Suppose I have one data.frame four-column: print(Dados) CLIENTE QTDE VALOR$ DATA_COMPRA 1234 2 50 2019-02-04 4586 1 70 2019-01-17 6535 3 25 2018-12-28 9562 1 150 2018-12-25 3478 7 12 2018-10-12 2684…
-
1
votes2
answers153
viewsHow to delete and then create all variable names in a data.frame in R?
Let’s say I have a data.frame 6x5, for example: print(Dados) Linha A B C D E L1 4 3 2 2 4 L2 1 11 1 1 1 L3 0 1 2 3 4 L4 2 0 0 8 0 But I want to exclude the "head" of data.frame, i.e., exclude the…
rasked 5 years, 7 months ago Izak Mandrak 1,059 -
1
votes1
answer30
viewsHow to edit values in a column?
Hello, I have a dataset with the following columns date total_cases 2019-12-31 0 2020-01-01 0 2020-01-02 0 2020-01-03 0 2020-01-04 0 2020-01-05 0 I am trying to take days and leave only the year and…
-
1
votes0
answers30
viewsHow to count the occurrence of a word in a textual corpus of R?
I’m running a lexical analysis with a pretty large database. Since there are many terms, R says that there is no vector memory to form the matrix with each of the terms and their respective…
rasked 3 years, 10 months ago Giulia Sbaraini Fontes 11 -
1
votes0
answers141
viewsR - Ripley function K error
I’m trying to do a spatial distribution analysis with Ripley’s K test on the R software. I tried to use the "splanc" and "spatstat" package. My question is as follows, as I do to create a…
rasked 5 years, 7 months ago Gustavo Mourao 19 -
1
votes1
answer581
viewsHow to add lines in a data.frame and or table in shinyserver?
Hello, good night, good night! I’m trying to sort some things out by shiny, but I ran into a problem, I need to create a data.frame, where I am able to add lines of information, without being doing…
-
1
votes2
answers1868
viewsHow to position the title in ggplot2 with theme_ipsum?
I have the following data dados B Freq 1 Feminino 61.54 2 Masculino 38.46 With the code below I graph a pizza using the package ggplot2: library(ggplot2) library(hrbrthemes) dados <- data.frame(B…