functional programming: user-defined function to parse multiple csvs, create variables, and count NA in R

I have about 100 data sets with different variables (and different numbers of variables) but each data set has a household ID (hh_ID) as identifier. Variables represent survey questions. Each csv represents a different type of survey. I want to write a custom function that counts the number of times a household was asked a question and the number of times a question was skipped (NA). The problem I have is changing the name of the variables and counting through csvs.

Let's say two dataframes look like this:

hh_ID <- c(1,1,2,2,2)
question1 <- c(NA,1,0,0,0)
question2 <- c(1,1,NA,0,0)
df1 <- data.frame(hh_ID, question1, question2)

hh_ID <- c(1,1,1,2,2)
question3 <- c(NA,NA,0,0,0)
question4 <- c(1,1,1,NA,NA)
df2 <- data.frame(hh_ID, question3, question4)

I need the final dataframe to make it look like this:

question1_count <- c(2,3)
question1_NAs   <- c(1,0)
question2_count <- c(2,3)
question2_NAs   <- c(0,1)
question3_count <- c(3,2)
question3_NAs   <- c(2,0)
question4_count <- c(3,2)
question4_NAs <- c(0,2)
finaldf <- data.frame(hh_ID,question1_count, question1_NAs,question2_count,question2_NAs,question3_count,question3_NAs, question4_count,question4_NAs) 

This is what I have so far:

# read in each dta file
filenames <- list.files(path=mydirectory, pattern=".*dta")
for (i in 1:length(filenames)){
assign(filenames(i), read_dta(paste("", filenames(i), sep=''))

variable_NA_count <- function(dataset, col_name){
temp <- dataset %>% group_by(hh_ID) %>% summarise(question_count = n()) 
temp1 <- aggregate(col_name ~ hh_ID, data=dataset, function(x) {sum(}, na.action = NULL)
final <- merge(temp, temp1, by = "hh_ID")

frequency <- function(dataset, col_name){
temp <- variable_NA_count(dataset, col_name)
temp <- temp %>% select(question1_count = question_count,
                        question1_NAs = col_name)}

The problem is that I want each variable name to end in "_count" and "_NAs" without explicitly typing "question1_count = question_count". I have hundreds of variables in csvs, so I need a function that reads every csv, reads each column name, count the number of times a household was asked a question and the number of times they did not respond. I have tried various ways such as paste function but still hitting a wall.

Thank you!

javascript – How do I create a real-time number generator?

I want to create a real time random number generator for my website and be able to put it on my html page like so:

A square that is centered in the middle of the website's page, and that random numbers, like 1 to 1,000,000,000,000, go through it, and that these numbers stay up and running without having to press a button. Did I understand?

If anyone knows please help me !!

views – Create a custom block programmatically in Drupal 8

I couldn't find a way to show view and restrict certain roles.

But I have managed to solve the problem in another way.

I created a script in Admin> Structure> Block> My_Block> Configure> PHP Visibility:

$hide_from_roles = array('administrator', 'sefii', 'membership');
 if (count(array_intersect($heh, $hide_from_roles)) > 0) {
    $match = FALSE;
return $match;

Create a web hosting business with the WHM option for members

Hi there.! I just want to ask if I need to if I am going to create a web hosting business with WHM option for clients. I already have a web server … | Read the rest of

18.04 – Is it possible to create a virtual television to transmit content from a phone?

I can use Smart View to stream content (don't stream my screen! I already use scrcpy for that) from my phone to my Samsung TV. Would it be possible to create a "virtual Samsung TV" within Ubuntu and stream content to it?

I want to play a slide show from my gallery to virtual TV and still be able to use my phone while the slide show is playing in the background just like normal TV.

Where and how to create po files for the US states? USA And Canada?

Therefore, my site supports 10 other languages ​​besides English. I am trying to convert all states in the US. USA And Canada in po files for each language translation. I found one that translates countries here: However, I can't seem to find a translation page like that to translate US states. USA And Canada to other languages.

I will create 10,000 dofollow seo backlinks for $ 90

I will create 10,000 dofollow seo backlinks

I will create 10,000 backlinks Dofollow Ser

It works best for!

  • Youtube videos
  • Websites 2.0
  • Buffer Links
  • Level 1 Urls Boost
  • 301 or url shorteners

Where will you get links from?

  • Article sites
  • Blog comment
  • Forum Profiles
  • web 2.0
  • Articles Directory
  • Wiki

Characteristics of my concert

  • Unlimited revisions
  • Complete report at the end of the order
  • Generally over delivered
  • Good mix of DoFollow – NoFollow
  • Indexing using the paid indexing service
  • Fast support All this for just $ 5
  • Anchor text optimization

Note: Adult websites not allowed

Best use: Use massive links on level 2 sites to boost and boost them. For the main sites, see the extras.

For any confusion, be sure to contact me to resolve it. Best of luck!


I can't create even 1 article link! -. :: GSA Marketing and SEO Forum ::.

Hi there,
Today, for some reason, I can't even create the article link.
I check my proxy servers and they are working fine. I'm trying to change the settings, clear the cache but nothing fixes the problem.
I also get many captchas like the one in the screenshot from yesterday.

Any idea what is going on?

Thank you.

I'll create 800 high quality Dofollow blog comments with manual feedback in High PR8 + for $ 12

I will create 800 high quality Dofollow blog comments with manual feedback in High PR8 +

High-quality work provider

If you want to buy secure TOP Authority Pages backlinks and rank your TOP website on Google, then I'm here to help. I will create 800 high quality Dofollow blog comment feedback links manually in High PR8 +

I will use your keywords and short extension when possible on the page. This puts your link in High PA / DA and TF / CF also Context with the theme of your site

Google has officially terminated all website PR, so why does it keep getting high PR links? Don't buy PR 0 Iinks Just buy Iinks with High TF CF DA PA (and must be actual TF and DA page)

Concert Feature

  • According to the latest update of Google 2020
  • 100% manual and live links
  • 100% safe from Google Animals
  • DoFollow backlinks
  • Backspace links on High TF CF DA PA pages not on root domains
  • Acceptability of all languages
  • Unlimited URLs and unlimited keywords
  • Free unlimited review until you are completely satisfied
  • 24/7 customer support

Frequently asked questions

How many URLs and keywords do you accept?
I will accept unlimited URLs and unlimited keywords

Do you work for a new website?
Yes! I will also work for a new website.

Do you accept the website of another language that you expect English?
Yes! I accept English, Estonian, Finnish, French, German, Greek, Hungarian, Irish, Italian and all other languages.

Do you work for the illegal Casino Porn Adult website?
Yes! I agree

Do you post relevant comments on the content of my website?
Yes! I will put relevant comment links on the content of your website.

Do you provide a report after work is completed?
Yes! I will provide all the details in the excel file after completing the job.

What do I need / requirement?

So give your Google Ranking a HUGE PUSH with these more powerful blog comments.

Once your order is complete I will provide you a detailed excel report

. (tagsToTranslate) blog (t) comments (t) backlink (t) seo (t) rank (t) dofollow

8 – Create cookie after downloading the file

I want to create a cookie after file download.

This is an extension of the existing module:

Every time you click on a download, a pop-up window opens.
It is fine for me to have the email address of the visitors once.
Direct download is then possible without displaying the popup again on other download pages.

This part of the code does not generate a cookie … why?

    $c_response = new SymfonyComponentHttpFoundationResponse();
    $c_response->headers->setCookie(new SymfonyComponentHttpFoundationCookie('foo', 'bar'));

    // Get cookie value
    $c_request  = new SymfonyComponentHttpFoundationRequest();
    $c_value = $c_request->cookies->get('foo');

    if($c_value) {
    } else {
        Drupal::logger('file_utility')->notice("cookie foo is empty");