dplyr

Rename the levels of a factor based on a data frame

Suppose I have the data frame iris, present in the memory of R: head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Wi ... h has thousands of different species occurrences. It would be impossible to type in all the options that I have to work with.

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)) h ... ter 1,116 different values. It is impractical to filter each of these values individually and combine them after at the end.

Reorder the columns of a bar chart and its legend

When processing and plotting data in R using tidyverse, it by default leaves the order of the chart bars in the original orde ... ed x-axis legend. I ended up not fixing this in my example, but the final version of the chart will have this problem solved.

Problem organizing a dataframe with tidyr in R

I have this dataframe and I need to organize it so that the unique dates are the first column and the columns are the bovespa ... chronological order. how do I fix that? I tried to fix by turning the date vector into a date vector " but it didn't work.

How to replace the lost values in data frame with the average of each column in R?

I have this table: tabela<-data.frame(v1 = c(1,NA,3,5,4), v2 =c(NA,NA,1,2,4), v3 = c(6,5,4,7,NA)) I need the lost values of each column to receive the average values of that column. How to do this using the dplyr or a repeat loop?

How to partially disregard NA in operations on the R with a historical series of data?

I have a set of rainfall data measured every hour and need to sum that data throughout the day. For this, I am using the comm ... y on the days that do not present any measurement and perform the sum on those that have both NA and measurement? Thank you!

A - how to create a delayed variable (lag) conditioned to the individual?

I need to delay a variable from my db (dCoopCred). However, it cannot mix the delay of two individuals (CNPJ). I would like L ... c("ano", "CNPJ")) Did what I wanted, but this generating another db, I would like the variable to be created in dCoopCred

How to calculate percentage change with 3 variables in R

I have the following data: library(sidrar) Tab1612SojaQde <-get_sidra(1612,variable = 214, period = c("last"=22), g ... one year to the other, per unit of the federation, because here appears only the " Federal District, but there are 11 states.

Error loading dplyr package in R studio

I am having problem loading the dplyr package, when I enter library (dplyr) Parace this message: Attaching package: ‘dplyr ' ... ackage ' dplyr’ was built under R version 3.4.4 How do I solve this problem so that I can join the two databases together.

How to use summarise?

I have a DF with energy data and I would like to group the data by activity (because they are divided by state and I want to ... "\"Consumo (MWm)\"", "Consumo (MWm)"), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

How to summarize data in R?

I have a sample of purchase data and would like to know how many purchases they had per user in total. Dput to assist the an ... "data.frame") I'm trying to use summarise from the dplyr package but I'm having trouble how I can use it. What should I do?

Perform mutate on columns simultaneously

Hello, I have a dataframe where I want to apply the same function on several columns at the same time. I tried using dplyr: ... col3 = percentualize(col3)) How could I operate on these three columns at the same time without having to keep repeating?

Creating a dataframe based on two other dataframes using dplyr in R

These are my dataframes: df<- as.data.frame(matrix(rexp(200),, 25)) colnames(df)<-c("A","B","C","D","E","F","G","H ... what comes before and after the point and not 1 by 1. Sometimes comes 5 letters before the DoT, other times comes 6 letters.