1

I'm trying to import a RDS file in Rstudio. And, when I type glimpse(data), it shows "Error: C stack usage 7970272 is too close to the limit'. I don't know if the following information is helpful, but the data is a spacial data, and has 26452 features and 14 fields.

I use a Macbook, and I tried following the answer from this thread

I typed the code in my terminal, but it still didn't work. Please help!

> Cstack_info()
      size    current  direction eval_depth 
   7969177      17024          1          2 

enter image description here

Edit 1: output for str(data)

Classes ‘sf’ and 'data.frame':  26452 obs. of  15 variables:
 $ State         : chr  "AL" "AL" "AL" "AL" ...
 $ Location      : chr  "Huntsville, AL" "Huntsville, AL" "Montgomery, AL" "Huntsville, AL" ...
 $ City          : chr  "HUNTSVILLE" "HUNTSVILLE" "MONTGOMERY" "HUNTSVILLE" ...
 $ Date          : Date, format: "2020-06-01" ...
 $ Attendees     : int  NA NA 40 NA 500 25 NA 40 NA 10 ...
 $ Tags          : Factor w/ 1893 levels "Civil Rights; Against abortion rights",..: 237 237 237 237 237 1292 237 843 1111 173 ...
 $ Curated       : Factor w/ 2 levels "No","Yes": 2 2 2 2 2 2 2 2 2 2 ...
 $ Source        : Factor w/ 22639 levels "B","http://13wham.com/news/local/community-rallies-behind-victims-survivors-of-gun-violence",..: 14745 12397 17787 14745 18848 12831 12390 12833 9287 2367 ...
 $ Total.Articles: int  2 3 5 1 3 1 1 8 1 2 ...
 $ Year          : num  2020 2020 2019 2020 2020 ...
 $ Day           : int  1 30 6 5 31 7 9 9 30 5 ...
 $ Month         : num  6 5 2 6 5 9 12 11 6 5 ...
 $ DOY           : num  153 151 37 157 152 250 343 313 181 125 ...
 $ Name          : Factor w/ 51 levels "Alabama","Alaska",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ geometry      :sfc_POINT of length 26452; first list element:  'XY' num  -86.6 34.7
 - attr(*, "sf_column")= chr "geometry"
 - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
  ..- attr(*, "names")= chr  "State" "Location" "City" "Date" ...
confusedallthetime
  • 155
  • 1
  • 3
  • 9
  • Are you able to work with the data otherwise? To put it another way, does this happen with `glimpse` only? – Roman Luštrik Sep 26 '20 at 16:13
  • @RomanLuštrik No, it happens to all the code I run. – confusedallthetime Sep 26 '20 at 16:21
  • 1
    Usually the error **C stack usage --- is too close to the limit** happens when a function performs recursive evaluation, and goes too deep before finishing the evaluation. Each recursion adds a lot to the stack. It is suprising if this is happening regardless of chosen function. That would (to me) indicate that the size of whatever object is in `M3 protests_sf.RDS` is likely very deep. What about `object.size(data)`? Just to evaluate something very low-level and basic. – Oliver Sep 26 '20 at 17:03
  • `str(data)` might be another thing to try. – Ben Bolker Sep 26 '20 at 17:56
  • @Oliver Thank you! your explanation is very helpful and your suggestion works! However, I still can't run other operators (such as filter(), select()) with the data. Do you perhaps know why? – confusedallthetime Sep 26 '20 at 18:36
  • @BenBolker Thank you Ben, that worked for me! However, like what I replied to Oliver above. I can't run other operators with the data. Do you have any suggestions for that? – confusedallthetime Sep 26 '20 at 18:38
  • I meant, "can you show us the output of `str(data)` ?" (or at least part of it?) Without knowing something about what your data looks like, we're kind of guessing in the dark. – Ben Bolker Sep 26 '20 at 21:30
  • https://community.rstudio.com/t/r-mapping-c-stack-usage-7971616-is-too-close-to-the-limit/60267 – Ben Bolker Sep 26 '20 at 21:33
  • @BenBolker Ah my bad. I just updated my post with the str(data). – confusedallthetime Sep 26 '20 at 22:47
  • thanks. I still don't think I can help, but maybe someone else will see something in there. – Ben Bolker Sep 26 '20 at 22:48
  • @BenBolker No worries. Thank you anyways! – confusedallthetime Sep 26 '20 at 23:17
  • Since you are able to execute low-level (ish) functions such as `object.size` and `str` (`summary` as well I'm guessing) my bet is that `tidyverse` performs a bit (if not a lot) of unnecessary but hard to recode recursion within their functions (`glimpse` and `select` are tidyverse functions). If that is the case then **a** solution is to **not** use `dplyr`, `broom`, `tidyr` and so on. An alternative and far more time consuming solution would be to debug `glimpse` and find the specific point at which the function reaches the **c-stack** limit, fix it and then post a pull request on github. – Oliver Sep 27 '20 at 08:32

1 Answers1

1

Thank you everyone for the comment! I fixed it by clearing my computer memory and re-downloading the newest version of R and Rstudio.

confusedallthetime
  • 155
  • 1
  • 3
  • 9