Questions tagged as 'r'

1
answer

Error "invalid input '..' in utf8towcs" with "read.csv"

I have a .csv database that gathers posts from both Facebook and twitter. For reading the bank in R, the code I have used is bancodedados <- read.csv("nomedobanco.csv", sep=";", encoding="UTF-8") The code loads the database almost to t...
asked by 28.01.2015 / 14:12
3
answers

Remove Environment (and List) elements based on your classes

Consider the vectors: a<-1:10 b<-1:10 c<-'a' d<-'a' e<-list('b') f<-list('b') g<-1.1 h<-1.1 The function below removes only a class (which is integer , in this case): rm(list=names(Filter(is.integer,mget(ls...
asked by 01.01.2019 / 05:09
3
answers

How to put the regression line on a graph?

Suppose a linear regression model such as the following: set.seed(1) x <- rnorm(100) y <- rnorm(100) + 2*x +10 modelo <- lm(y~x) If I plot y against x, how do I include the regression line in the chart? plot(y~x)     
asked by 18.02.2014 / 14:50
3
answers

How to sort a data.frame by columns in R?

Suppose a data.frame with numeric values and strings: set.seed(1) dados <- data.frame(w=rep(c("A", "B"), 2), x= rep(c("D", "C"), 2), y= rnorm(4), z=rnorm(4), stringsAsFactors=FALSE) dados w x y z 1 A...
asked by 17.02.2014 / 18:51
4
answers

How to join observations of tables that have a different set of variables in R?

In the case below id corresponds to observations contained in two different data frames, where in df1 the observations have the variable x and in df2 the observations have x and z In these cases how to join the two data frames? rbind...
asked by 14.01.2016 / 18:34
2
answers

Why are loops slow in R? How to avoid them?

It is very common to hear (or read) that loops are not efficient in R and should be avoided ( in this link or on another link or same in this ). And proving this statement is simple: numeros <- rnorm(10000) com_loop <- fun...
asked by 26.10.2017 / 14:51
2
answers

How to create a for in R with the indexes of a data frame

If I have a data.frame: > dato<-as.data.frame(matrix(1:64,8,8,T))[-3,] > dato V1 V2 V3 V4 V5 V6 V7 V8 1 1 2 3 4 5 6 7 8 2 9 10 11 12 13 14 15 16 4 25 26 27 28 29 30 31 32 5 33 34 35 36 37 38 39 40 6 41 42 43 44 45 46 47 48...
asked by 01.05.2018 / 16:15
2
answers

How to create a Stopwords using R

Hi, I need to do a task and I'm not getting into logical reasoning. My scenario is: I have a DF with several columns, I need to "read column 3", identify the words and sort. Example: DF nome rua funcao alberto assis progr...
asked by 28.09.2018 / 19:07
2
answers

How to make concentric circles in the plot of r

I need to make concentric circles, preferably displaced from the source, in the plot() function to serve as a visual reference for a function. I tried abline() , but I did not succeed.     
asked by 15.05.2018 / 15:55
4
answers

Generate and download links programmatically

There is a database of the National Water Agency that can be accessed by Hidroweb . To download, just go to:    Hydrological data > Historical series and include the code of the desired rain gauge. When chosen the code and type...
asked by 25.04.2015 / 22:57