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 have survey data that has information in columns like
Q1_1 Q2_2 Q3_3
How do I merge their responses to just Q1 using the surveydata or tidy package?
We can use pivot_longer
library(dplyr)
library(tidyr) # 1.0.0
df1 %>%
pivot_longer(cols = matches("^Q\\d+_\\d+"), values_to = 'Q1') %>%
select(-name)
Related
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))
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(시군구명,단기체류외국인인구수)
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 years ago.
Improve this question
I want to split a list of tibble into ther respective tibbles. How do I do that? I have 245 tibbles in the list so I can't do that by each one.
Create an example dataset:
library(tibble)
myList <- list("iris_tbl" = as_tibble(iris),
"cars_tbl" = as_tibble(cars))
Answer:
mapply(assign, names(myList), myList, MoreArgs=list(envir = globalenv()))
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"
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))