Error in population %>% -cannot find function %>% [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
population <- read.csv("자치구단위 서울생활인구 일별 집계표.csv")
View(population)
str(population)
summary(population)
## install.packages('dplyr')
library('dplyr')
population %>%
filter(between(기준일ID,
20200101,20210524)
& 시군구명 == '서울시') %>%
I don't know why it doesn't run, and sometimes it runs, apparently randomly.
In this case, after run, I want to plus my variable '기준일ID'. but when I add this, it doesn't run again. Nothing change else before.. why
select(시군구명,단기체류외국인인구수) %>%
write.csv("C:/Users/haejo/OneDrive/바탕 화면/2021 1학기/빅데이터의과학적탐구 강의자료/a1541.csv"
,row.names=F,na=)
View(population1)

We need to assign
population1 <- population %>%
filter(between(기준일ID,
20200101,20210524) & 시군구명 == '서울시') %>%
select(시군구명,단기체류외국인인구수)

Related

How to find the percentage of observations in each day in R? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 17 days ago.
Improve this question
I have a dataset with time, where the time intervals are 6 hours apart and I have a column of heaterstatus.
The dataset :
I would like to know the percentage of zero occurred in each day for heaterstatus. New to R, any suggestion will be helpful.
Not tested since you only provided data as an image, but this should do what you want:
library(dplyr)
dat %>%
group_by(day = as.Date(Time)) %>%
summarize(pct_0 = mean(HeaterStatus == 0))

How to change row values with calculation in R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I need some help with my data frame (df) in R. I need to transform existing row values with some calculation and I don't know how to apply it to every row I need. I have gross domestic product and I need to change it obsValues with calculation that includes CPI row values : (GDP/CPI)*100. The most difficult thing here is that GDP and CPI are in rows not in columns...
My dataframe looks like this:
enter image description here
enter image description here
Thanks in advance!
We may do
library(dplyr)
library(stringr)
df1 <- df1 %>%
group_by(obsTime) %>%
mutate(obsValue = replace(obsValue,
SUBJECT_DEF == "Gross domestic product",
obsValue[SUBJECT_DEF == "Gross domestic product"]/
obsValue[str_detect(SUBJECT_DEF, "CPI:")] * 100)) %>%
ungroup

How to create new column that compares 2 other columns [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have dataset in R for samples (ID) for 2 years for one variable (Majorclade). I want to see how major clade have changed over the 2 years for each sample. I would like to create a column that compares it, like it is the same calls it 0, if different calls it 1. I imagine some kinda of mutate would do it, but I am not figuring it out. Ideas?
Table example:
We can use
library(dplyr)
df1 %>%
group_by(ID) %>%
mutate(new = +(n_distinct(Majorclade) > 1)) %>%
ungroup

How to extract adjectives and adverbs from vector of text in R [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to extract adjectives and adverbs from a vector, is there any way to do this ?
input <- "It's a good phone"
Expected output : "good"
You can use tidytext :
library(tidytext)
library(tidyverse)
unnest_tokens(tibble(txt="It's a good phone"),word, txt) %>%
left_join(parts_of_speech) %>%
filter(pos %in% c("Adjective","Adverb")) %>%
pull(word) %>%
unique
# [1] "good"

How to create a sum if multiple criteria [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have to create a "sum if" by column with multiple criteria.
I've tried this:
b <- DB.all %>% group_by(Family) %>% summarise(x)
But it doesn't work.
How can I do it?
Try this:
library(dplyr)
b <- DB.all %>% group_by(Family) %>% summarise(sum(x))

Resources