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
answer78
viewsError with interactive menu function when running block code
I have a line of code that asks for a number requested from the user like this: menu(c('1','2','3'), title='Escolha um número:') But it is part of a program that uses this requested number in…
-
2
votes1
answer171
viewsSubset problem in R
I’m having trouble using subset in R. I believe it’s an easy question, but I’m not getting it right. I want to make a subset of data that I can keep, only observations that do not have the value of…
-
2
votes1
answer38
viewserror in server rselenium scraping google scholar
It is giving this error. What would be the solution? checkForServer() Error in checkForServer() : could not find Function "xmlParse"
-
2
votes1
answer383
viewsDifference between VAR and Structural VAR and Cholesky Estimation in R
I am studying the Autoregressive Vectors (VAR) method. The pet part I am understanding, but there is a question that intrigues me. Is there a differentiation between VAR and structural Var? Isn’t it…
-
2
votes0
answers228
viewsGenerate multiple samples
I’m trying to generate 500 samples of size 50 each, but it’s not working. The program follows below. require("gsl") n=50 amostra = 500 alpha = 2 beta = 3 X=NULL X<-matrix(0,nrow=n,ncol=amostra)…
-
2
votes1
answer3371
viewsHow to change the class of a variable within a table/ data frame/ Tibble?
I have a table called tab01 with the following variables (columns) and their respective classes in parentheses: uf (Character), regiao (Character), ano (double) and pop (double). I want, inside the…
-
2
votes0
answers52
viewsProblems with connection to the Bing Ads API
I am creating a connection to the Bing Ads API via R, as there is no library for this and I need to get all the data Analytics existing for my project. But I’m not getting this connection through…
-
2
votes1
answer1954
viewsContingency table in R
I have a table that summarizes in the following: Destino; Proposito; Custo;<br/> Chicago; Negocios; 35;<br/> Nova York; Negocios; 30;<br/> Miami; Turismo; 25;<br/> Chicago;…
-
2
votes0
answers251
viewsGMM (Generalized Moments Method) in R
I use GMM and would like, given a group of possible instrumental variables, R provide me the best combination with lags. For example modelo GMM x ~ a b c d VI q y z R provide, based for example on…
rasked 7 years, 11 months ago white_knight 79 -
2
votes1
answer2467
viewsMultiple Regression with R
I have a table with some columns of factors that vary over time. With multiple regression I can evaluate the influence of a group of factors on the variation of 1. How can I do this in R?
rasked 7 years, 4 months ago Bruno Rigueti 305 -
2
votes1
answer1375
viewsImport Excel Tables into R
I would like to know which is the best library to import excel tables to be manipulated in R. I would like one that supports all extensions, mainly the . xlsm.
rasked 7 years, 4 months ago Bruno Rigueti 305 -
2
votes2
answers658
viewsObtain coefficients "a" and "b" of the Linear Regression Model in R
In a Simple Linear Regression model - y = a + bx - we have the angular coefficient "b" and the intercept "a". I wonder how I do to get these coefficients in R?
rasked 7 years, 4 months ago Bruno Rigueti 305 -
2
votes1
answer607
viewsệ log' not Meaningful for factors
I tried to run an example, but gave the error below: Calculate asset returns log r <- diff(log(prices)) Error in Math.factor(prices) n <- length(r) Error: Object 'r' not found Someone knows…
-
2
votes1
answer419
viewsBeta and OR confidence interval
I have a data set to make the logistic regression of the dependent variable childbirth which is binary qualitative. I use the command below to obtain the univariate logistic model in the R program:…
-
2
votes1
answer78
viewsFunction to read file via ODBC
Hello, it must be a very simple problem, but I’ve searched a lot and I couldn’t find a solution to my question. My setting is: R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit)…
-
2
votes1
answer212
viewsStrsplit regular expression
How to assign E.R. to separate the city name ? cid <- c(cidade1..SP.Brasil,cidade2...SP.Brasil,cidade3..SPDF.Brasil,cidade4...SPDF.Brasil) In the sublime for example, this works:…
-
2
votes0
answers145
viewsUse of Ks.test for Poisson distribution
Good night, you guys. I have a question about using the Ks.test function. It is giving completely different results when using Ks.test specifying the probability distribution: ks.test…
rasked 7 years, 3 months ago Marco Machado 195 -
2
votes1
answer255
viewsI cannot run a command with the "rDEA" package
I am a beginner in R and do not understand much of the solutions in English. I believe, therefore, that a forum in Portuguese can help me. I have the following database (date): I’m trying to run the…
-
2
votes1
answer967
viewsInterpretation of Impulse Response Charts
Hey, guys, all right? I have a question when it comes to interpreting graphs of the 'response impulse functions'. I have read some books, but none of the books I have consulted is said clearly when…
rasked 7 years, 9 months ago Rodrigo Loureiro 29 -
2
votes1
answer162
viewsdifferent results using rpart and Caret
Hello, I’m testing some regression models and I don’t quite understand one thing: I used rpart from the rpart package, and then used Train with rpart method from the Caret package resultRPart <-…
-
2
votes1
answer128
viewsHow do I find the average of a note? In R
I need to add two typed notes to find the final R average (Nota1 + 2*Nota2)/3 but I don’t know how it makes the final calculation for the script to work without error print("Escreva seu nome")…
rasked 7 years, 3 months ago Carlos Winter 39 -
2
votes1
answer871
viewsArea and Line Graph in R with x-Axis as String
I would like to make an area chart and insert another line chart overlaid. I’m not able to do this, because the x chart that I want to put are strings and it gets all wrong. The picture should look…
-
2
votes0
answers54
viewsLogging into site with R, what error?
I’m trying to log into a site, the value site is merely illustrative, someone knows why the function is not working? login <- function (xxxx_user, xxxx_pass) { url_login <-…
rasked 7 years, 9 months ago Danilo Imbimbo 533 -
2
votes1
answer127
viewsHow to get the table with the data that generate the graph with the DECOMPOSE command in R
Good afternoon, you guys. I generated this graph with the "decompose" command in R. What I’d like to know is how to extract the data from each of these components into a table. For example, I want…
rasked 7 years, 2 months ago Leonardo Barbieri 23 -
2
votes2
answers1628
viewsI want to generate an R table for Latex
I want to generate a table with the R Summary data with the results I got, I know there’s a library called Stargazer that does, but I couldn’t find the documentation.
-
2
votes1
answer1029
viewsCreation of Boxplot in ggplot2
I’m doing some simulations on R. By generating a data.frame and request the impression of boxplots with small sample size and number of samples boxplot is generated perfectly. The problem is when…
-
2
votes1
answer303
viewsHow to install ajdamico package?
I tried, but: Downloading GitHub repo ajdamico/lodown@master from URL [...] Installing lodown Downloading GitHub repo jimhester/archive@master from URL [...] trying URL [...] Error in utils:…
rasked 7 years, 1 month ago Alvaro Frota 21 -
2
votes1
answer117
viewsHow do I synchronize git folders to allow me to use R files simultaneously on multiple stations?
I did an account in Git, and it’s supposed to allow me to use R files simultaneously on multiple stations. But I have fought hard to succeed in the SSH key that the platform asks for. And now I…
-
2
votes4
answers129
viewsBuild database
I need to build a database with 200 rows and 4 columns (with the 4 variables I idealized). I devised a study to estimate the presence of snakes in a given city, I have no data. I thought that the…
-
2
votes2
answers2546
viewsHow to view comments on Rstudio console?
When I write a comment (preceded by the "#" symbol) in a Rstudio script, and press the 'Control+Enter' command, my comment is not displayed on the console screen. Someone would know me how to make…
-
2
votes0
answers58
viewsError in submitting form
Good afternoon, I have a code that works for some forms on the web and I’m trying to reuse it on this site: http://www.anbima.associados.rtm/titulos-publicos/estrutura-a-termo/tp-estrutura-termo.asp…
-
2
votes2
answers102
viewsFactor Column for Date
My data frame x=structure(list(V1 = structure(c(33L, 35L, 36L, 37L, 39L, 4L, 6L, 7L, 8L, 10L, 14L, 16L, 18L, 19L, 21L, 25L, 27L, 28L, 29L, 30L, 1L, 17L, 31L, 32L, 34L, 38L, 40L, 2L, 3L, 5L, 9L, 11L,…
-
2
votes1
answer119
viewsSaving rows of a data frame based on the values of a column of another data frame
I have a dataframe with 50 rows and 10 columns and another with 10 rows and 5 columns, with the first column of both dataframes can have equal values. How do I select and save the rows, only, from…
rasked 7 years ago Flavio Costa 23 -
2
votes1
answer134
viewsIn R, use dplyr functions to find the minimum distance
I have a matrix with two numerical variables: lat and long. Like this: > head(pontos_sub) id lat long 1 0 -22,91223 -43,18810 2 1 -22,91219 -43,18804 3 2 -22,91225 -43,18816 4 3 -22,89973…
-
2
votes1
answer1513
viewsArray Column Names using R
This is my matrix in R: n_forward=50 matriz=matrix(0,nrow=length(1:n_forward),ncol=16) The number of lines depends on the command n_forward. From there I want to name the lines in t+1, t+2,....…
-
2
votes2
answers690
viewsSearching strings in R language
I need to search a df column where the text may not be exact. Example: df$titulo=="SE" & df$titulo=="projeto de pesquisa" can’t find anything. I’ve tried using like instead of =, I’ve tried…
rasked 7 years ago André Nascimento 1,258 -
2
votes1
answer67
viewsHow do I eliminate the first variable for testing with the t-1 variable?
I import the Excel files but I can’t lag the variable in R. The lag function it eliminates the first observation and I can’t use nrow or anything like that. How would I do it? I wanted to use it to…
rasked 7 years ago André Takano 21 -
2
votes1
answer440
viewsStrata R function not found (Ubuntu)
Good afternoon, I’m studying R on Ubuntu (16.04 LTS). When trying to use the strata function via the command below: amostra = strata(infert, c("education"), size = c(5, 48, 47), method = "srswor")…
-
2
votes1
answer755
viewsMulti-line chart
I have a data frame with information of weight gain as a function of the time of several animals. Accurate plot a graph with connected lines. However I need a line for each animal in a single graph,…
rasked 6 years, 11 months ago Luciano Hauschild 431 -
2
votes1
answer340
viewsMatlab to R translation with system(sprintf())
I am trying to translate the following Matlab code to R: clear all nsta = [1,2,3]; npx = [2,3,4,5]; npu = [2,3,4,5]; nmax = 2500; nome = 'MODEL1b'; system(sprintf('del %s.log',nome)); nfiles = 0;…
-
2
votes1
answer284
viewsSelect ID vectors with certain characteristics in R
I have a data frame with four columns of values for each ID and need to create a new df excluding Ids whose vectors have more than one zero or more than one NA. I created the DF library(dplyr)…
-
2
votes1
answer145
viewsStrange result on to.Monthly (quantmod package) cut series
Problem with my to.monthly. He cuts my data series, I don’t know why. ####install.packages("quantmod") library(quantmod) ####install.packages("PerformanceAnalytics") library(PerformanceAnalytics)…
-
2
votes1
answer70
viewsInclude javascript in Shiny
I would like to include the event "Restoring column visibility (https://datatables.net/extensions/buttons/examples/column_visibility/restore.html), the code would be the one below:…
-
2
votes1
answer61
viewsIs it possible to convert this for loop to an apply family function?
df_loop <- data.frame(data1, data2, data3, 0) for (i in 4:nrow(df_loop[1])) { tmp_1 = df_loop[i,1] tmp_2 = df_loop[i,2] tmp_2_lag3 = df_loop[i-3,2] tmp_3 = df_loop[i,3] if (!is.na(tmp_2_lag3)) {…
-
2
votes1
answer1070
viewsNumber of items to replace is not a multiple of the length of the substitute
I am trying to create a method for the Minkowsky formula but it is giving this error. It happens in the line where I try to assign the value to matriz_distancia[i,j]. distancia_minkowsky <-…
-
2
votes1
answer2020
viewsHow to create a chart of averages and standard deviation in a data set that includes missing values (Nas)
Hello! I work with bioacoustics and I’m trying to create a graph of averages per species using the lineplot.CI function of the sciplot package, but I can’t make R ignore the missing values (NA).…
rasked 7 years, 5 months ago Pedro Rocha 23 -
2
votes0
answers951
viewsError trying to save script to R
When I try to save my script appears the error message as per image. How to solve this problem?…
-
2
votes1
answer86
viewsNegative age in R
I have a database that I need to calculate the age of the limbs in it, below a sample taken with the dput. base.teste <- c("04/03/73", "10/09/67", "21/12/74", "17/04/76", "25/03/66", "11/03/73",…
-
2
votes2
answers865
viewsDownload CSV file using R
Good afternoon, everyone! how do I download (read) a CSV file from a link like this:…
-
2
votes3
answers407
viewsDelete "X" in Header in R
I am importing a csv file into the R and the name of each column is appearing the letter "X" before the original name. For example: Field names in csv: 1.2_cidade; 2_UF. Field names after import:…
rasked 6 years, 9 months ago Bruno Avila 867