Questions tagged as 'r'

1
answer

filter in dplyr using a categorical variable

Suppose I have the following dataset: set.seed(12) dados <- data.frame(grupos=rep(letters[1:5], 5), valores=rnorm(25)) head(dados) grupos valores 1 a -1.8323176 2 b -0.0560389 3 c 0.6692396 4 d 0.8067977 5 e...
asked by 08.06.2017 / 18:15
2
answers

How to create a popup warning that the script is over?

I would like to display a pop-up warning that the code just ran. The only script I have, below, is what opens a command window. system('CMD /C "ECHO O seu script chegou ao fim! && PAUSE"', invisible=FALSE, wait=FALSE)   ...
asked by 02.09.2014 / 16:28
1
answer

Is there a way to open a straight SQL table in a data.table without doing the SQL data.frame data.table path?

I want to open a straight SQL table in a data.table. When I query with dbGetQuery , what I get is a data.frame. I know I can later turn that data.frame into a data.table easily. But I'd like to skip this step - which on some occasions may...
asked by 19.09.2014 / 13:27
2
answers

Connecting the points to the regression line

Suppose the following database: Income <- structure(list(X = 1:30, Education = c(10, 10.4013377926421, 10.8428093645485, 11.2441471571906, 11.6454849498328, 12.0869565217391, 12.4882943143813, 12.8896321070234, 13.2909698996656, 13.732441...
asked by 02.04.2014 / 14:51
1
answer

Size of the panels with facet_wrap

I'm doing some panel graphics in ggplot2 . See the example below: library(ggplot2) ggplot(mpg, aes(x=displ, y=hwy)) + geom_point() + geom_smooth(method="lm", se=FALSE, colour="black") + facet_wrap(~ trans) Ihavemygraphicalwindo...
asked by 13.09.2018 / 18:15
1
answer

How to generate correlated variables in R?

I was able to create the uniform variables X and W , both with normal distribution, through the formula rnorm and R . However, I wanted to create the variables so that they had a -0.8 correlation value. What command...
asked by 23.03.2014 / 02:24
1
answer

vectorize moving average of an array in R

I am doing the following operation with an array in the R: > m <- matrix(1:9, ncol = 3, nrow = 3) > m [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > m2 <- m > for(i in 1:nrow(m)){ + for(j...
asked by 20.07.2015 / 23:28
1
answer

How to know the arguments contained in '...' in a function in R?

In R you can use '...' for the function to receive an indeterminate number of arguments. How do I know which arguments were used in the function? Example, if I wanted to print the arguments used. imprimeArgumentos <- function(...) {...
asked by 14.01.2016 / 14:02
1
answer

RStudio: does not automatically load variables in environment

Whenever I start RStudio some variables appear in environment . Is there any way to remove them automatically without using the famous rm(list=ls()) ? Thank you!     
asked by 07.12.2015 / 03:33
1
answer

Are there any R functions similar to Excel's PROCV?

In my case I have two data.frames: > head(Trecho) Xt Yt Zt 1 -75.56468 1.642710 0 2 -74.56469 1.639634 0 3 -73.56469 1.636557 0 4 -72.56470 1.633480 0 5 -71.56470 1.630403 0 6 -70.56471 1.627326 0 > head(TrechoS...
asked by 18.05.2017 / 14:46