Posts by T. Veiga • 595 points
24 posts
-
0
votes1
answer476
viewsQ: Take a sample without repetition taking into account 2 variables in the R
I have two bases. One with the lines I would like to take the sample and the other with the sample size with the dates. The first one that is the database of fact that I need to make the sample, is…
-
1
votes0
answers37
viewsQ: For is taking the rest of the sample variables in R
I’m making a sample and the size of it is in a spreadsheet called "sizing". When I use the command is, as below, the sample is made, however, appears only the first column for each sample, I would…
-
1
votes1
answer35
viewsQ: Take previous values of a variable if the current value is 0 with a condition using dplyr in R
I have a database as follows: CNPJ data dataquebra alto 2222 201603 201711 s 2222 201511 0 s 2222 201702 201711 s 2222 201704 201711 s 3333 201601 201711 s 3333 201509 0 s 3333 201512 0 s 3333…
-
1
votes2
answers133
viewsQ: Indicator on R with more than one condition 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…
-
2
votes3
answers152
viewsQ: Aggregate string in R
I have the following basis: cidade a b c AGRONOMICA CRESO NA NA AGRONOMICA NA SICOOB NA ALFREDO CREDIVERTENTES NA NA ALMIRANTE SICOPER NA NA ALMIRANTE NA SICRED NA ALTO SICOPER NA NA ALTO NA SICOOB…
-
1
votes1
answer840
viewsA: Transform the database into R - A kind of dynamic table
I was able to do this in two stages. First used the dplyr to create "Siglan" and "Centraln": ##Criando o contador relcoop <- relcoop[order(relcoop$chave),] relcoopw<-relcoop %>%…
-
0
votes1
answer840
viewsQ: Transform the database into R - A kind of dynamic table
I have a database as follows: CNPJ SIGLA chave CENTRAL 3333 CREDSUL CACHOEIRODIM-ES CECOOPES 4444 COOPSEFES VITORIA-ES CECOOPES 55555 CREDI VITORIA-ES CECOOPES 66666 CREDEXTRA SERRA-ES CECOOPES…
-
3
votes2
answers80
viewsQ: Indicator 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
answers94
viewsQ: Transform duplicate values to 0 by keeping an element in the conditional R
Suppose there is a database in which: x y z a 2015 122.4 a 2015 122.4 b 2016 200.5 a 2014 300.6 c 2016 80.1 What I was wondering is with making a programming in R that transforms the repeated values…
-
0
votes1
answer115
viewsQ: Make a subset with the same condition on different bases in R
I’m willing to apply the same condition subset on different bases in the R. I thought the for was going to solve, but I did not succeed. Follows programming used: for(i in c("mar16", "jun16",…
-
1
votes1
answer389
viewsA: Changing the row name of a list in R using lapply from a list variable
I solved this problem using a for command as follows: for (i in 1:340){ rownames(dadosLista[[i]])<-dadosLista[[i]][,c(3)] } Where column 3 represents the desired values for row names.…
-
2
votes1
answer389
viewsQ: Changing the row name of a list in R using lapply from a list variable
I have a list called dataList and I would like the name of the lines to be equal to a variable called CNPJ that is within that list. For that, I first applied: dadosLista<-lapply(dadosLista,…
-
6
votes1
answer347
viewsQ: Split base with "for" in R
As it is my first for in the R I found it difficult to apply this function. I have a base with a base date of different years and would like to divide the base by base dates. The variable "date" has…
-
0
votes2
answers1675
viewsA: Percentage Frequency in R with dplyr
Just to give feedback, from Rafael’s programming, the programming that calculated the relative frequency was: dados<-dados %>% group_by(CENTRAL) %>%…
-
1
votes2
answers1675
viewsQ: Percentage Frequency in R with dplyr
I wanted to use the dplyr package to calculate the Relative Frequency by group. I have a database like the first three columns below and I would like the last column to be the answer variable: CNPJ…
-
4
votes1
answer1248
viewsQ: Using Mysql with R in the Rmysql package
I am new when the subject is Mysql and installed this program to use with R. I managed to install the Rmysql library, following tutorials I found on the Internet and in the course I am doing in…
-
2
votes2
answers91
viewsQ: Adding the same substring to multiple columns in R
I have a base with 2 lines and 68 remarks called "varnomes" and would like to add the word "PF" at the end of each remark. With that, I tried to use the function Paste:…
-
5
votes1
answer125
viewsQ: Take the previous value with a condition on R
I have a single key base made of two other repeating variables, CNPJ and date. I need to do some sum and division accounts with the previous date values for each CNPJ. If there is no previous date…
-
0
votes0
answers152
viewsQ: Aggregate in R using date as key
Good afternoon, I’m using the code: soma<-aggregate(as.numeric(coop[c(10,18,26,34,42,50,58,66)]), by=list(coop$data), FUN=sum, na.rm=TRUE) to aggregate the data based on the date key, which is in…
-
0
votes2
answers1947
viewsA: Join multiple files from a folder in R
I did it that way: larquivos<-list.files("C:/Users/tomas.veiga/Documents/Financeiro/dados",full.names=TRUE) arquivos <- sapply(larquivos, read_excel,simplify = F) dados <-…
-
3
votes2
answers204
viewsA: Subset and maintain NA values
The way I found out was to put the is.na in the programming, that is to say: dados1<-data.frame(subset(dados,V2!="CNPJ"|is.na(V2)))
-
3
votes2
answers204
viewsQ: Subset 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:…
-
4
votes2
answers1947
viewsQ: Join multiple files from a folder in R
I’m trying to piece together several xlsx files in R. For this, first I open the following libraries and use the programming: library(readxl) library(plyr)…
-
2
votes1
answer171
viewsQ: Subset 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…