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
votes1
answer1756
viewsError: The condition has length > 1 and only the first element will be used
I am writing a code in the R but it informs the following error: In if ((Bwgmax * (1 - Exp(-K * (Mcisimulate - Xm)))) > WG) { : the condition has length > 1 and only the first element will be…
-
3
votes1
answer419
viewsHow do I access a position in a character array?
The following code returns me a vector of 12 letters: res <- "ACDEDEAEDCED" res <- strsplit(res,"", FALSE) View(res[4]) Error in . subset2(x, i, Exact = Exact) : out-of-bounded index More when…
rasked 8 years, 8 months ago André Oliveira 376 -
3
votes2
answers465
viewsIs there a function that checks if a certain value is contained in a certain range?
Supposing: x=120,00 limites.inferior<-80 limites.superior<-160 limites<-c(limites.inferior,limites.superior) I am performing this procedure with a logical test: x.int<-x>=limites[1]…
-
3
votes1
answer87
viewsWhat is the best way to perform a descriptive analysis of birth dates in R?
I have in my data table a column of birthdates that are in the English model, but I don’t know how to analyze it descriptively nor what resources to use of the R. Should I use a bar chart or…
-
3
votes2
answers16023
viewsHow to correlate qualitative and quantitative variables in R?
I have a table of data where I have qualitative variables, such as gender and origin, and quantitative variables such as cholesterol rate, weight and height. It is possible to correlate these…
rasked 8 years, 8 months ago Cloves Paiva 369 -
3
votes1
answer203
viewsGraphical package faster than ggplot2
you know some package in R that concatenates and makes 2D and 3D graphics faster than ggplot2?
rasked 8 years, 7 months ago Wagner Jorge 1,377 -
3
votes1
answer3317
viewsHow to turn rows into columns, when the number of rows is variable in R
I have a data frame that way: And I need him to stay that way: The variable that defines the column can be calculated according to the image below The sequence starts with each id change, in excel…
-
3
votes1
answer212
viewsHow to check if a polygon is convex
How do I check if a polygon is convex? The input can be given by: #Por exemplo um quadrilátero, a primeira coluna é x e a segunda coluna é y. quadrilatero = matrix(c(0,2,-7,1,4,3, 4,5), ncol = 2)…
-
3
votes3
answers319
viewsRemove dataset elements by factors
Recital a dataset: set.seed(1) fatores = sample(1:12, 30, replace = T) x = matrix(rnorm(60), ncol = 2) dataset = cbind(fatores, x) dataset = data.frame(dataset) dataset$fatores =…
rasked 8 years, 6 months ago Wagner Jorge 1,377 -
3
votes1
answer109
viewsCreate package on Windows
Given a set of functions, like creating a package on Windows OS? For example for the two functions below: soma = function(x, y){ res = x + y res } multiplica = function(x,y){ res = x*y res }…
rasked 8 years, 5 months ago Wagner Jorge 1,377 -
3
votes1
answer53
viewsCreate new DF based on text criteria of a certain column
I have a DF in the following model, Data Coluna 1 Coluna 2 Coluna 3 12/01/2016 82 88 abc 06/02/2016 30 76 abd 15/03/2016 9 74 abc_abc|1234 11/01/2016 43 48 abc_abc|1235 14/04/2016 21 100…
rasked 8 years, 6 months ago Felipe Amaral Rodrigues 309 -
3
votes1
answer634
viewsMultiple imputation with dashboard data in R
I have panel data in the following format: estado ano var1 var2 var3 It turns out that variable 2 (var2) has no data corresponding to one of the years. I tried to perform multiple imputation with…
-
3
votes1
answer549
viewsIntegration between R and Java
I’m working on a project and I have to integrate the language R with Java. You could help me by indicating a good library or a code (Hello World) make this integration?…
-
3
votes2
answers255
viewsError in r function Optim output
I am simulating values of the Birnbaum-Saunders distribution with alpha and beta parameters and later try to estimate these values using the Optim function, although the simulation converges, I am…
-
3
votes2
answers173
viewsCompare lines between two tables of data?
Considering: q1 <- data.frame(COD = 1:5, CLAS=letters[1:5]) q2 <- data.frame(COD = c(25,1,31,3,2), CLAS=c(45,letters[1],100,letters[3],letters[10])) I need to know which lines are common among…
-
3
votes1
answer237
views"Join" two graphs in R
I’m using the library igraph to create two graphs in R: g.v1 <- graph.full(6, directed= TRUE) E(g.v1)$weight <- 1 g.merchant <- graph.empty(1, directed=TRUE) E(g.merchant)$weight <- 1…
-
3
votes1
answer279
viewsPass data CSV file to array in R (BARPLOT)
I need to plot a graph in R by importing a csv file. After importing csv and calling the barplot he accuses that the variable I imported csv is not a vector. So how do I turn it into a vector to use…
rasked 8 years, 5 months ago Shinforinpola 430 -
3
votes2
answers228
viewsFiltering data from a vector
I have a data frame that lists a number of customer reviews for different products (each record is a review/note). I need to do some boxplots with the ratings of some specific products (the ids of…
rasked 8 years ago Carolina Bury 109 -
3
votes0
answers92
viewsError in `[. simple_triplet_matrix`(myTdm, c(Names(termFrequency2[i])), : Repeated indices Currently not allowed
I have the following code in R, it worked in version 3.0.2, but at the top it presents the error Error in [.simple_triplet_matrix(myTdm, c(Names(termFrequency2[i])), : Repeated indices Currently not…
rasked 8 years, 4 months ago Marjori Klinczak 51 -
3
votes1
answer99
viewsuse of Sys.Sleep
I can’t make a point-to-point graph, the R plot the graph then stays in the count of the Sys.sleep, someone help me? n=1 Cn=6.45 x<-3 t<- seq(1,20) for (i in 1:21) { flux = round(Cn*sin(n*pi*x…
-
3
votes1
answer36
viewsConvert labels to numeric labels
I have labels stored as letters and want to convert to numerics, for example: a <- c("A", "B", "A", "A", "C", "E", "D", "A", "B") Desired exit [1] 1 2 1 1 3 5 4 1 2…
rasked 8 years ago Wagner Jorge 1,377 -
3
votes1
answer3912
viewsConversion of data factor to Numeric
In the following example: > str(rhm) 'data.frame': 24 obs. of 4 variables: $ plant : Factor w/ 1 level "LaR": 1 1 1 1 1 1 1 1 1 1 ... $ time : int 0 0 0 0 3 3 3 3 7 7 ... $ Tratamento: Factor w/…
rasked 8 years, 4 months ago Juanita Hernández Solano 31 -
3
votes1
answer216
viewsHow to make maps in R with parallel processing?
I’ve been trying to make multiple maps at the same time R using plot and parallel processing using the package snowfall. I did the following function mapas: mapas <- function (tx, limite) { #…
-
3
votes1
answer600
viewsGet different values from a column - Data Frame - R Language
Good guys, I’m dealing with R in college for the first time in my life!! So in a data frame I have a column "to" that has +20,000 values ( equal and different ) What I wanted to know was the…
-
3
votes2
answers204
viewsSubset and maintain NA values
I’m sure there’s a way to subset and keep the NA values in the R. However, when I apply this function it is also disappearing from my base the NA values. I’m just using the formula below:…
-
3
votes1
answer116
viewsSave changes from a loaded app to shinyapps.io
I’m developing an app in Shiny that I’m going to upar at shinyapps.io. It consists of an already loaded table that the user can select some row, and then a report is generated based on the selected…
-
3
votes2
answers64
viewsR - match and replace string
I have this vector: n <- c("alberto queiroz souza (alberto, q-s.)", "alberto queiroz souza (alberto, queiroz souza)", "alberto queiroz souza (alberto, q. s.)", "alberto queiroz souza (alberto, q…
-
3
votes1
answer84
viewsSimilarity of elements in different vectors
I have two vectors: A <- c("RS", "DF", "CE") B <- c("Porto Alegre - RS", "Brasília - DF", "Fortaleza - CE", "Porto Alegre - RS", "Acre - AC", "Recife - PE") and a function: f <-…
-
3
votes1
answer108
viewsText Cleaning and Standardization
I have an Excel table already in R with two columns (code and company name) and 22 thousand rows. The names have been filled freely, so the same name is written in different forms, abbreviated and…
-
3
votes1
answer77
viewsR - match and add string
n <- c("alberto queiroz souza","bernardo josé silva","josé césar pereira","alberto, q-s.","alberto, queiroz souza","alberto, q. s.","alberto, q c", "bernardo, j. s.", "bernardo, j. silva", "josé,…
-
3
votes1
answer142
viewsA: Naming vector within a for
I’m making a for in my script, but in the last line when I run models$i, I needed that one i was the value of my i of for, would have been able to do? for(i in x){ maxit <- as.integer(1000000)…
rasked 7 years, 9 months ago Guilherme Hathy 31 -
3
votes1
answer511
viewsI need to create a column with the ln of a variable in the same data frame
I have a series of data for example GDP and I need to create a column next to it with the variable lnPIB, as I do in R?
-
3
votes1
answer82
viewsHow to ignore links that do not fit the established conditions and continue with scraping?
I would like to know how to ignore the links that do not fit the conditions set in title, data_hora and text; thus managing to continue scraping the site. Error that occurs when a link does not have…
-
3
votes3
answers955
viewsHow to place multiple formats on the dots of my PCA by ggplot2
I would like to put different shapes on the plot points of a PCA generated by ggplot2 for example (masculnos= square, female= triangle...).
-
3
votes1
answer53
viewsDots (...) with variable name
I need to run a function like f <- function(...) { l <- list(...) l[["hortela"]] } x <- 'hortela' If we do f(hortela = 1) we have the result 1, what is expected. What do I call it f() using…
rasked 7 years, 9 months ago Julio Trecenti 987 -
3
votes1
answer231
viewsFile download from filling a form
I’m trying to access a site, fill out your form and download the file, but I’m encountering some difficulties. That’s my code so far: #library's require(rvest) #website url <-…
-
3
votes2
answers696
viewsInconsistent numerical format
I am an experienced SAS programmer but a beginner in R. I am working with Rstudio Version 0.99.903 - 2009-2016 Rstudio, Inc. and Windows 8. I have the following question: The file "a_us" has 4…
-
3
votes1
answer108
viewsWhat’s new on R3.3.3?
R-core team launched on 03/06/2017 version 3.3.3 of R. Since then, some packages are releasing messages like this: package name_do_package was built under R version 3.3.3 What’s new in the R 3.3.3?…
rasked 7 years, 8 months ago Tomás Barcellos 5,562 -
3
votes1
answer216
viewsParameter estimation via mount Rlo and Optim function
I’m doing a study with the bivariate Birnbaum Saunders distribution. To solve my problem I need to create a code that estimates the parameters of a mixed model. Would you like to insert the gradient…
-
3
votes1
answer240
viewsLinear regressions in IHD with subdivided plot
Hello, good afternoon! would you like to know, how to perform a linear regression in dic with subdivided portion, detail I need the "Betas", because I intend to use the answer to predict a curve!…
-
3
votes1
answer51
viewsHow to return cells based on identifier in R
need to return the class of a specific id to a table. Often a single id encodes several classes: id<-c("A","B","C","D","C","B","A") clas<-c(1,2,2,2,3,3,4) tab<-data.frame(id,clas) What I…
rasked 7 years, 8 months ago Vivian Ribeiro 195 -
3
votes0
answers592
viewsProblem type Std::bad_alloc
I’m trying to read a database that’s in .xlsx. It has about 90,000 rows and 70 columns. I’m using the package openxlsx and I’ve made the mistake: Error in eval(substitute(expr), envir, enclos) :…
rasked 7 years, 7 months ago Flavio Silva 1,108 -
3
votes1
answer163
viewsUsing If/Else in R
This is my data frame: tsdata=structure(list(S.Educ = c(228.3000255, 237.2500067, 248.2500235, 235.8500022, 243.3000045, 254.9999758, 258.1000174, 261.1000144, 268.3000056, 277.1000373, 249.2000057,…
-
3
votes1
answer219
viewsProbabilities with pnorm R function
Statistics and Probability is not my area. A doubt has arisen, I think I’m doing it right but the result is strange. This is my series: y=structure(c(-0.276926746036887, 5.1002303288006,…
-
3
votes1
answer44
viewsAccrued Interest Quarterly using R
I am trying to make a rule in the R to accumulate the interest rates every three months, as in the time series below: juros <- structure(c(0.423918702462353, 0.235602849515353,…
-
3
votes2
answers968
viewsBat file to run file. r
I would like to use a . bat file to run a particular file. r daily with windows taskmanager, but I’m not getting it running. My steps are as follows: 1) open Notepad 2) enter code, which is…
-
3
votes1
answer322
viewsHow to mount a data.frame with identical elements from another two data frames.
Hello, I have two data.frames, each with 1 column. A data.frame has 3701 rows, while the other has more than 50,000 rows. What I want is this: assemble a data.frame that contains only the data.frame…
rasked 7 years, 7 months ago Lukais Iohan Carvalho 117 -
3
votes1
answer2281
viewsSelect a part of the database in R
I’m doing an evaluation of the database of the transparency portal that can be obtained in this link, The problem is that I would like to select only one part of the database, my assessment is only…
-
3
votes2
answers155
viewsGradient vector for use in the Optim function
I have searched a lot, in several forums and in many pages about parameters estimation via function optim of R and found nothing on how to add the gradient function in a script, so that the…
-
3
votes1
answer82
viewsGraph of Conditional Densities of a Linear Regression
I have this data frame with two columns: Y and X. data=structure(list(Y = c(NA, -1.793, -0.642, 1.189, -0.823, -1.715, 1.623, 0.964, 0.395, -3.736, -0.47, 2.366, 0.634, -0.701, -1.692, 0.155, 2.502,…