Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6091661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:21:13+00:00 2026-05-23T12:21:13+00:00

I have created a script that analyzes a set of raw data and converts

  • 0

I have created a script that analyzes a set of raw data and converts it into many different formats based on different parameters and functions. I have 152 more raw data sheets to go, but all I will have to do is use my script on each one. However, there will be times that I might decide I need to change a variable or parameter and I would like to come up with a parameter list at the top of my spreadsheet that would affect the rest of the functions in my soon to be very large script.

  1. Global variables aren’t the answer to this problem, this is best illustrated through this example:

    exceedes <- function (L=NULL, R=NULL)
    {
    
    if (is.null(L) | is.null(R)) 
    {
    print ("mycols: invalid L,R.")
    return (NULL)               
    }
    options (na.rm = TRUE)
    test <-(mean(L, na.rm=TRUE)-R*sd(L,na.rm=TRUE))
    test1 <- ifelse(is.na(L), NA, ifelse(L > test, 1, 0))
    return (test1)
    }
    
    L=ROCC[,2]
    R=.08
    ROCC$newcolumn <- exceedes(L,R)
    names(ROCC)[names(ROCC)=="newcolumn"]="Exceedes1"
    
    L=ROCC[,2]
    R=.16
    ROCC$newcolumn <- exceedes(L,R)
    names(ROCC)[names(ROCC)=="newcolumn"]="Exceedes2"
    
    L=ROCC[,2]
    R=.24
    ROCC$newcolumn <- exceedes(L,R)
    names(ROCC)[names(ROCC)=="newcolumn"]="Exceedes3"
    

So in the above example, I would like to have a way at the top of my script to change the range of R and have it affect the rest of the script because this function will be repeated 152 times. The only way I can think of doing it is to copy and paste the function over and over with a different variable each time, and set it globally. But I have to imagine there is a simpler way, my function possibly needs to be rearranged perhaps?

  1. File names and output names. I am not sure whether this is possible but say for example that all my input.csv’s come in a format where one dataset will be titled 123 another will be 124, another 125 etc. and then have R know to take the very next dataset, and then output that dataset to a specific folder on my computer without me having to actually type in read.csv(file=”123.csv”), and then write.csv(example, file=”123.csv) and so on?

  2. General formatting of automation script
    Before I dive into my automation, my procedure was going to be to copy and past the script 152 times over and then change the filename and output name for each one. This sounds ridiculous, but with my lack of programming skills I am not sure a better way to change it. Any ideas?

Thanks for all the help in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:21:13+00:00Added an answer on May 23, 2026 at 12:21 pm

    You can rerun the function with different parameters by constructing a vector of paremters (say R)

    R <- c(seq(0.1, 1, by = 0.01))
    

    and then run your exceedes function length(R) times using sapply.

    exceedes <- function(R, L) {} #notice the argument order
    sapply(X = R, FUN = exceedes, L = ROCC[, 2])
    

    You can pass other arguments to your function (e.g. file.name) and use it to create whatever file name you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a PHP-script to update a web server that is live inside
I have written a CGI script that creates an image dynamically using GET data.
I have a selenium script that I created with Selenium IDE. I was wondering
I have a Perl script to analyze many megabytes of data line-by-line. As an
I have created PS script that queries the Event Logs on my Servers then
I have created a script that sends email automatically! My mail message is included
I have created a Python script that I want to run daily via a
See i have a created a script that logs in the user. And I
Quite new to this but i have created a SQL script that groups by
Suppose I have wrote script Table_ABC.sql which creates table ABC. I have created many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.