Code Monkey home page Code Monkey logo

Comments (3)

skranz avatar skranz commented on August 25, 2024

Hmm, I don't see the problem in your screenshot when you just show example_df[,-2]. In the output the 5 remaining columns seem to be shown.

The command

example_df <- example_df[,2]

indeed won't work with RTutor. Using the same variable on the left and right in an assignment is often problematic in RTutor. More precisely, problems arise if calling the command twice would yield different results than calling it only once. This restriction is hard to fix in RTutor. So in particular deleting columns or rows won't work. If you want to do this you have to set a new variable name on the LHS.

from rtutor.

MartinKies avatar MartinKies commented on August 25, 2024

Yes you are right. Maybe something I will have a look at down the line. Right now I was able to circumvent the problem as per your suggestion.

And you are right that just showing example_df[,-2] did indeed deliver the desired output. I confused myself there.

from rtutor.

skranz avatar skranz commented on August 25, 2024

Just as a remark. Unrelated to the limitations of RTutor I also try to write my personal R code (at least the one outside packages) such that I can run a line twice without changing the result. E.g. if I want to remove a column, I like most to use a function like:

remove.cols = function(dat, cols) {
  dat[,setdiff(colnames(dat), cols)]
}

which returns the same data frame even when called errorneously twice. (I don't like e.g. that select(dat, -mycol) would throw an error if mycol does not exist anymore in dat). The thing is that I most often work interactively with R and it often happens that I run only some but not all data preparation steps twice and it is nice if this does not yield by accident wrong results. In this sense, RTutor forces you to follow this convention.

from rtutor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.