Asking Good Questions

Asking Good Questions
Author

Parvin Mohammadiarvejeh

Published

January 26, 2023

Prompt:

Asking good questions is a valuable skill to have - asking questions in an online setting is both easier and harder than asking questions in person: we can prepare to ask a question but we are also expected to prepare. The links posted here give some advice on how to ask good questions:

Follow these links and read through the advice given, then

  1. Pick at least one question from stackoverflow or the R help and answer it.

Write a blog post answering the following questions:

  1. Document which question you answered (link to your answer).

  2. Relate your experience of answering the question to your reading.

Instructions to follow.

Parvin’s work

1 & 2. I picked this question, link: (https://stackoverflow.com/questions/75225812/how-to-identify-rows-where-observations-are-identical-in-two-different-columns-i)

My stackoverflow account name: StarWiiin

In the following R chunk, I prepared my solution with code:

# Create a data including two columns: start_id, end_id

start_id = c("one", "two", "three", "four", "five", "six", "seven")
end_id = c("one", "three", "two", "four", "seven", "six", "five")


df = data.frame(start_id, end_id)
df
  start_id end_id
1      one    one
2      two  three
3    three    two
4     four   four
5     five  seven
6      six    six
7    seven   five
# create a new column which is True if start_id equals end_id, otherwise it is False.
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
df = df %>% 
  mutate(status= if_else(.$start_id == .$end_id, 'True', 'False'))
df
  start_id end_id status
1      one    one   True
2      two  three  False
3    three    two  False
4     four   four   True
5     five  seven  False
6      six    six   True
7    seven   five  False
  1. I tried to answer breifly but comprehensive. Since the question was related to R, I created a dataframe based on the writer explanations and I gave the solution exactly by solving the example. Also, I got the output myseld and I checked it to be sure it is true. So, my solution is easily reproducible and verified.