Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_dta leads to R crashing #37

Closed
fhollenbach opened this issue Mar 5, 2015 · 7 comments
Closed

write_dta leads to R crashing #37

fhollenbach opened this issue Mar 5, 2015 · 7 comments

Comments

@fhollenbach
Copy link

@fhollenbach fhollenbach commented Mar 5, 2015

Created a data frame using simulated data and tried to save it as a dta file, this led R to crash with segfault error. Using R version 3.1.2 on a Mac with OSX 10.10.2.

Example code:

library(haven)
library(plyr)

set.seed(12345)
N=300
var1 = rnorm(N,0,1.5)
var2 = rnorm(N,2,5)
var3 = runif(N,-10,10)

dataForStata = data.frame(var1,var2,var3)
names(dataForStata) = c("var1","var2","var3")
write_dta(dataForStata,path="~/Desktop/")

Running the code produces the following error:

> write_dta(dataForStata,path="~/Desktop/")

 *** caught segfault ***
address 0x68, cause 'memory not mapped'

Traceback:
 1: .Call("haven_write_dta", PACKAGE = "haven", data, path)
 2: write_dta(dataForStata, path = "~/Desktop/")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

R session info:

sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin14.0.0 (64-bit)

locale:
[1] en_US/en_US/en_US/C/en_US/en_US

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plyr_1.8.1       haven_0.1.1.9000

loaded via a namespace (and not attached):
[1] Rcpp_0.11.4
@afleishman
Copy link

@afleishman afleishman commented Mar 5, 2015

You need to specify the file name... change your last line of code to

write_dta(dataForStata,path="~/Desktop/dataForStata.dta")

@fhollenbach
Copy link
Author

@fhollenbach fhollenbach commented Mar 5, 2015

That doesn't solve the issue, the same thing happens. The help file does ask for a path, not filename.

@afleishman
Copy link

@afleishman afleishman commented Mar 5, 2015

weird, worked for me when I specified file name. I'm on a Windows machine though.

@fhollenbach
Copy link
Author

@fhollenbach fhollenbach commented Mar 5, 2015

Ha, I just figured it out. You were correct, but the path also cannot be specified with "~" in it.
So "write_dta(dataForStata,path="/Users/fhollenbach/Desktop/dataForStata.dta")" works on the Mac.
Thanks! I am closing the issue for now?

@fhollenbach fhollenbach closed this Mar 5, 2015
@afleishman
Copy link

@afleishman afleishman commented Mar 5, 2015

Glad it worked out :). I had a similar issue on Ubuntu... I forgot the first '/' at the beginning of the path and it was crashing every time I'd run the code.

@hadley hadley reopened this Mar 5, 2015
@hadley
Copy link
Member

@hadley hadley commented Mar 5, 2015

It shouldn't crash on a malformed path

@rubenarslan
Copy link
Contributor

@rubenarslan rubenarslan commented Mar 20, 2015

Can confirm this goes away in write_sav when switching from tilde expansion to full path (OS X).

hadley added a commit that referenced this issue Apr 7, 2015
@hadley hadley closed this in 3876493 Apr 7, 2015
@lock lock bot locked and limited conversation to collaborators Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants