Posts by Antonio C. da Silva Júnior • 490 points
14 posts
-
3
votes2
answers52
viewsA: Create new columns of data in a data frame
You must first create the two variables: censo2$Minimo <- NA censo2$Maximo <- NA There are a few ways to apply the condition you want. A clear (maybe not the fastest) way is through a for…
ranswered Antonio C. da Silva Júnior 490 -
1
votes2
answers694
viewsA: Double bar graph
I noticed that you asked a new question wondering how to work with the chart caption. My suggestion is similar to that of the colleague, with some differences: The function used for reformatting the…
-
3
votes1
answer110
viewsQ: Corrplot - How to adjust to the center in Rstudio?
How do I display the center-adjusted corrplot? When executing the command in Rstudio, the graph is displayed very small and positioned to the lower right. corrplot(cor.matrix, method="circle")…
-
3
votes1
answer45
viewsA: Restrict a R code to a certain local machine
The command Sys.info() returns system information, including the name of the machine on the network (nodename). Sys.info() # sysname release # "Windows" "7 x64" # version nodename # "build 7601,…
ranswered Antonio C. da Silva Júnior 490 -
3
votes1
answer526
viewsA: Error: The Incompatible Types
Leandro, In addition to the inversion as the colleague above signaled, there is another problem in your code. When the PROCV does not locate the searched value, it returns an N/D and this is causing…
-
3
votes2
answers114
viewsA: What do you call the previous month in the R?
You can also use the mondate: library(mondate) mondate(Sys.Date())-1 # mondate: timeunits="months" # [1] 05/12/2018 And to format only year and month: format(mondate(Sys.Date())-1, "%Y-%m") # [1]…
-
1
votes1
answer1068
viewsA: Include column in a select
Ronaldo, it’s all right? The structure of your query is more or less this: <- sqlQuery(channel = conn, query = paste0("SELECT x.coluna1, x.coluna2, sum(x.col3) AS coluna3 ", "FROM (SELECT…
-
4
votes1
answer139
viewsA: Speed in crossing tables - R
Ronaldo, it’s all right? Check out this experiment by comparing the merge() function with the inner_join() function of the dplyr package. # Garantindo a reprodução dos resultados aleatórios…
-
1
votes1
answer109
viewsA: Copying files with the same name to a directory without overwriting (R!)
Jessica, it’s all right? It’s not that the file.copy() ends up overwriting the entries with the same name. On the contrary, it does NOT overwrite files with the same name, since you have set…
ranswered Antonio C. da Silva Júnior 490 -
3
votes2
answers95
viewsA: Generate a date after a specific date
Whoa, that’s all right? You can also do it without using the function seq(): # Criando um data frame de exemplo base <- data.frame( DATE_END = as.Date(c("2017-02-15", "2017-04-08", "2017-09-13",…
-
2
votes2
answers3207
viewsA: Replace specific column values with NA
Danilo, it’s all right? I suggest we do it this way: Creating a data frame to serve as an example: a <- c(1,2,3,4,5,6,7,8,9,10) b <- c(10,9,8,7,6,5,4,3,2,1) df <- data.frame(a,b) >…
-
1
votes3
answers11076
viewsA: Turning factor into numeric R
Ronaldo, it’s all right? Adjusting the stringsAsFactors parameter = FALSE prevents Character fields from being converted to factor. Example: df <- read.csv("dados.csv", stringsAsFactors = FALSE)…
-
1
votes2
answers75
viewsA: How to change the value of a variable?
Iago, all right? R does not require variable declaration, so you just need to directly assign the desired Character value. Test there: x <- 0 class(x) x <- "Hello world" class(x)…
ranswered Antonio C. da Silva Júnior 490 -
2
votes3
answers1583
viewsA: function in R that also returns the execution time itself
Adenilson, all right? I believe that the system.time function meets your need: funcao_exemplo <- function(x) { print(x) } system.time(funcao_exemplo("Hello World"))…