I was using rstudio cloud for a project. I ran out of hours so I downloaded all the files of the project and opened them in rstudio desktop.
I have an .Rmd with a chunk that includes foo <- read.csv('foo.csv')
. I then set a variable to a column of the data, bar=foo$bar
. In the actual .csv, this column includes mostly numbers with a few '?' characters. I first remove these rows entirely. Looking at typeof(bar)
in rstudio cloud shows that bar
is of type character. Running as.numeric(bar)
successfully converts it to type double.
Running this exact same file using the exact same .csv in my rstudio desktop reports that bar
is of type integer, even before I remove the rows with '?' characters in the column. Running as.numeric(bar)
now (after removing question marks) returns with a seemingly random list of values that are in no way related to the original values.
I am very confused how this is possible, as virtually everything in the environments is the same including the source and data files. I have the most up to date versions of all packages on my desktop version (testing before updating packages showed the same results on desktop).
I have a slight suspicion CRLF/LF conversion is involved. My local os is Windows 10, could the cloud server be linux?
How could this be happening and how can I fix this?