Questions tagged [data-wrangling]
The data-wrangling tag has no usage guidance.
data-wrangling
1,316
questions
1
vote
1
answer
44
views
Creating a large number of columns in R tidyverse based on a comparison with a specific column
I have a dataset in R tidyverse and I want to create 192 columns based on comparison with the sp column, just like the mp_comp_1 column. How can I do this for 192 columns in tidyverse?
library(...
1
vote
2
answers
53
views
Pattern matching in a dataframe
I am having some trouble conducting pattern matching within a data frame. I am working with grepl function in R.
I have a data frame of 5 local districts in two years (2001 and 2002). I want to check ...
2
votes
3
answers
73
views
Complete and fill missing rows with groups of uneven length
I have a dataframe of county executives and the year they were inaugurated. I am running a panel study with county-year as the unit of analysis. The date range is 2000 to 2004.
I will like to expand ...
-1
votes
3
answers
49
views
Remove duplicate rows, keep first row [duplicate]
I am working with a dataframe on county executives. I want to run a panel study where the unit of analysis is the county-year.
The problem is that sometimes two or more county executives serve during ...
-1
votes
1
answer
34
views
Fill in missing rows
I have a data frame of county executives and the year they were inaugurated.
I am runnig a panel study with county-year as the unit of analyis. The date range is 2000 to 2004.
I will like to expand ...
1
vote
2
answers
37
views
dataframe breakdown by year
I have a dataset on county executives and their year of inaguration. I need break down which year each executive was inaugurated.
The problem is that the notation under the "year" variable ...
1
vote
3
answers
125
views
Add values across dataframe columns
I have a dataframe where missingness in indicated by "Z" (there may also be some "z" and NA entries present in the data), and values are entered as characters ("0", "...
1
vote
3
answers
40
views
Drop columns that are replicated in a data frame
I have a large data frame with repeated variables. This is just a sample of my data to illustrate the question:
df <- data.frame(
ID = rep(1:4, each = 1),
CMW = rep(c(10, 20, 30, 30), each = 1),...
-1
votes
1
answer
42
views
I need some help creating a loop/automatic way of cleaning my data [duplicate]
I'm quite new to programmin language and I am starting with R in my research predicting dengue desease cases with climatic data.
I'm still cleaning my data to work with and this particular one has ...
0
votes
1
answer
42
views
Add Column to R Data Frame from Another Data Frame with Matching Index Column, Only When Values are in A Certain Range
I am trying to add a column to a data frame (df1) from another data frame (df2), but only when the "depth range" from df1 lies within the "depth range" from df2. I'll explain below ...
0
votes
1
answer
48
views
SQL data wrangling help using the Having statement
The below code (Databricks SQL) produces the table following it. I am trying to adjust this code so that the output only includes zip5 records that have only 1 (or less) of each facility_type ...
1
vote
1
answer
39
views
Join tables based on a range instead of exact match [duplicate]
I have two datasets as the ones described below:
dfA <- tibble(
name = c("John", "Michael", "Brian", "Thomas", "Peter"),
expected = c(128.34, ...
0
votes
0
answers
7
views
How to transform nested data from long format to wide format without using nested structure?
I have a big dataset and have data in long format ('longdf') with one column for subjectnr., one for illness (e.g., rows are epilepsy, ms, diabetes etc.) and other columns for the variables (...
0
votes
0
answers
36
views
How can I load data in Rstudio but making it accessible in other computers when opening the file?
I'm working on an assignment and we were asked to load the data and make the file run without errors when opening from the teacher's computer. He said: "When writing your code, keep the data ...
0
votes
2
answers
37
views
R: Alternatives/approaches to read_html() + html_text() that also work on strings without HTML/XML tags
In this solution to removing HTML tags from a string, the string is passed to rvest::read_html() to create an html_document object and then the object is passed to rvest::html_text() to return "...