Created
April 1, 2023 12:33
-
-
Save jeroen/a7b1de85f9de9478e1eb43dd629b46b0 to your computer and use it in GitHub Desktop.
webr export csv file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Hello World! Site Title</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script> | |
<script> | |
import('https://webr.r-wasm.org/latest/webr.mjs').then(function(x){ | |
const webR = new x.WebR(); | |
return webR.init().then(function(){ | |
return webR.evalR('write.csv(iris, "iris.csv")').then(function(result){ | |
return webR.FS.readFile("iris.csv").then(function(bytes){ | |
var blob = new Blob([bytes], {type: "text/csv"}); | |
return saveAs(blob, "iris.csv"); | |
}); | |
}); | |
}); | |
} | |
).catch(function(err){ | |
alert("ERROR: " + err); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment