Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

TranceNova

  • 4 years ago

Anyone use R for data manipulation? I'm trying to get a subset and struggling with my code... (basically I'm trying to select stuff based on different values in different columns, but I just don't know how to word it).

  • This Question is Closed
  1. mcnalljj
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    You'd likely be better off asking this in the CompSci section of the site. And it'd be good to include some source code and data.

  2. FoolForMath
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    R is good for data manipulation?

  3. TranceNova
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Yeah I suspected that, I just figured I'd wait to see if anyone used R. Programmers don't really use R do they? And yepp!

  4. FoolForMath
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I have never used R and nor I am looking forward to using it ... btw what about sql or my sql?

  5. TranceNova
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Haven't used sql/my sql before. Nah don't worry R is VERY useful does take some learning but way better than excel once you learn it

  6. mcnalljj
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    use nested if statements that cycle through your data and break if a requirement isn't met?

  7. TranceNova
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Thanks for your help, I think I will have to come back to this later when my brain is working a little better, I've been trying to type a description of what I am trying to do and not getting anywhere!

  8. mcnalljj
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    while(!eof) //while you haven't reached the end of the file (eof) if (mindate<x<maxdate) { next if } else { break;} } Something like that, I'm not at all familiar with R, I'm more into OOP and functional languages. But, I was meant to study it at one point. As I said give some code and a description of what you want, and I'll try give some pointers.

  9. TranceNova
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Hmmm.. What if I show you the way I was doing it in excel, would that make any sense to you? (p.s. I definitely not from a programing background.. to tell you the thruth I've never used a loop before)

  10. TranceNova
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    oh dear I can't even spell today! Anyway if you look to the far right of the sheet (which I cut alot of data out of so you could see better) you will see the excel functions I've used - basically just to get a percentage of each landuse in the "LCT_1990" column out of each "FID_buffer931" code (which is each site - first column). My "FID_buffer931" gets down to 19, so I don't want to keep doing it manually in excel like I am doing. I was originally trying to stick "q<-subset(B,"LCT.1990=bare" & "FID.poly9093=1")" in R just to select one landuse in one site (yes I can hear you cringe at that awful - and wrong - piece of code).

    1 Attachment
  11. mcnalljj
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hmmm and You're sure that R is the language you'd like to use? Sorry I might be a bit slow at this, your variable names are not terribly stranger friendly. What are you having difficulty with? Is it where you are using sumif in excel?

  12. TranceNova
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Hmm yeah, mainly because its the only other one I remotely know how to use, and I know it can be used for that type of thing.. I'm just missing the how part :P Yeah, they are pretty bad.. that's why I was reluctant to go on lol. Anyway basically "LCT_1990" = is landuse and "FID_buffer931" = site. You see I know how to do it in excel - like you can see - but to do the whole dataset (which is much longer) I would have to keep pasting those excel functions under each block of "sites" or "FID_buffer931" numbers (separated by the colours). I suppose I was trying to be lazy :P and I suspect I should probably go to an R forum hehe.

  13. TranceNova
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Anyway please don't waste time on it! I'm going to bed :)

  14. mcnalljj
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    In java or c++ once you'd read these in, I would make them in to objects with, then pass them to functions which would handle the calculations. I'm sorry I was expecting a bit of debugging rather than thinking the whole thing out.

  15. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy