R Studio Crashed and Failed to Save Unsaved Changes, Lost R Script, and R-Studio No Longer Reads CSV files

Overview

Before I started my project, I updated R and R Studio to the newest versions, so I subsequently had an older and newer version of R-Studio on my computer.

While I was working on the project, all of a sudden, I got a warning message saying:

Message

File changed.

The file Rscript.R has changed on disk.
Do you want to reload the file from disk and discard your unsaved changes?

I selected 'No' because I wanted to keep all the unsaved work.

All of a sudden, R-studio crashed and I re-opened R-Studio and the R-script. I continued to work on the project, but R-Studio crashed again. The same happened four or five times where: (1) I receive the warning message; (2) R-Studio freezes; and (2) R-Studio closes itself.

Each time I re-opened R-Studio, I clicked on the 'R-Studio' toolbar at the bottom of the screen (I have a MacBook Pro). After a while, I realised I'd accidentally opened the newest and oldest versions of R-Studio simultaneously.

Therefore, I was working on two versions of the R-script on two different versions of R-Studio at different points in time; however, I repeatedly saved all unsaved changes on both versions. I decided to update, save all the unsaved changes, and close both R-Studio versions to produce a fresh start.

I, therefore, opened the newest version of R-Studio from my documents folder and the associated R-script. However, all the unsaved changes which I had been saving were gone. In summary, I was using 'Save Page as' in my file documents to save all unsaved changes, but these unsaved changes were not saving in the R-Script. As a consequence, I have now lost three-quarters of my work.

I re-opened the older version of R-Studio and attempted to re-open the R-script just in case the project could be recovered here. However, I could not recover my work because the .csv file had been corrupted, and I am now experiencing many different problems, which I cannot solve.

If anyone can help to solve the warning messages in order to open the .csv file and to retrieve my R-Script, I would be extremely grateful.

Problem 1:

I tried to open the .csv file (which was opening without any problems beforehand) in the specified documents folder using the same working directory as before However, the .csv file will not open now. I double checked the .csv files and they were corrupted after R-Studio crashed. I copied and pasted the data onto new excel files, saved them as .csv files, deleted the corrupted files, and placed the new .csv files in the same document folder as before with name.

To solve this situation, I tried several different methodologies but nothing works.

  1. I have checked the status of the .csv file and it is not 'Read Only' or 'Blocked".

  2. I have also tried list.files() and this function returns 'character(0)'.

  3. The working directory is written to the correct level using the correct command e.g. read.csv() towards the correct documents folder containing the .csv file i

R-code

leaf_1<-read.csv("~/Users/kirstymedcalf/Documents/Open University/S397 Terrestrial Ecosystems/TMA'S/TMA02/Data_TMA02_S397/Phenological_observations_1_S397_TMA02/Phenological_observations_1_S397_TMA02_2019.csv", header = T, stringsAsFactors=TRUE, sep=',')

#Error message

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file '/Users/kirstymedcalf/Documents/Open University/Ecosystems/TMA03/Group B Data/GroupB/GroupB.csv': No such file or directory

I also tried: setting the working directory and opening up the .csv file again. However, the output is the same warning message.

print(getwd()) # Where does the code think it is?
setwd("~Users/kirstymedcalf/Documents/Open University/S397 Terrestrial Ecosystems/TMA'S/TMA02/Data_TMA02_S397/Phenological_observations_1_S397_TMA02/Phenological_observations_1_S397_TMA02_2019.csv") # Where do I want my code to be?
leaf_1 = read.csv("~Users/kirstymedcalf/Documents/Open University/S397 Terrestrial Ecosystems/TMA'S/TMA02/Data_TMA02_S397/Phenological_observations_1_S397_TMA02/Phenological_observations_1_S397_TMA02_2019.csv") #just make it work!

Problem 2

I attempted to recover the lost R-Script using suggestions from different websites. All solutions suggest the R-Scripts could be recovered from sdb files using jsonlite::fromJSON format; however, I don't understand how to find these sdb files on my computer. Therefore, I am currently unable to input the correct working directory to recover the unsaved R-Scripts from these the sdb files stored on my computer.

R-code:

##R Support and StackOverflow Solutions

#Example of suggested jsonlite::fromJSON code to recover the R-Scripts.

 dataObj <- jsonlite::fromJSON('.Rproj.user/586F3E74/sdb/s-DB8D414F/BDFFFF92', simplifyVector = T)
writeLines(json$contents, con = "/path/to/file.R")

    #jsonlite::fromJSON function

function (txt, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, 
    simplifyMatrix = simplifyVector, flatten = FALSE, ...) 
{
    if (!is.character(txt) && !inherits(txt, "connection")) {
        stop("Argument 'txt' must be a JSON string, URL or file.")
    }
    if (is.character(txt) && length(txt) == 1 && nchar(txt, type = "bytes") < 
        2084 && !validate(txt)) {
        if (grepl("^https?://", txt, useBytes = TRUE)) {
            loadpkg("curl")
            h <- curl::new_handle(useragent = paste("jsonlite /", 
                R.version.string))
            curl::handle_setheaders(h, Accept = "application/json, text/*, */*")
            txt <- curl::curl(txt, handle = h)
        }
        else if (file.exists(txt)) {
            txt <- file(txt)
        }
    }
    parse_and_simplify(txt = txt, simplifyVector = simplifyVector, 
        simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, 
        flatten = flatten, ...)
}
<bytecode: 0x10de79d58>
<environment: namespace:jsonlite>

Data

Data

structure(list(Obs_.no = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 
36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 
49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 
62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 
75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 
88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L, 
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L, 
123L, 124L, 125L, 126L, 127L, 128L, 129L, 130L, 131L, 132L, 133L, 
134L, 135L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 143L, 144L, 
145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 155L, 
156L, 157L, 158L, 159L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 
178L, 179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 
189L, 190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L, 198L, 199L, 
200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 209L, 210L, 
211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 219L, 220L, 221L, 
222L, 223L, 224L, 225L, 226L, 227L, 228L, 229L, 230L, 231L, 232L, 
233L, 234L, 235L, 236L, 237L, 238L, 239L, 240L, 241L, 242L, 243L, 
244L, 246L, 247L, 248L, 249L, 250L, 251L, 252L, 253L, 254L, 255L, 
256L, 257L, 258L, 259L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 
267L, 268L, 269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 
278L, 279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 288L, 
289L, 290L, 291L, 292L, 293L, 294L, 295L, 296L), Date_observed = structure(c(5L, 
17L, 7L, 7L, 7L, 7L, 3L, 3L, 3L, 3L, 12L, 12L, 12L, 12L, 4L, 
4L, 4L, 4L, 9L, 9L, 9L, 9L, 9L, 9L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
7L, 12L, 12L, 12L, 12L, 13L, 8L, 8L, 8L, 8L, 10L, 10L, 10L, 10L, 
10L, 10L, 10L, 10L, 10L, 10L, 9L, 9L, 9L, 12L, 12L, 6L, 6L, 6L, 
6L, 16L, 16L, 16L, 16L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 7L, 7L, 
7L, 7L, 7L, 14L, 14L, 14L, 6L, 6L, 10L, 10L, 10L, 10L, 4L, 4L, 
4L, 4L, 5L, 5L, 5L, 5L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 1L, 
1L, 12L, 12L, 12L, 12L, 12L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 5L, 
5L, 5L, 5L, 6L, 6L, 6L, 6L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
11L, 7L, 7L, 7L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 
5L, 5L, 5L, 5L, 9L, 9L, 11L, 11L, 11L, 11L, 3L, 3L, 10L, 10L, 
10L, 10L, 4L, 4L, 4L, 4L, 12L, 12L, 12L, 10L, 10L, 10L, 10L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 14L, 14L, 14L, 14L, 9L, 9L, 9L, 
9L, 11L, 11L, 11L, 11L, 4L, 4L, 4L, 4L, 7L, 7L, 7L, 14L, 14L, 
14L, 14L, 10L, 10L, 11L, 11L, 11L, 3L, 3L, 3L, 3L, 14L, 4L, 4L, 
4L, 4L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 5L, 5L, 5L, 12L, 6L, 6L, 6L, 6L, 11L, 6L, 6L, 6L, 12L, 12L, 
2L, 2L, 2L, 2L, 6L, 6L, 6L, 10L, 10L, 10L, 10L, 15L, 11L, 11L, 
11L, 11L, 3L, 3L, 3L, 7L, 7L, 7L, 4L, 4L, 4L, 12L, 12L, 12L, 
12L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 12L, 7L, 
7L, 7L, 7L, 12L, 12L, 12L, 12L), .Label = c("10/1/18", "10/14/18", 
"10/19/18", "10/20/18", "10/21/18", "10/22/18", "10/23/18", "10/24/18", 
"10/25/18", "10/26/18", "10/27/18", "10/28/18", "10/28/19", "10/29/18", 
"11/6/18", "12/9/18", "8/20/18"), class = "factor"), Latitude = c(51.4175, 
52.12087, 52.0269, 52.0269, 52.0269, 52.0269, 52.947709, 52.947709, 
52.947709, 52.947709, 53.14919, 53.14919, 55.94154, 55.94154, 
51.59449, 51.59449, 51.59449, 51.59449, 51.491811, 51.491811, 
52.59925, 52.59925, 52.59925, 52.59925, 51.60157, 51.60157, 51.60157, 
51.60157, 52.6888, 52.6888, 52.6888, 52.6888, 50.697802, 50.697802, 
50.697802, 50.697802, 53.62417, 50.446841, 50.446841, 50.446841, 
50.446841, 35.292896, 35.292896, 53.959679, 53.959679, 53.959679, 
53.959679, 32.2855, 32.2855, 32.2855, 32.2855, 52.01434, 52.01434, 
52.01434, 50.8365, 50.8365, 51.78375, 51.78375, 51.78375, 51.78375, 
51.456965, 51.456965, 51.456965, 51.456965, 51.3651, 51.3651, 
51.3651, 51.3651, 52.01182, 52.01182, 52.01182, 52.01182, 55.919722, 
50.114277, 50.114277, 50.114277, 50.114277, 53.39912, 53.39912, 
53.39912, 51.43474, 51.43474, 51.10676, 51.10676, 51.10676, 51.10676, 
50.435984, 50.435984, 50.435984, 50.435984, 51.78666, 51.78666, 
51.78666, 51.78666, 51.473203, 51.473203, 51.473203, 53.38728, 
53.38728, 53.38728, 53.38728, 52.441088, 52.441088, 52.552344, 
19.61263, 19.61263, 19.61263, 19.61263, 53.582285, 53.582285, 
53.582285, 49.259471, 49.259471, 49.259471, 49.259471, 50.461625, 
50.461625, 50.461625, 50.461625, 51.746642, 51.746642, 51.746642, 
51.746642, 52.2501, 52.2501, 52.2501, 52.2501, 52.423336, 52.423336, 
52.423336, 52.423336, 50.79387, 50.79387, 50.79387, 53.615575, 
53.615575, 53.615575, 53.615575, 52.55317, 52.55317, 52.55317, 
52.55317, 51.08474, 51.08474, 51.08474, 53.19329, 53.19329, 53.19329, 
53.19329, 55.96785, 55.96785, 56.52664, 56.52664, 56.52664, 56.52664, 
52.04252, 52.04252, 51.8113, 51.8113, 51.8113, 51.8113, 52.580157, 
52.580157, 52.580157, 52.580157, 51.5894, 51.5894, 51.5894, 50.52008, 
50.52008, 50.52008, 50.52008, 25.3671, 25.3671, 25.3671, 25.3671, 
51.48417, 51.48417, 51.48417, 51.48417, 54.58243, 54.58243, 54.58243, 
54.58243, 52.58839, 52.58839, 52.58839, 52.58839, 52.717283, 
52.717283, 52.717283, 52.717283, 50.740764, 50.740764, 50.740764, 
50.740764, -36.865, -36.865, -36.865, 52.57937, 52.57937, 52.57937, 
52.57937, 50.736531, 50.736531, 50.79926, 50.79926, 50.79926, 
53.675996, 53.675996, 53.675996, 53.675996, 55.43828, 48.35079, 
48.35079, 48.35079, 48.35079, 51.36445, 51.36445, 51.36445, 51.36445, 
52.36286, 52.36286, 52.36286, -25.77831, -25.77831, -25.77831, 
-25.77831, -20.112381, -20.112381, -20.112381, -20.112381, 52.122402, 
52.122402, 52.122402, 51.481079, 52.16104, 52.16104, 52.16104, 
52.16104, 54.7311, 51.61842, 51.61842, 51.61842, 55.91913, 55.91913, 
51.06433, 51.06433, 51.06433, 51.06433, 55.920966, 55.920966, 
55.920966, 51.6528, 51.6528, 51.6528, 51.6528, 57.158724, 51.88485, 
51.88485, 51.88485, 51.88485, 52.34015, 52.34015, 52.34015, 50.615029, 
50.615029, 50.615029, 53.37687, 53.37687, 53.37687, 54.27745, 
54.27745, 54.27745, 54.27745, 52.026042, 52.026042, 52.026042, 
52.026042, 51.319032, 51.319032, 51.319032, 51.319032, 51.51357, 
51.51357, 51.51357, 51.51357, 53.43202, 53.43202, 53.43202, 53.43202, 
51.50823, 51.50823, 51.50823, 51.50823), Longitude = c(-0.32118, 
-0.29293, -0.7078, -0.7078, -0.7078, -0.7078, -1.435407, -1.435407, 
-1.435407, -1.435407, -0.76115, -0.76115, -3.19139, -3.19139, 
-2.98828, -2.98828, -2.98828, -2.98828, -3.210324, -3.210324, 
1.33011, 1.33011, 1.33011, 1.33011, -3.67111, -3.67111, -3.67111, 
-3.67111, -3.30909, -3.30909, -3.30909, -3.30909, -2.11692, -2.11692, 
-2.11692, -2.11692, -2.43155, -3.706923, -3.706923, -3.706923, 
-3.706923, 139.676727, 139.676727, -1.061008, -1.061008, -1.061008, 
-1.061008, -110.9434, -110.9434, -110.9434, -110.9434, 1.04007, 
1.04007, 1.04007, -0.1631, -0.1631, -0.65046, -0.65046, -0.65046, 
-0.65046, -2.624917, -2.624917, -2.624917, -2.624917, 0.70706, 
0.70706, 0.70706, 0.70706, -0.70082, -0.70082, -0.70082, -0.70082, 
-3.210278, -5.541128, -5.541128, -5.541128, -5.541128, -2.33356, 
-2.33356, -2.33356, 0.45981, 0.45981, -2.32071, -2.32071, -2.32071, 
-2.32071, -4.105617, -4.105617, -4.105617, -4.105617, -0.71433, 
-0.71433, -0.71433, -0.71433, -2.586492, -2.586492, -2.586492, 
-2.95811, -2.95811, -2.95811, -2.95811, -0.176158, -0.176158, 
-1.337177, 57.66801, 57.66801, 57.66801, 57.66801, -2.802239, 
-2.802239, -2.802239, -123.107788, -123.107788, -123.107788, 
-123.107788, 3.560973, 3.560973, 3.560973, 3.560973, 0.486416, 
0.486416, 0.486416, 0.486416, -0.8825, -0.8825, -0.8825, -0.8825, 
-1.787563, -1.787563, -1.787563, -1.787563, 0.26684, 0.26684, 
0.26684, -2.432959, -2.432959, -2.432959, -2.432959, -0.20337, 
-0.20337, -0.20337, -0.20337, -0.73645, -0.73645, -0.73645, -0.63793, 
-0.63793, -0.63793, -0.63793, -3.18084, -3.18084, -3.40313, -3.40313, 
-3.40313, -3.40313, -2.43733, -2.43733, -0.22894, -0.22894, -0.22894, 
-0.22894, -1.948571, -1.948571, -1.948571, -1.948571, 0.1879, 
0.1879, 0.1879, -4.20756, -4.20756, -4.20756, -4.20756, 51.53781, 
51.53781, 51.53781, 51.53781, -0.34854, -0.34854, -0.34854, -0.34854, 
-5.93229, -5.93229, -5.93229, -5.93229, -1.96843, -1.96843, -1.96843, 
-1.96843, -2.410575, -2.410575, -2.410575, -2.410575, -2.361234, 
-2.361234, -2.361234, -2.361234, 174.757, 174.757, 174.757, -1.89325, 
-1.89325, -1.89325, -1.89325, -2.011143, -2.011143, -3.19446, 
-3.19446, -3.19446, -1.272824, -1.272824, -1.272824, -1.272824, 
-4.64226, 10.91812, 10.91812, 10.91812, 10.91812, -0.23106, -0.23106, 
-0.23106, -0.23106, -2.06327, -2.06327, -2.06327, 28.22357, 28.22357, 
28.22357, 28.22357, 57.580207, 57.580207, 57.580207, 57.580207, 
-0.487443, -0.487443, -0.487443, -0.026923, 0.18702, 0.18702, 
0.18702, 0.18702, -5.8041, -0.16034, -0.16034, -0.16034, -3.20987, 
-3.20987, -1.79923, -1.79923, -1.79923, -1.79923, -3.193503, 
-3.193503, -3.193503, -1.57361, -1.57361, -1.57361, -1.57361, 
-2.166099, -0.17844, -0.17844, -0.17844, -0.17844, -1.27795, 
-1.27795, -1.27795, -1.966392, -1.966392, -1.966392, -1.34506, 
-1.34506, -1.34506, -0.47911, -0.47911, -0.47911, -0.47911, -0.503114, 
-0.503114, -0.503114, -0.503114, -0.472994, -0.472994, -0.472994, 
-0.472994, -3.18738, -3.18738, -3.18738, -3.18738, -2.27968, 
-2.27968, -2.27968, -2.27968, -0.25847, -0.25847, -0.25847, -0.25847
), Altitude = c(5L, 0L, 68L, 68L, 68L, 68L, 104L, 104L, 104L, 
104L, 11L, 11L, 0L, 0L, 7L, 7L, 7L, 7L, 15L, 15L, 23L, 23L, 23L, 
23L, 184L, 184L, 184L, 184L, 176L, 176L, 176L, 176L, 12L, 12L, 
12L, 12L, 178L, 36L, 36L, 36L, 36L, 0L, 0L, 11L, 11L, 11L, 11L, 
718L, 718L, 718L, 718L, 47L, 47L, 47L, 42L, 42L, 210L, 210L, 
210L, 210L, 97L, 97L, 97L, 97L, 23L, 23L, 23L, 23L, 0L, 0L, 0L, 
0L, 110L, 9L, 9L, 9L, 9L, 30L, 30L, 30L, 4L, 4L, 200L, 200L, 
200L, 200L, 160L, 160L, 160L, 160L, 166L, 166L, 166L, 166L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 74L, 74L, 74L, 74L, 36L, 
36L, 36L, 47L, 47L, 47L, 47L, 58L, 58L, 58L, 58L, 43L, 43L, 43L, 
43L, 97L, 97L, 97L, 97L, 133L, 133L, 133L, 133L, 18L, 18L, 18L, 
123L, 123L, 123L, 123L, 5L, 5L, 5L, 5L, 128L, 128L, 128L, 15L, 
15L, 15L, 15L, 14L, 14L, 65L, 65L, 65L, 65L, 45L, 45L, 129L, 
129L, 129L, 129L, 140L, 140L, 140L, 140L, 0L, 0L, 0L, 18L, 18L, 
18L, 18L, 0L, 0L, 0L, 0L, 30L, 30L, 30L, 30L, 19L, 19L, 19L, 
19L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 96L, 96L, 96L, 96L, 88L, 
88L, 88L, 169L, 169L, 169L, 169L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 123L, 123L, 123L, 
1436L, 1436L, 1436L, 1436L, 0L, 0L, 0L, 0L, 43L, 43L, 43L, 6L, 
75L, 75L, 75L, 75L, 0L, 73L, 73L, 73L, 109L, 109L, 0L, 0L, 0L, 
0L, 115L, 115L, 115L, 110L, 110L, 110L, 110L, 119L, 95L, 95L, 
95L, 95L, 112L, 112L, 112L, 23L, 23L, 23L, 34L, 34L, 34L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 24L, 24L, 24L, 24L, 38L, 38L, 38L, 
38L, 29L, 29L, 29L, 29L, 20L, 20L, 20L, 20L), Species = structure(c(6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 1L, 1L, 6L, 6L, 6L, 6L, 1L, 1L, 
1L, 1L, 5L, 5L, 5L, 1L, 1L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 5L, 5L, 1L, 1L, 1L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 5L, 1L, 1L, 1L, 
5L, 5L, 5L, 5L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 1L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 2L, 2L, 2L, 6L, 6L, 6L, 6L, 3L, 3L, 3L, 3L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 1L, 1L, 1L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 
6L, 5L, 6L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 1L, 
1L, 1L, 1L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 1L, 6L, 5L, 6L, 5L, 5L, 
5L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 
5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 
5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L), .Label = c("other deciduous tree", "other oak", 
"other plant", "other shrub", "Quercus petraea", "Quercus robur"
), class = "factor"), Tree_diameter = c(68.8, 10, 98.5, 97, 32.5, 
45.1, 847, 817, 569, 892, 57.3, 43.5, 120, 180, 74, 67, 69, 55, 
62, 71, 140, 111.4, 114.6, 167.1, 29, 46.5, 27.7, 40.1, 68, 45, 
60, 54, 104, 122, 85, 71, 81, 39.8, 43.6, 44.6, 22.6, 160, 156, 
20.1, 17.8, 15.6, 12.1, 37.3, 45.1, 42.8, 51.2, 48.1, 83.7, 77.9, 
80.2, 84.7, 81.8, 102.5, 75.5, 57.3, 0.3, 0.2, 0.3, 0.3, 70, 
36, 53, 44, 31.5, 27.1, 23.3, 22, 85, 69.4, 37.3, 82.9, 52.9, 
98.4, 64.6, 81.8, 19.9, 14.6, 196, 122, 118, 180, 58.6, 54.1, 
58, 61.5, 58.4, 40.6, 61, 68.6, 44.2, 45.2, 44.2, 117, 240, 210, 
310, 134, 64, 52.2, 32, 25, 22, 17, 57, 73.9, 37.1, 170, 114, 
127, 158, 147.4, 135.3, 122.9, 104.1, 263, 237, 322, 302, 175, 
182, 141, 155, 89, 41, 70, 83, 81.5, 29.3, 43.3, 141, 86.5, 82, 
114.5, 57, 42, 58, 64, 129, 127, 143, 125, 92, 68, 90, 24.5, 
20.1, 63.7, 39.8, 66.2, 112.4, 41.9, 43.8, 124.5, 94.1, 68.6, 
74.4, 23.6, 27.7, 22.9, 25.2, 59.2, 78, 79.3, 24.2, 54.7, 43, 
33.1, 56, 67, 62, 58, 306, 274, 56, 60, 72.5, 128.5, 22, 16, 
143, 103, 53, 130, 48.4, 69.8, 6.4, 18.6, 129.2, 41.7, 57.6, 
14, 75, 105, 44, 41.7, 30.2, 39.5, 24.2, 320, 352, 120.9, 108.3, 
53.2, 240, 274, 122, 85, 21, 52, 43, 38, 37, 219, 215, 216, 175, 
124, 133, 119, 39.2, 63, 94.9, 47.1, 126.6, 86.9, 94.7, 106.2, 
85.9, 49.7, 97.1, 55, 40.8, 79.3, 62.4, 62.4, 70, 115.9, 111.1, 
88.9, 80.3, 90.8, 36, 31, 37.5, 42.3, 73, 54, 75, 43, 50.3, 28.7, 
31.9, 159, 181.5, 149.7, 122, 143.6, 148, 145, 99, 47, 76.4, 
62.7, 49, 57.9, 54.8, 53.5, 88.8, 71.3, 101.9, 28, 32, 54, 54, 
169, 152, 160, 138, 90.8, 87.9, 77.4, 81.2, 91.7, 62.7, 50, 72.9, 
23.7, 58, 80.7, 73.7), Urbanisation_index = c(2L, 1L, 2L, 2L, 
2L, 2L, 2L, 2L, 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 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 
2L, 2L, 3L, 3L, 3L, 2L, 4L, 4L, 4L, 4L, 4L, 2L, 1L, 1L, 4L, 4L, 
2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 1L, 1L, 2L, 
1L, 1L, 1L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
2L), Canopy_Index = c(85L, 85L, 85L, 75L, 45L, 25L, 75L, 65L, 
65L, 75L, 65L, 15L, 75L, 85L, 85L, 45L, 45L, 65L, 75L, 75L, 95L, 
95L, 95L, 95L, 95L, 55L, 85L, 65L, 85L, 65L, 95L, 85L, 85L, 85L, 
75L, 75L, 65L, 85L, 85L, 85L, 85L, 65L, 35L, 75L, 75L, 85L, 65L, 
55L, 65L, 45L, 45L, 95L, 85L, 85L, 85L, 65L, 95L, 85L, 95L, 95L, 
75L, 75L, 85L, 85L, 85L, 85L, 85L, 75L, 85L, 85L, 85L, 85L, 45L, 
75L, 75L, 65L, 75L, 35L, 35L, 75L, 85L, 85L, 65L, 75L, 85L, 75L, 
95L, 95L, 95L, 95L, 75L, 75L, 65L, 65L, 85L, 95L, 95L, 35L, 75L, 
65L, 85L, 95L, 95L, 55L, 75L, 75L, 75L, 85L, 65L, 95L, 75L, 75L, 
65L, 75L, 65L, 85L, 95L, 95L, 75L, 95L, 75L, 95L, 65L, 75L, 75L, 
85L, 85L, 65L, 95L, 65L, 65L, 75L, 75L, 65L, 65L, 65L, 65L, 65L, 
35L, 65L, 75L, 35L, 85L, 85L, 75L, 95L, 85L, 85L, 75L, 45L, 55L, 
35L, 35L, 25L, 25L, 75L, 65L, 95L, 85L, 75L, 85L, 85L, 75L, 75L, 
65L, 95L, 95L, 95L, 75L, 85L, 65L, 45L, 75L, 35L, 65L, 95L, 95L, 
95L, 95L, 95L, 65L, 75L, 45L, 35L, 75L, 95L, 95L, 85L, 75L, 65L, 
85L, 95L, 75L, 85L, 85L, 95L, 95L, 95L, 55L, 65L, 65L, 45L, 65L, 
85L, 35L, 95L, 85L, 85L, 75L, 85L, 95L, 85L, 95L, 75L, 65L, 65L, 
65L, 65L, 55L, 75L, 85L, 85L, 85L, 85L, 55L, 25L, 55L, 65L, 35L, 
75L, 25L, 35L, 85L, 95L, 85L, 55L, 75L, 75L, 75L, 75L, 65L, 85L, 
75L, 65L, 85L, 55L, 95L, 95L, 95L, 95L, 45L, 55L, 35L, 65L, 45L, 
75L, 75L, 55L, 65L, 65L, 75L, 65L, 95L, 95L, 95L, 45L, 15L, 85L, 
65L, 95L, 95L, 45L, 65L, 45L, 55L, 85L, 65L, 75L, 75L, 75L, 65L, 
75L, 35L, 75L, 75L, 75L, 75L, 25L, 45L, 45L, 35L, 85L, 95L, 85L, 
95L), Phenological_Index = c(2L, 4L, 2L, 2L, 4L, 4L, 2L, 2L, 
2L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 4L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 
3L, 4L, 3L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 2L, 2L, 2L, 2L, 3L, 
1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 4L, 3L, 2L, 1L, 4L, 4L, 1L, 
1L, 1L, 1L, 1L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 1L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 
2L, 2L, 3L, 3L, 3L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 
4L, 4L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
3L, 3L, 3L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 2L, 3L, 3L, 
3L, 3L, 4L, 3L, 2L, 3L, 2L, 2L, 2L, 1L, 3L, 1L, 1L, 1L, 1L, 4L, 
2L, 4L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 3L, 3L, 2L, 
3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 3L, 1L, 3L, 4L, 3L, 3L, 
2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 
1L, 1L, 4L, 4L, 4L, 3L, 4L, 3L, 3L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 
2L, 3L, 3L, 4L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L)), class = "data.frame", row.names = c(NA, 
-295L))

I'm confused by this:

Are you setting wd to a file? You want a folder there


Are you aware that these may not be the same directories? Why don't you use the same path?

"~/Documents/Open University/S397 Terrestrial Ecosystems/TMA'S/TMA02/Data_TMA02_S397/Phenological_observations_1_S397_TMA02/Phenological_observations_1_S397_TMA02_2019.csv"
"~/Users/kirstymedcalf/Documents/Open University/S397 Terrestrial Ecosystems/TMA'S/TMA02/Data_TMA02_S397/Phenological_observations_1_S397_TMA02/Phenological_observations_1_S397_TMA02_2019.csv"

I feel like you have a problem with folders and need to figure out where your analysis is stored.
I'd also suggest using R Projects to avoid the whole setwd() getwd() business.


It also goes without saying that keeping two versions of RStudio if unnecessary at the very least. Why don't you kill the older version?


I'm sure you can clean it up manually. CSV is just a text file with data delimited by comas. You can open it in any text editor and see if you're missing any comas or have an unnecessary header or a footer...

Hi Tara,

Thank you for replying.

Both of those working directories go to the same folder (however, I will edit further), and the extra wording in the directory was achieved by changing or setting the working directory manually with R Studio. This suggestion came from a StackOverflow post. I was just trying different methodologies to try and open my .csv file stored in a particular documents file. I have already killed the other version of R-Studio. However, because I update my version of R and R Studio simultaneously, I did not realise I had two versions until afterwards. i thought I was just using the updated version already on my computer.

I have done all of the above and nothing works. I just mentioned that when R-Studio crashed, my .csv files were corrupted. Therefore, I have copied and pasted the data again onto a new excel datasheet, saved it in .csv format, and placed the new .csv files back into the same folder with the same file name in the working directory. I have cleaned up the .csv file many times manually. I was just wondering if there was any relationship between the corrupted files and my inability to open the .csv files.

I really don't understand how to fix these issues!

If you can help, I would be deeply appreciative

One thing I can't help you with is recovering your R script. If anyone else can help - great.


What I'm on a mission for is to help you fix the process moving forward.
I think we've established a couple of things already:

  • You don't need two versions of R or RStudio, I'd suggest delete the older one.
  • It is considered a bad habit to point to files they way you do it (and your issues prove the point). There are quite a few workarounds. I'd suggest taking 5 minutes of your time and reading this: Project-oriented workflow if you don't want @jennybryan to set your computer on fire :smiley:

What is left to figure out is what do you mean by "corrupted csv file"?

  • Can you open the same file in Excel? in Numbers? In any text editor? If so - your file isn't corrupted.
  • Can you use the RStudio add-in to import your csv file? You'll get a pop-up window that will help you locate the file and import it, and will generate the code for you. You'd be able to see if it is any different from your code.

32%20PM

Dear Tara

Thank you so much for your help

After R-Studio crashed, the layout panes have also changed. I have gone to Global options and tried to change them, but the environment, history, and Connections tab have disappeared!

I have already deleted the corrupted files a long time ago. I created new versions of the .csv files

The software is just acting strangely now.

Best wishes

Kirsty

It sounds strange.
Have you tried uninstalling both versions completely, restarting the machine, and installing a fresh version of RStudio?

Hi Tara,

I was just thinking along the same lines. The position of the third pane is blank and it says 'No outline available'.

There is nothing wrong with my working directory because it was opening my files completely find beforehand.

I will try that and get back to you. However, will I still be able to recover the missing work in the interim before I do anything drastic?

From my own perspective, and if I were you, I'd forget about recovering any lost work, and use it as a learning opportunity.
I mean, we're talking about hours of work, not weeks or months, right?

Weeks of work, and if it is somewhere on my computer, I'd like to attempt to recover it!

Good luck, and save/back up better next time :slight_smile:

Hi Tara,

Thank you so much for the tips, and I will try to find my work using your suggestions. Fingers crossed! I will let you know what happened in the morning - I live in Sri Lanka (2:02 am here).

This is the issue! Everytime I wrote a new piece of script, I ardently saved the work. What lesson is there to learn from this? Back-up and keep another copy of the script elsewhere for sure. I have learned that lesson here.

However, R-Studio crashed and my unsaved changes, which I definitely backed up every 20 minutes or so, did not save. Isn't that more of a software issue?

I'm still really confused as to why R-Studio crashed in the first place, and why my work did not save, and why my .csv files, which were open in R-Studio, were corrupted at the same time.
.
I have been using R-Studio for years, and I have never come across this issue before.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.