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
answer77
viewsPlotting data evolution in time on R
Good afternoon, I’m having trouble plotting this data series over time. I would like to see the frequency of clients without CPF and without note per month, and how these indicators are evolving. I…
-
2
votes1
answer3263
viewsHow to insert point and line caption in ggplot?
How do I insert the dots in the caption? The purple dot on the caption "base1" and the red dot on the caption "base2"? lines = 'Mes Lg1 total1 Lg2 total2 Jan base1 1450 base2 89 Fev base1 1700 base2…
-
2
votes2
answers914
viewsRstudio. Colors in a set of Boxplots
I created this very simple set of boxplots but intended to improve it, namely coloring each of them and eventually improve the code. Someone can help. I leave here the code I created. Thank you.…
-
2
votes1
answer86
viewsHow to store table names in a Vector in R
I need to store the names of a table in an array, as I will need to make combinations with the names. Here is an example for understanding: Table: Carro preço cor Gol 15000 vermelho uno 14000 azul…
rasked 5 years, 10 months ago Pesquisador008 59 -
2
votes1
answer526
viewsAdd error bar on graph in R
I’m trying to plot a graph but I’m not able to add the error bars with the function arrow. I don’t know what could be wrong with the code below: m12<-plot(tq1_mean~time ,type ="p", col = "red",…
-
2
votes1
answer159
viewsUse of summarySE function for graph construction in ggplot2
Hello, I am looking for an aid to improve a script in R. I develop it with the help of the ggplot2 package. I have some errors and would like to get some feedback. In the study, I evaluated the…
-
2
votes1
answer231
viewsAlternative to Miktex
Hello. I am making a document in RMD in Rstudio and would like to export it to word or pdf. I saw that for this I need to install Miktex. However, even following all the steps ( the most brief…
-
2
votes2
answers501
viewsHow to receive an input during an R function?
It is possible to ask a question and receive an input while executing a function? Example: formateCdoispontos<-function(){ print('Tem certeza que quer fazer isso? (S/N)') ...…
-
2
votes1
answer88
viewsHow to chart in r with variable titles?
I need to create a function that returns graphics in which the title name contains the variable name, as in the example. Dados<-c(5,4,8,9,2,1,6,2,5) Validação <- function(y){ plot(y,…
-
2
votes0
answers115
viewsError retrieving Central Bank report
The functions to meet the Central Bank Expectations of the Focus Report are presented the following error: Error in curl::curl_fetch_memory(url, handle = handle) : Failure when receiving data from…
-
2
votes2
answers68
viewsReplacing text with words from another file
it should be easy, but I’m not finding a solution! Here’s the thing: Arquivo1 - with texts: Doc Texto doc1 Isto é um teste para substituições de palavras. doc2 As casas são parecidas. Arquivo2 -…
-
2
votes1
answer250
viewsError generating graph with package ggplot2 in R
Hello, I am looking for an aid to improve a script in R. I develop it with the aid of the ggplot2 package. I intend to show a graph with media and standard error and the data set points. I used the…
-
2
votes2
answers52
viewsHow does a forloop generate random values, then "appenda" the next set of generated values?
k <- 8 m = 100 for (i in 1:k){ x <- rnorm(mean = i, sd = .5, n=m) y <- rnorm(mean = (8-i), sd = .5, n=m) amostra2 <- data.frame(x,y) } This is the code I have. Given k and m, I give…
-
2
votes1
answer84
viewsEncoding problem in a file folder
I switched computer today on the service and my codes stopped working, giving encoding error in the files folder: > setwd("I:/AGG/01. DIGEP/Relatórios Gerenciais/Edição/2018-08-17") > getwd()…
-
2
votes1
answer72
viewsExport file . SAP in R
It would be possible to export a file in . SAP using R or Python ? Find a tutorial that said that in R to export to . SAP it would be as follows: write_sas(df, "table.sas7bdat") But I was left with…
-
2
votes2
answers53
viewsGenerate multiple graphics in a loop using X11() and two different indices in R
Guys, this is my list. mylist=list(list(a = c(2, 3, 4, 5), b = c(3, 4, 5, 5), c = c(3, 7, 5, 5), d = c(3, 4, 9, 5), e = c(3, 4, 5, 9), f = c(3, 4, 1, 9), g = c(3, 1, 5, 9), h = c(3, 3, 5, 9), i =…
-
2
votes2
answers176
viewsTRI - using MIRT
I am applying the TRI (Item Response Theory) with the package mirt, in Rstudio. However, when applying the mirt, processing stops when it reaches 500 iterations. Is it possible to increase the…
rasked 5 years, 8 months ago Fabiana Zaffalon 21 -
2
votes2
answers632
viewsKs.test and p-value < 2.2e-16
I am trying to compare two distributions, but when I apply Ks.test for both, I only get the value of’D' and p-value coincidentally gives the same value for both, '< 2.2e-16'. I had the idea of…
-
2
votes2
answers810
viewsConvert all columns of a data frame
I know that to convert a column I can do df$COLUNA <- as.character(df$COLUNA). But my problem is that I need to convert all 80 columns of 18 arranged dataframes into one list. The idea of…
-
2
votes1
answer49
viewsSelect vector only with dates shared by all matrices in the list
I have a database with a lot of stock market assets. After running several filters to get only assets with imposed number of observations, I arrive at a large data frame and a list, as will be…
rasked 5 years, 8 months ago Henrique Faria de Oliveira 725 -
2
votes0
answers384
viewsDoubts about discriminant analysis in R
I’m trying to reproduce the accounts of example 5 of this pdf about discriminant analysis. When doing the accounts without using any package, get the same results of the file, as code below.…
-
2
votes1
answer653
viewsHow to check if all values are equal in a vector in r
I have as response of a function the vectors RMSEA, GFI, NFI and CFI that can contain all equal values. In sequence I use the algorithm below to test normality through the Shapiro-Wilk test. When…
-
2
votes1
answer39
viewsUse lapply (replacement for) to leave only columns in common for multiple dataframes in a new list
dput of the list: structure(list(col1 = structure(list(a = 1:5, b = 1:5, c = 1:5), .Names = c("a", "b", "c"), row.names = c(NA, -5L), class = "data.frame"), col2 = structure(list( a = 6:10, c =…
-
2
votes1
answer23
viewsExtract only value from the hypothesis test for an object
Good night I am performing the KPSS hypothesis test for time series stationarity, through the following commands. #Todos os pacotes necessários para o desenvolvimento do curso library(forecast)…
rasked 5 years, 8 months ago Henrique Faria de Oliveira 725 -
2
votes1
answer58
viewsLapply does not return the desired result for some functions
My list: structure(list(col1 = structure(list(a = 1:5, b = 1:5, c = 1:5), .Names = c("a", "b", "c"), row.names = c(NA, -5L), class = "data.frame"), col2 = structure(list( a = 6:10, c = 6:10), .Names…
-
2
votes2
answers186
viewsCalculating columns with conditional in R
I have the following table df Valor DebCred 100 C 200 D 300 C I have to create a logic that is the following if Table DebCred for C I have to multiply Valor * -1,00 and if it equals D multiply…
rasked 5 years, 7 months ago Victor R. Tavoni 23 -
2
votes2
answers5826
viewsUse of Seed in R
About the Seed, I don’t understand when to use: seed(1), seed(123), seed(12345). What would be the difference between them?
-
2
votes1
answer250
viewsRotate names on x-axis
Good afternoon how do I plot the graph generated by the code below so that the treatments name V10RC4, V15RC3, V20RC2 and V25RC1 appear diagonally? barplot(1:4, names.arg = c("V10RC4","V15RC3",…
rasked 5 years, 7 months ago Vitor Hugo 151 -
2
votes1
answer196
viewsColoring specific points in Ggplot - R
I’m doing a graphical analysis of the package data gapminder. Soon, I made the following code: library('gapminder') dados6 <- gapminder ggplot(gapminder, aes(x = continent, y = lifeExp)) +…
-
2
votes2
answers94
viewsSelect Time in R
I have the following df with date in date and time format: MATRICULA <- c('111','222','333','444','555') DATA_INICIO <- c('17/03/2017 22:25','15/01/2019 20:01', '10/12/2013 01:01','10/10/2018…
rasked 5 years, 7 months ago Bruno Avila 867 -
2
votes1
answer58
viewsPreserve rownames after use of apply family functions
I make use of the functions apply and, I need you to rownames stay in the database after execution of these. Consider: dataframe=structure(list(Composição100g = structure(c("Valor energético (KJ)",…
-
2
votes0
answers470
viewsError while compiling files in rmarkdown
I recently updated Ubuntu on my computer, I continued using R normally, including rmarkdown. Today I went to compile a file that had already compiled previously and the following error appeared:…
-
2
votes2
answers24
viewsInclude "." or "," from right to left of integers
I have an array with the following integer values (or strings): x <- c("1781818", "178181800", "92561781818", "1781810") I’d like to put a semicolon to separate the last two digits, so they stay…
rasked 5 years, 7 months ago George Santiago 139 -
2
votes1
answer730
viewsHow to calculate amplitude of each class in R?
I have the following variable in R set.seed(7) valor <- round(runif(35, min=30, max=100), 2) I want to calculate the amplitude (maximum value - minimum value) for each class of my data. To…
-
2
votes1
answer748
viewsBar graph name in ggplot2
I made this chart with geom_bar(), would like the title (a) followed the direction of ylab, but I’m not getting it. I used this function parameter geom_bar() theme(plot.title = element_text(hjust =…
-
2
votes2
answers349
viewsImport csv - 18 million lines in R
How to import a base of 20 million lines with 24 variables. There are two variables that are string. The base is importing these two variables as Numeric and excluding the zeros at the beginning. I…
-
2
votes1
answer47
viewsHow to create a list of values with restriction on a stipulated number of data
I have the following code n <- 130 pl <- trunc(n/20) p0 <- 20 pp <- 20 + (0:(pl-1))*p0 With the result of pp, being: [1] 20 40 60 80 100 120. In addition, I also use the same process for…
-
2
votes2
answers151
viewsPerform the tapply function for multiple variables on a dataframe (with pairwise.t.test)
I try to perform the function tapply for several variables at the same time, but using the function pairwise.t.test. However, I do not succeed. So I have to do this:…
-
2
votes3
answers121
viewsHow to exclude a specific row from a base in R
I’m validating a base on R and I’ve identified some lines that don’t make sense so I’ll have to exclude some of them. What is the best way to delete lines containing 'N', 'P' and 'K' from the…
rasked 5 years, 6 months ago Natalia Soares 81 -
2
votes1
answer98
viewsColumn of unwanted numbers in write.xlsx
I am saving a data frame in excel spreadsheet with the following command: library(xlsx) write.xlsx(df, "buildingTEPT.xlsx", sheetName = "TEPT", showNA = F, col.names = T) It turns out that the…
-
2
votes2
answers88
viewsSelect first with conditional
I am starting in R, and I have a data frame similar to this one below: x <- data.frame(cod_produto = c(1,1,1,2,2,2), valordia = c(0,0,150.23,110.98,18.65,0), data =…
-
2
votes3
answers1276
viewsA: Creating a new variable using if and Else
I’m with a base of 9 million lines. I’m trying to make a new variable called base$trs_localidade using the variable base$iso_pais being: base$iso_pais<- c( '076', '840', '076','442' , '052' ,…
-
2
votes2
answers373
viewsHow to calculate the average excluding zeroes in R?
I averaged the following values: MÉDIA = mean(c(12,20,15,0,7,0)) print(MÉDIA) [1] "9" But I need the average that doesn’t consider zeroes: MÉDIA_Sem Zeros = mean(c(12,20,15,7)) print(MÉDIA_Sem…
-
2
votes1
answer50
viewsProblems with indexing in cbind
I try to perform the function cbind as follows: reg<-lm(cbind(variable1,variable2,variable3,variable4,variable5,variable6)~kmeans,data=dataset) and it works. But consider this structure:…
-
2
votes1
answer1261
viewsRemove duplicate cases and keep specific values from another variable
Consider the following situation: I have a database with two variables. The first is a variable with duplicate values (e.g. Cpfxxx.xxx.xxx-xx appears 14 times, Cpfxxx.xxx.xxx-xx appears 18 times and…
-
2
votes2
answers5241
viewsHow to order Ascending and descending in R?
Let’s assume unique(base$workclass)#Checando os valores dos atributos das colunas, instâcias,linhas ou registros unique(base$workclass)# o resultado de apenas unico valor como seria a ordem…
-
2
votes2
answers169
viewsRemove all after the second occurrence of a comma
I have a df with addresses and want to remove everything that is after the second comma. exemplo <- c("Rua Pajé, 30, apto 44", "Av. Brasil,55, blocoB") What I’ve already tried:…
-
2
votes1
answer34
viewsR <- Vector - Error in c(vector_item, v$Qty) : Object 'vector_item' not found
A simple doubt, How to have the (new) vector briefly to avoid: for(v in i$checkout) { c(vector, v$name) -> vector c(vector_item, v$qty) -> vector_item } Error in c(vector_item, v$Qty) : Object…
-
2
votes1
answer70
viewsChart with captions overlaid in R [without using ggplot2
Hello, my chart is getting some overlapping values, already tried to increase the chart not solved. library(RColorBrewer) #cores cor = brewer.pal(12, "BuPu") gen =c(1, 130, 2, 31, 1 ) labs_g =c(…
-
2
votes1
answer136
viewsWhich object identifier should I use?
There are several functions that serve to identify objects in the R (or at least "think" they are for this purpose), such as: class() mode() typeof() storage.mode() str() that, with a simple…