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
-
3
votes2
answers957
viewsLodown facility
I am trying to install the lodown package, but the following error appears and I cannot solve: ERROR: loading failed * removing…
rasked 7 years, 1 month ago Larissa Cardoso 31 -
3
votes2
answers221
viewsCreate a vector with the Levels of a factor in r
I have a column in my data matrix as follows: > as.factor(matriz$especime) [1] 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 [29] 3 3 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7…
-
3
votes3
answers1220
viewsUse of the sub function in R - string with special characters
I am operating a database with the following values: data$Col_new <- data$Col_old Col_Velha Col_Nova Médico Médico Médica Intensivista Médico Técnica em Enfermagem Técnica em Enfermagem…
-
3
votes0
answers287
viewsOne of my Shiny applications is not running on my server
I recently installed Shiny on a server I have. This can be checked by clicking at this link. I would like to put on this server several applications that I have done and still intend to do, as if it…
-
3
votes3
answers743
viewsCount of TRUE and FALSE
I have a vector with only true and false, would like to know how do I count how many true and false have in this vector?
-
3
votes2
answers186
viewsRun command for each column of a date.frame
Hi, I have a data.frame (df) 8 rows x 8 columns. I am calling the columns "ST[i]". df <- structure(list(ST1 = c(58.69, 58.5, 58.5, 58.69, 58.69, 58.5, 58.69, 58.69), ST2 = c(68.7, 68.42, 68.42,…
-
3
votes1
answer310
viewsCalculate average and deviation time series data
I have a database of information of consumption of animals. The date of beginning of collection of consumption of each animal is different. Here is an example with only two animals: Animal Dia…
-
3
votes2
answers237
viewsHow to create an array with repeating dates?
I need to create a vector with sequential dates between 01/01/2013 and 05/31/2018, but with repetitions, as an example below, associated with time. 01/01/2013 0:00 01/01/2013 1:00 01/01/2013 4:00…
rasked 6 years, 6 months ago Andreia Almeida 183 -
3
votes1
answer151
viewsCustomize boxplot
I have the following data: structure(list(NotasMateriais...4. = c(1L, 2L, 8L, 5L, 5L, 4L, 4L, 2L, 9L, 2L, 5L, 3L, 1L, 3L, 0L, 3L, 3L, 2L, 2L, 3L, 0L, 2L, 14L, 0L, 0L, 3L, 6L, 3L, 4L, 3L),…
-
3
votes1
answer546
viewsBoxplot in R pattern
I intend to connect a line connecting several boxplots on R. I’ve tried using the functions abline and lines, but I did not succeed. How can I solve my problem?…
-
3
votes1
answer102
viewsNavigate between pages from a web page bar
How to browse pages that are in a web page bar? Specific case: When performing a query on the TCM-Ba website, on the page that records the expenses of municipalities, it is possible to access some…
-
3
votes2
answers195
viewsCreate a calendar dimension with the month before Sys.date.
Hello, the scrip below creates a CSV with a Calendar dimension from the year 2015 to the current month. It turns out that I would like the function to return the month before the execution. Ex: If…
-
3
votes2
answers95
viewsGenerate a date after a specific date
I have a column of a table with dates, I need to create another column with random dates and after this one. I used seq.Date function for this but I get the following error.…
-
3
votes2
answers80
viewsIndicator in variable-conditioned R with duplicate values
Suppose there is a basis with two variables as follows: Município IF RIOBOM Cooperativa RIOBOM Cooperativa ABADIA Múltiplo ABADIA Múltiplo ABADIA Cooperativa ABADIA Banco DOURADOS Banco DOURADOS…
-
3
votes2
answers692
viewsHow to reverse the order of labels on a bar graph stacked with ggplot2?
I am trying to create a chart with the following code: ggplot(data=percent.prod, aes(x=Ano, weights=Percent)) + geom_bar(aes(fill=Tec), color="Black") + geom_text(aes(x=Ano, y=Percent, group=Tec,…
-
3
votes1
answer139
viewsSpeed in crossing tables - R
good night! I cross two bases in Rstudio, using the merge, however, I would like to know if using another crossover medium (ex:left_join), I get faster, because my tables reach 8 million lines.…
-
3
votes1
answer132
viewsCustom Line Chart - any tool
I need to create a line chart (python, R or even excel), where each line is a product category, the y axis is the sale and x is the time. If the sale is above the finish line, the line stays of one…
-
3
votes1
answer55
viewsDelete totalizing lines
I have the following structure of a database: MES EST.DET1 EST.DET2 EST.DET3 DIAS 2 Curso 1 Turma A Manha 5 2 Curso 1 Turma A Tarde 5 2 Curso 1 Turma B <NA> 5 2 Curso 1 <NA> <NA>…
rasked 6 years, 11 months ago Rafael Cunha 4,954 -
3
votes1
answer323
viewsWhat does the function of %% and %any% on the r?
I’ve been reading the R’s documentation and the document Arithmetic{base}, Arithmetic Operators I came across the %% who claims to have the mod function, which I assumed was the modulo function, but…
-
3
votes2
answers1414
viewsIn R, how to calculate the average of one column based on another?
I have the following table XLSX: I need to calculate the SP500 column average for each year. I did it with 'Mean(namedabela$SP500)' and found the total average. Now I need the average for each year.…
rasked 6 years, 5 months ago Victor Oliveira 33 -
3
votes1
answer474
viewsHow to look for a word within a text in R
I need to know if within a certain text there is a specific word, for example fnord. So far I’ve only found: x<-"fnord: Você não tem nivel de acesso a está informação." strsplit(x, "[[:punct:]…
rasked 6 years, 4 months ago Márcio Mocellin 1,443 -
3
votes1
answer698
viewsInitial values in function nls in R
Hello, I have the following code in R temp<-c(10,12,14,15,17,20,22,23,25,26,28,29,30) taxa<-c(2,4.5,6.1,7.0,11,16,19,21,22,11,2,0.1,0.001) taxa<-taxa/9 plot(temp,taxa) df<-…
-
3
votes1
answer3255
viewsCalculate difference between dates in days on the R
How do I calculate the difference between dates and have the result in days? I have a column in my table called input with data similar to the ones shown below: Entree 2017-01-27 2017-06-01…
-
3
votes2
answers1529
viewsRemove NA in a Data Frame
I import file containing more than 30 columns. A few blank rows that I imported the R recognizes as "NA". When exporting these same columns, the rows that should be blank (empty) appear with "NA".…
-
3
votes1
answer181
viewsMultiple join on R
I have two tables: dados and dados_aux. I need to add to the table dados the column REGIÃO, present in the table dados_aux. However, I have to use two keys to make the Join: CIDADE and UF.…
-
3
votes2
answers97
views -
3
votes1
answer1025
viewsVariables selected in GLM being used in GLMM
I would like to ask a question about generalized mixed linear models. I know that the hierarchical structure of the observations, their independence and the existence of unbalanced samples among…
-
3
votes1
answer79
viewsCorrelation between two dose-response R curves?
I would like to know how to correlate two dose response curves of the "drc"? Example: ryegrass.m1 <- drm(rootl~conc, data = ryegrass, fct = LL.4()) ryegrass.m2 <- drm(rootl~conc, data =…
rasked 6 years, 9 months ago Vitor Muller Anunciato 127 -
3
votes1
answer146
viewsHow to create a loop that turns columns into variables and returns Shapiro.test at the end?
I have several . csv files with a high number of columns. I would like to optimize the work by creating a function that reads the columns and returns the result of the normality test (Shapiro.test)…
-
3
votes1
answer201
viewsTruncation of values in R
I need to do a survey to detect how many employees currently earn equal to or above the INSS ceiling (R$ 5531.31, in the base reference month). The databases I have inform the contribution values of…
rasked 6 years, 9 months ago Flavio Silva 1,108 -
3
votes1
answer42
viewsGraph generation error in R
Hello, I’m trying to create a chart from a list, but I’m not getting it. The download part works perfectly: # download adj. price data - Asset[1],Asset[2]... symbols= c("TIET4.SA","BVMF3.SA",…
-
3
votes1
answer86
viewsWhat is the logic of Function(x) and Function(x,y) in R?
In the execution of loops with functions apply, is always used function(x). Example: lapply(df,function(x)gsub('[^A-Z]','',x)) In other functions, however, it is used function(x,y). Example:…
-
3
votes1
answer1331
viewsA - Download data from the Hidroweb portal
The National Water Agency makes available in its portal Hydroweb the download of historical series referring to the data obtained by several monitoring stations. I would like to automate the…
-
3
votes1
answer126
viewsCreate one column indexed to another in R
Good afternoon ! I am new to R and have a database where I need to include a column, however the values of this column need to be linked to the values of another column. In case, I have the column…
-
3
votes3
answers91
viewsIs it possible to pair values of two dataframes with different observation numbers?
I have two data frames: Sexo <- rep(1:2 , length.out = 51) Estudo <- rep(1: 17, length.out = 51) Salário <- c(runif(51, min=900, max=3000)) data1 <- data.frame(Sexo, Estudo, Salário)…
rasked 6 years, 8 months ago Arthur Baldini 99 -
3
votes1
answer47
viewsMake the variables created with lapply be allocated in their respective dataframe within a list
Use the function lapply and wish the results to return within their respective dataframe within the list. Consider the following function:…
-
3
votes1
answer587
viewsHow to group information into a data frame from missing data?
I need to exclude empty lines from the df of a 30-year time series, with three daily measurements for each variable. I have already used the function subset(x, ...) that solves part of the problem.…
-
3
votes1
answer144
viewsHow to remove lines based on the values of another variable?
Consider the dataframe: data<-data.frame(a=c(1,3,4,5,6,NA,6,NA),b=c(1,NA,NA,4,6,7,NA,1)) I want to eliminate the whole line when it exists NA in variable 'a'. So what I hope is: data a b 1 1 1 2…
-
3
votes2
answers349
viewsHow to insert missing dates into a data frame?
I have a time series with 30 years of data that presents filling failures. As noted in the example below, a few days were not recorded (1961-08-19,1961-08-20,1961-08-21...). How do I identify and…
rasked 6 years, 7 months ago Andreia Almeida 183 -
3
votes1
answer67
viewsHow to transfer a table from the clipboard to a R data.frame
Motivation In various language questionsRI see people putting the contents of a table instead of showing the steps to reproduce the data they’re analyzing. Requests to provide the result of the…
rasked 6 years, 7 months ago Marcos Banik 1,779 -
3
votes2
answers64
viewsAutomatically add all Environment elements to a list
Suppose my Environment contains the following objects (fictitious names): abcd # numeric efgh # dataframe ijkl # matrix mnop # character My goal: put them in a list automatically without having to…
-
3
votes2
answers48
viewsMatrix of Expression
I have the following matrix on R: FC12h FC10d FC6w -8.44770875 -0.37171750 0 -56.72384575 2.64778150 2.94636550 -3.00214850 2.64778150 -1.57755700 I need some function that causes numbers greater…
-
3
votes1
answer171
viewsA - How to calculate the price variation for different periods and companies?
Hello, I would like to know how to calculate the price variation from one period to another. Being several years for several companies. Example: Company | Year | Price 1 |2007 | 25 1 | 2008 | 30 1…
-
3
votes1
answer147
viewsError importing decimal numbers into R
I am trying to import a decimal column in csv (part of a dataset) through the function read_delim. However, columns with decimal numbers (comma-separated in the original dataset) are coming as…
rasked 6 years, 1 month ago Diego Peliciari 319 -
3
votes1
answer359
viewsWhat is rank-deficient and how to get around that?
I did a linear regression lm(), where he declared some variables as factor, and I got some Bs as NA as: citySão José NA When I made the prediction, the prediction occurred and I received the…
-
3
votes2
answers253
viewsFile Import in R - Taking only part of the name
To with a local file xlsx, only that the file name is random (changes date and time at the end of the file name), and wanted to know if you can read the file only by the beginning of the name.…
rasked 6 years ago Layla Comparin 553 -
3
votes1
answer75
viewsHow to transform a written sequence into a numerical sequence? (R)
I’m having trouble manipulating a TSE bank. The part below the code matters it: library(tidyverse) locais_vot_SP <-…
rasked 6 years, 7 months ago Camila Gonçalves 31 -
3
votes1
answer54
viewsHow to get the N-Points FFT in R?
Hi, I have a question about FFT, I am seeking a similar method to numpy.fft.rfft. I wonder if anyone knows a way of calculating the R N-Points FFT. The following is code with only normal fft.…
-
3
votes1
answer119
viewsShiny error when generating HTML
I am trying to "create an odds calculator for the Normal and Binomial distributions, however this giving some error when generating HTML..Follow the codes below. PS: it would be possible to exchange…
-
3
votes2
answers144
viewscycle for calculation of a function
I intend to cycle for but it’s not working. My R knowledge is still poor. I intend to calculate a function F(y, x) = 1 + y + y^2 + ... + y^x = sum(y^(0:x)). I wrote the following code, but it is…