Posts by Thiago Fernandes • 1,704 points
53 posts
-
0
votes0
answers5
viewsQ: Denormalization of data with Pentaho
Suppose I have a table like this below in a CSV file, there is some command in PDI that I can turn the table into a dimensional model without I need to manually create columns with the relationship…
-
0
votes0
answers10
viewsQ: Neural Networks in Colab - Runtimeerror: CUDA error
I’m training a simple neural network for database classification Internet Firewall Data Data Set from the UCI Machine Learning site, but in the execution of the training occurs the following error…
-
0
votes1
answer33
viewsQ: How to remove cluster data in the ggplot?
I have the data set below, where I plot the values on a date axis, as there can be equal dates in the database, by default ggplot does the grouping of this data, but the correct visualization would…
-
0
votes0
answers38
viewsQ: What is the correct procedure for installing the PYGSLIB library?
Anaconda had been installed with version 3.8 of Python, but was unable to install the specific library, the following error occurred: UnsatisfiableError: The following specifications were found to…
-
3
votes1
answer29
viewsQ: How to remove duplicate figures generated by the geom_errorbar function?
How do I remove the other tags generated by the function geom_errorbar()? I only need the marking that is circled in the image. Database dataset = structure(list(structure(c(1L, 1L, 1L, 1L, 1L, 1L,…
-
4
votes2
answers83
viewsQ: Reference one color column based on another
I have a dataset with several columns, but a specific column is reference for the colors of the chart, as I can reference this column in scale_fill_manua ggplot automatically? Obs. The same color…
-
0
votes2
answers115
viewsA: Regression Graph in R or Python
Solution I used to solve. dataset$ï..QAQC_STATUS = as.factor(dataset$ï..QAQC_STATUS) library("ggplot2") p <- ggplot(dataset, aes(ASSAYVALUE_OR, ASSAYVALUE_CK, color=(ï..QAQC_STATUS))) +…
-
2
votes2
answers115
viewsQ: Regression Graph in R or Python
It is possible to play this Regression graph in R or Python? Obs. This graph was produced using the Acquire 4 QAQC object. Link And this is the model I’ve created so far. dados =…
-
0
votes1
answer917
viewsQ: Merge two queries in SQL Server
Hello, I have two queries of the same table, but I’m not able to join them parallel, I tried to use the UNION, but it didn’t work, is there any way to do it? Or else create a column with the…
-
3
votes1
answer656
viewsA: How to put percentage in bar graph?
dado <- data.frame("Estado" =c("ALESP", "ALRS", "ALMG"), "teste" =c(0.09, 0.29, 0.20)) library("scales") library("ggplot2") ggplot(dado, aes(x = Estado, y=teste, fill = Estado))+…
-
1
votes1
answer756
viewsA: format X-axis of bars in ggplot2
You need to sort the column as a factor, indicating the required order. c<- c ("Casal 1", "Casal 2", "Casal 3", "Casal 4", "Casal 5", "Casal 6", "Casal 7", "Casal 8", "Casal 9", "Casal 10",…
-
6
votes2
answers256
viewsQ: Concatenate columns and return the relation by SELECT
Suppose I have the following tables and their relations: Tabela A Col 1 Col 2 Col 3 Tabela B Col 1 Col 2 Col 3 Tabela C Col 1 Col 2 Col 3 Tabela D Col 1 Col 2 Col 3 Relacionamentos: A (col 1)…
-
1
votes2
answers70
viewsA: How to return a logical value when the lines have identical values in the R software?
To check if the same element repeats in all columns use the condition > 1, if you want to check if an element repeats at least once in the columns use the condition == 3. In both cases the…
-
1
votes2
answers45
viewsA: Selection/Cleaning of information in a column
Try it like this: data = read.delim(file.choose(), header = T) library("stringr") new_string = str_sub(data$XLOCAL, start = -16) str_sub(new_string, start = 1, end=15) #[1] "04°27'S;71°30'W"…
-
3
votes1
answer67
viewsA: Slow execution of a repeat problem for c
Your algorithm is making unnecessary comparisons, try it this way: #include<stdio.h> int main(){ int n, i; scanf("%d", &n); n/=2; for(i=1; i<=n; i++) printf(" %d ^ 2 = %d\n", 2*i,…
canswered Thiago Fernandes 1,704 -
2
votes1
answer50
viewsA: Problems with indexing in cbind
In this case the function parameter needs to be a Matrix, try so: reg<-lm(as.matrix(cbind(dataset[,c(1:6)]))~kmeans,data=dataset) or so reg<-lm(as.matrix(dataset[,vars])~kmeans,data=dataset)…
ranswered Thiago Fernandes 1,704 -
1
votes1
answer791
viewsA: How to count consecutive values in Excel?
For the formula not to get too extensive you can use another column to compare lines, two by two, as the image below:…
excelanswered Thiago Fernandes 1,704 -
4
votes2
answers200
viewsA: How to create a Stopwords using R
A way to do this, probably not the most efficient. dataset = read.table(text = 'nome rua funcao alberto assis programador elisa cons enfermeira pedro assis prog.', header = T) palavras_similares =…
-
2
votes1
answer371
viewsA: Compare first characters of two distinct columns in excel
Formula used: Result obtained:…
excelanswered Thiago Fernandes 1,704 -
3
votes1
answer699
viewsA: How to create a Plot with two or more histograms side by side:
There are two ways to do the same thing, considering only the native R Consider as an example the dataset iris, the two scrits below will produce the same result. the command c(1,2) of both means 1…
ranswered Thiago Fernandes 1,704 -
6
votes2
answers354
viewsA: Generate sequence in R
Use the rbind() to interlink the sequences. x = rep(1:221) y = (x + 221) Vetor = c(rbind(x, y)) head(Vetor) #[1] 1 222 2 223 3 224
ranswered Thiago Fernandes 1,704 -
6
votes1
answer50
viewsA: Problem using ggplot by group
Notice that your column date is as Factor, so the levels are totally out of order. str(df) #'data.frame': 120 obs. of 4 variables: # $ ind : Factor w/ 246 levels "01/04/2015","01/06/2015",..: 177…
-
7
votes1
answer377
viewsA: Size of panels with facet_wrap
In that case the problem would be the blank panels library(ggplot2) library(grid) grafico_1 = ggplot(mpg, aes(x=displ, y=hwy)) + geom_point() + geom_smooth(method="lm", se=FALSE, colour="black") +…
-
3
votes4
answers7118
viewsA: Changing the name of a variable in a dataframe R
Another way, but without using packages. x = names(dataset) x[(names(dataset) == "Country")] = "Pais" colnames(dataset) = x
ranswered Thiago Fernandes 1,704 -
2
votes1
answer248
viewsA: Insert rownames/ values as a new variable in a list dataframes
You can fix that with a loop. dados = list(structure(list(modelo = structure(1:5, .Label = c("a", "b", "c", "d", "e"), class = "factor"), valor = c(5000, 10000, 15000, 20000, 25000)), .Names =…
-
1
votes1
answer121
viewsA: Manipulation of Dataframe in R
Take as a hypothetical example this data set Mes = c(1,2,2,4,3) Nome = c("ACIR G","ACIR G","ACIR G","ACIR G","ACIR G") Tipo = c("Aluguel", "Aluguel","Aluguel", "Passagem", "Passagem") Valor = c(5,…
ranswered Thiago Fernandes 1,704 -
3
votes2
answers2585
viewsA: How to calculate the percentage of NA in a data frame in R?
To count NA by columns you can use the function colSums(): # total de linhas n = nrow(df) # porcentagem de NA por coluna round(colSums(is.na(df))*100/n, 2) Or you can also use the function apply():…
ranswered Thiago Fernandes 1,704 -
1
votes2
answers119
viewsA: Convert all Environment files to '.Rda' and then load them at once with a loop
Converts data.frames into list df1 = data.frame(x=c(1:5)) df2 = data.frame(x=c(1:5), y=c(6:10)) df3 = data.frame(x=c(1:8), y=c(9:16), z=c(17:24)) lista_df = list(df1, df2, df3) Saves the list in the…
ranswered Thiago Fernandes 1,704 -
3
votes2
answers163
viewsA: Interpolation of decimal numbers in R
In R, you can use the function trunc > trunc(191.1) #[1] 191 > trunc(191.48) #[1] 191 > trunc(191.8755) #[1] 191 In Excel the function Truncate = TRUNCAR(191,8755;0) Dataset > dados…
ranswered Thiago Fernandes 1,704 -
4
votes3
answers559
viewsA: Compare columns of a dataframe with those of others and remove columns that are not common between them
The basic idea is this, all you have to do is to automate the process and cover more dataframes. df1 = data.frame(x1=runif(5,0,5), x2=runif(5,5,10), x3=runif(5,0,5), x4=runif(5,10,15)) df2 =…
ranswered Thiago Fernandes 1,704 -
0
votes2
answers174
viewsA: Print reverse order
Try it like this: x = float(input()) if (x >= 1000 and x < 10000): y = str(x) print(y[::-1])
pythonanswered Thiago Fernandes 1,704 -
3
votes2
answers160
viewsA: Renaming all Environment objects with a specific name
An option would be like this. ola = data.frame(x=1) tudo_bem_com = data.frame(y=2) voce = data.frame(z=3) lista_df = list(ola, tudo_bem_com, voce) for (i in 1:length(lista_df)){…
-
4
votes2
answers49
viewsA: Pulling elements from one list to another under a R criterion
You can use the function match it will return the position of the elements of best_pairs in the vector regression_pairs regression_pairs=c("A~B", "C~D", "E~F", "G~H","I~J","K~L","M~N","O~P","Q~R")…
ranswered Thiago Fernandes 1,704 -
1
votes2
answers651
viewsA: How to perform the tapply function for multiple dataframes in R?
One option would be to use repeat loops, this method is not advisable if the BD is too long. dataset1<-data.frame(group=rep(c('a','b','c','d'),3,each=3),number1=c(1:36),number2=c(1:36))…
-
2
votes2
answers1914
viewsA: Argument is neither numerical nor logical: returning NA
Hello, note that your variable $Colocm: is as Factor w/ 159 levels, that is you need to convert it to numerical format, so R will be able to understand that they are numerical values and will make…
-
5
votes2
answers52
viewsA: How does a forloop generate random values, then "appenda" the next set of generated values?
You can use it that way k = 8 m = 100 create_empty_table <- function(num_rows, num_cols) { frame <- data.frame(matrix(NA, nrow = num_rows, ncol = num_cols)) return(frame) } amostra =…
-
4
votes1
answer97
viewsA: Determine circle size in GGPLOT2 chart caption
You can use scale_size() to define the sizes. qplot(x = percwhite, y = percbelowpoverty, data = midwest, size = popdensity) + scale_size(range = c(1,4), breaks = c(10000, 20000, 30000, 40000, 50000,…
-
5
votes1
answer236
viewsA: r - average of one variable relative to the values of another variable in a data frame within each grouping
The average of each species registered in each local within each stage: dplyr::group_by(data, especie, local, etapa) %>% summarise(Total=mean(frequencia)) # A tibble: 13 x 4 # Groups: especie,…
-
1
votes1
answer466
viewsA: R histogram with all apparent breaks, hist() function
With the bar graph it is possible to use the log10 on the y-axis, with the histogram unknown. library(ggplot2) library(gridExtra) grafico_1 = ggplot(h1, aes(x=breaks, y=counts))+…
-
2
votes2
answers68
viewsA: Replacing text with words from another file
Another solution would be to use the package stringr options(stringsAsFactors = FALSE) Arquivo1 <- read.table(text = " Doc 'Texto' doc1 'Isto é um teste para substituições de palavras.' doc2 'As…
-
0
votes2
answers490
viewsA: Error in a - b : non-numeric argument to Binary Operator
I believe that’s what you wanted, correct? lines = 'mês ano receita despesa 1 2018 778.7376 1579.185 2 2018 611.4827 1362.005 3 2018 544.0717 1532.969 4 2018 498.8309 1324.723 5 2018 428.6952…
ggplot2answered Thiago Fernandes 1,704 -
1
votes2
answers82
viewsA: Separate subsets of a base in R
The last column of the dataframe is the steps. dados = structure(list(X__1 = c("1.2. DADOS DOS ÓRGÃOS/ENTIDADES (ETAPA 1)", "CNPJ", "03.066.219/0001-81", "03.066.219/0001-81", "04.809.688/0001-06",…
ranswered Thiago Fernandes 1,704 -
1
votes2
answers206
viewsA: r - average of one variable relative to the values of another variable in a data frame and take NA values
I don’t know if that’s exactly what you want. The average of each species in each location. library(dplyr) group_by(dados, especie, local)%>%summarise(Total=mean(frequencia))…
-
5
votes2
answers914
viewsA: Rstudio. Colors in a set of Boxplots
Create a vector with 25 colors. cores=c('blue', 'red', 'pink', 'orange', 'gray', '#fb5772', '#d953bd', '#c26a31', '#919c75', '#d312b4', '#4549e5', '#6f95ef', '#f15050', '#54c2de', '#8f2e78',…
-
1
votes1
answer67
viewsA: How do I adjust the lengenda to Spatial Lines in ggplot?
Solution: legenda1 = c("BR-040","BR-116","BR-262","BR-381") cores = c('#d01c8b', 'yellow', '#e66101', 'blue') library("ggplot2") library('ggsn') library("ggrepel") ggplot(mapa_mg) + aes(x=long,…
-
3
votes1
answer67
viewsQ: How do I adjust the lengenda to Spatial Lines in ggplot?
I’m filling lines on polygons, but when I try to insert the caption the lines get bad, how do I adjust it? Without the Legend library("ggplot2") ggplot(mapa_mg) + aes(x=long, y=lat, group=group) +…
-
2
votes1
answer3263
viewsQ: How to insert point and line caption in ggplot?
How do I insert the dots in the caption? The purple dot on the caption "base1" and the red dot on the caption "base2"? lines = 'Mes Lg1 total1 Lg2 total2 Jan base1 1450 base2 89 Fev base1 1700 base2…
-
2
votes1
answer609
viewsQ: How to insert caption into ggplot maps?
How do I insert the legend and scale the map to degrees? library("rgeos") library("maptools") library("ggplot2") library("mapproj") cores1 = c('brown2', 'aquamarine2', 'darkgray','darkolivegreen1',…
-
4
votes2
answers1017
viewsQ: How to insert a chart caption with two axes y in r?
As I insert the caption in this chart, like the bar would be the gross total and the line the net total? lines = 'Mes Acid Obt Jan 1450 102 Fev 1447 86 Mar 1461 87 Abr 1356 61 Mai 1398 80 Jun 1115…
-
2
votes1
answer159
viewsQ: How to delimit plotting area in python?
The figure is cutting the captions, how do I fix it? # Libraries import matplotlib.pyplot as plt # Make data group_names=['0,89% - Tração Animal e Propulsão Humana', '45,08% - Passageiro e Misto',…