Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R Programming / Functions - nothing loads in modify script question #289

Closed
diadema378 opened this issue Apr 23, 2015 · 15 comments
Closed

Comments

@diadema378
Copy link

R Studio in Mac OS 10.10.3

Below is what I get. There's no script to modify.
|============== | 12%

| In the following question you will be asked to modify a script that will appear as soon as you move on from this question. When you have finished modifying the script, save your changes to the script and type submit() and the script will be evaluated. There will be some comments in the script that opens up, so be sure to read them!
...
|================ | 15%

| The last R expression to be evaluated in a function will become the return value of that function. We want this function to take one argument, x, and return x without modifying it. Delete the pound sign so that x is returned without any modification. Make sure to save your script before you type submit().

@seankross
Copy link
Member

Does this still occur after restarting RStudio and Making sure you have no r script files open?

@diadema378
Copy link
Author

Hi Sean,

Thank you - If I quit RStudio and reopen, I get a file deleted message,

If I select Yes, load swirl package, start swirl, and start Functions exercise from the start, the same thing happens - no script appears to modify.

If I open R in Terminal and load the swirl package, I get:

| Hi! I see that you have some variables saved in your workspace. To keep
| things running smoothly, I recommend you clean up before starting swirl.

| Type ls() to see a list of the variables in your workspace. Then, type
| rm(list=ls()) to clear your workspace.

| Type swirl() when you are ready to begin.

ls()
[1] "boring_function" "ints”

If I clear the workspace, return to RStudio, load swirl packages, start swirl, return to R functions, the same thing happens - no script appears.

Thanks for any help you can provide.

Regards,

On Apr 24, 2015, at 10:17 AM, Sean Kross notifications@github.com wrote:

Does this still occur after restarting RStudio and Making sure you have no r script files open?


Reply to this email directly or view it on GitHub #289 (comment).

@diadema378
Copy link
Author

Never mind! I didn’t realize the script appears in the source work area of R, which I had collapsed so as to give me more work area in the console. you might consider adding ‘in the source work area above the console’ to the end of 'you will be asked to modify a script that will appear’. Sorry for the trouble.

On Apr 24, 2015, at 10:17 AM, Sean Kross notifications@github.com wrote:

Does this still occur after restarting RStudio and Making sure you have no r script files open?


Reply to this email directly or view it on GitHub #289 (comment).

@seankross
Copy link
Member

I'm so happy it works! I was stumped!

@ghost
Copy link

ghost commented Apr 28, 2016

I am reading these others errors people are having. I used RStudio, I used the RGUI, I tried using the newest RGUI 3.2.5, and still after saving the Rscript with the function as shown AND with out the '#' in front of the x, I get the same dialogue box, over, and over, ... again.

You're about to write your first function! Just like you would assign a value

to a variable with the assignment operator, you assign functions in the following

way:

function_name <- function(arg1, arg2){

# Manipulate arguments in some way

# Return a value

}

The "variable name" you assign will become the name of your function. arg1 and

arg2 represent the arguments of your function. You can manipulate the arguments

you specify within the function. After sourcing the function, you can use the

function by typing:

function_name(value1, value2)

Below we will create a function called boring_function. This function takes

the argument x as input, and returns the value of x without modifying it.

Delete the pound sign in front of the x to make the function work! Be sure to

save this script and type submit() in the console after you make your changes.

boring_function <- function(x) {
#x
}

I have written this in my R script file:

boring_function <- function(x) {
x
}
Then I save it as functions.R in my folder of my working directory, then source it in the console as:
source("functions.R"), and type submit() as the prompt directs the user to do, and I get this message:

Sourcing your script...

| Give it another try.

| Make sure to delete the pound sign so the last expression in the function is
| just x.

So, what am I missing or doing wrong here? Thank you.

@seankross
Copy link
Member

What happens if you skip the question?
On Thu, Apr 28, 2016 at 4:06 PM JanisCorona notifications@github.com
wrote:

I am reading these others errors people are having. I used RStudio, I used
the RGUI, I tried using the newest RGUI 3.2.5, and still after saving the
Rscript with the function as shown AND with out the '#' in front of the x,
I get the same dialogue box, over, and over, ... again.
You're about to write your first function! Just like you would assign a
value to a variable with the assignment operator, you assign functions in
the following way:

function_name <- function(arg1, arg2){ # Manipulate arguments in some way #
Return a value }

The "variable name" you assign will become the name of your function. arg1
and arg2 represent the arguments of your function. You can manipulate the
arguments you specify within the function. After sourcing the function,
you can use the function by typing: function_name(value1, value2)

Below we will create a function called boring_function. This function takes the
argument x as input, and returns the value of x without modifying it. Delete
the pound sign in front of the x to make the function work! Be sure to save
this script and type submit() in the console after you make your changes.

boring_function <- function(x) {
#x
}

I have written this in my R script file:

boring_function <- function(x) {
x
}
Then I save it as functions.R in my folder of my working directory, then
source it in the console as:
source("functions.R"), and type submit() as the prompt directs the user to
do, and I get this message:

Sourcing your script...

| Give it another try.

| Make sure to delete the pound sign so the last expression in the
function is
| just x.

So, what am I missing or doing wrong here? Thank you.


You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub
#289 (comment)

@diadema378
Copy link
Author

you’re not doing anything w/in your function to return a value, so try return x

On Apr 28, 2016, at 4:06 PM, JanisCorona notifications@github.com wrote:

I am reading these others errors people are having. I used RStudio, I used the RGUI, I tried using the newest RGUI 3.2.5, and still after saving the Rscript with the function as shown AND with out the '#' in front of the x, I get the same dialogue box, over, and over, ... again.

You're about to write your first function! Just like you would assign a value

to a variable with the assignment operator, you assign functions in the following

way:

function_name <- function(arg1, arg2){

Manipulate arguments in some way

Return a value

}

The "variable name" you assign will become the name of your function. arg1 and

arg2 represent the arguments of your function. You can manipulate the arguments

you specify within the function. After sourcing the function, you can use the

function by typing:

function_name(value1, value2)

Below we will create a function called boring_function. This function takes

the argument x as input, and returns the value of x without modifying it.

Delete the pound sign in front of the x to make the function work! Be sure to

save this script and type submit() in the console after you make your changes.

boring_function <- function(x) {
#x
}

I have written this in my R script file:

boring_function <- function(x) {
x
}
Then I save it as functions.R in my folder of my working directory, then source it in the console as:
source("functions.R"), and type submit() as the prompt directs the user to do, and I get this message:

Sourcing your script...

| Give it another try.

| Make sure to delete the pound sign so the last expression in the function is
| just x.

So, what am I missing or doing wrong here? Thank you.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub #289 (comment)

@SoumikKB
Copy link

Hi,
Rstudio on windows 7
R version 3.2.4 Revised (2016-03-16 r70336)
Problem encountered : similar to diadema378 - please find the comments which was displayed in the R console -

"""""""""
| The last R expression to be evaluated in a function will become the return value
| of that function. We want this function to take one argument, x, and return x
| without modifying it. Delete the pound sign so that x is returned without any
| modification. Make sure to save your script before you type submit().

Error in editor(file = file, title = title) :
argument "name" is missing, with no default

| Leaving swirl now. Type swirl() to resume.
"""""""""""
I have closed the R script tabs which was open in the window above the console and restarted the R studio. As per the entry instructions cleaned up the variables using > rm(list = ls()) and then continued as below -

"""""""

library(swirl)

| Hi! I see that you have some variables saved in your workspace. To keep things
| running smoothly, I recommend you clean up before starting swirl.

| Type ls() to see a list of the variables in your workspace. Then, type
| rm(list=ls()) to clear your workspace.

| Type swirl() when you are ready to begin.

Warning message:
package ‘swirl’ was built under R version 3.2.5

ls()
[1] "a" "add2" "e" "x" "y"
rm(list = ls())
swirl()

| Welcome to swirl! Please sign in. If you've been here before, use the same name as
| you did then. If you are new, call yourself something unique.

What shall I call you? Soumik

| Would you like to continue with one of these lessons?

1: R Programming Functions
2: No. Let me start something new.

Selection: 1
.....
""""""""""""""""""""""""""""""""""""""'
I am still encountering the same issue. Not sure if I am doing anythin incorrect. Request guidance on this. Thank you,

Best Regards,
Soumik

@seankross
Copy link
Member

See #434 (comment)

@pratik20k
Copy link

boring_function(x) doesn't work properly in swirl. Its always give delete pound sign comment. And even mentor of Coursera are not helping with it

@brianhuynh2021
Copy link

      Does this still occur after restarting RStudio and Making sure you have no r script files open?
      R Studio in Mac OS 10.10.3

Below is what I get. There's no script to modify.
|============== | 12%
| In the following question you will be asked to modify a script that will appear as soon as you move on from this question. When you have finished modifying the script, save your changes to the script and type submit() and the script will be evaluated. There will be some comments in the script that opens up, so be sure to read them!
...
|================ | 15%
| The last R expression to be evaluated in a function will become the return value of that function. We want this function to take one argument, x, and return x without modifying it. Delete the pound sign so that x is returned without any modification. Make sure to save your script before you type submit().

Hello, for this issue please delete pound '#' first, then you click Run on console side bar. Nex, Save it and reopen the source, you then click "Run" again, now you type submit() --> Enter. I hope it would run well for you, and the error will be fixed.

delete pound

@ctejeda86
Copy link

Hi there, I have the same problem. I did what brianhuynh27 said, but I get the next message from R:

Try again. Getting it right on the first try is boring anyway!

| Make sure to delete the pound sign so the last expression in the function is just x.

I can't continue with that lesson. I hope someone can help me. Regards.

@ctejeda86
Copy link

Hi there, I have the same problem. I did what brianhuynh27 said, but I get the next message from R:

Try again. Getting it right on the first try is boring anyway!

| Make sure to delete the pound sign so the last expression in the function is just x.

I can't continue with that lesson. I hope someone can help me. Regards.

Hi. My function works. I delete pound sign, click Run, click save, and then wrote "submit()"in the console and click Run, and it finally works.

@Elephanty33
Copy link

      Does this still occur after restarting RStudio and Making sure you have no r script files open?
      R Studio in Mac OS 10.10.3

Below is what I get. There's no script to modify.
|============== | 12%
| In the following question you will be asked to modify a script that will appear as soon as you move on from this question. When you have finished modifying the script, save your changes to the script and type submit() and the script will be evaluated. There will be some comments in the script that opens up, so be sure to read them!
...
|================ | 15%
| The last R expression to be evaluated in a function will become the return value of that function. We want this function to take one argument, x, and return x without modifying it. Delete the pound sign so that x is returned without any modification. Make sure to save your script before you type submit().

Hello, for this issue please delete pound '#' first, then you click Run on console side bar. Nex, Save it and reopen the source, you then click "Run" again, now you type submit() --> Enter. I hope it would run well for you, and the error will be fixed.

delete pound

It worked.

  1. write the function
  2. delete#
    3.click Run
  3. Save
  4. click Run
  5. type submit()

@vedasreereddy
Copy link

save the function(just select the function part and save it) before typing submit() in the console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants