Using knitr with GIS data [closed] - r

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm attempting to create a presentation about loading/using shapefiles in R using the knitr package. The issue I'm encountering is that when I include standard # notation in my .Rnw file, as in ND#data, R reads that as the end of the code chunk meaning a bunch of my code doesn't get read in properly.
Here is a fuller example of my .Rnw file (data available from the North Dakota GIS portal http://www.nd.gov/gis/apps/HubExplorer/).
\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{graphicx}
\begin{document}
<<Loading Datasets>>=
install.packages("rgdal")
library(rgdal)
ND <-readOGR(dsn="C:/Users/.../NDGISHubData",
layer="NDHUB_STATE_polygon")
head(ND#data)
ND#proj4string
plot(ND)
#
\end{document}
Is there a way to have R correctly recognize the # symbol in my code chunk as part of the code and not as the end of the R code chunk?

Related

Error when trying to use ggmap::get_map ( JPEG decompression error: Not a JPEG file: starts with 0x89 0x50) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am trying to set up a map from ggmap.I have borrowed this line from another script but it is not working for me. I want to specify the boundary of the map.
myLocation <- c( -133.50734, 26.07781, -60.49268, 47.77387)
myMap <- ggmap::get_map(location=myLocation, source="stamen", maptype="terrain", crop=TRUE)
The map should show the US boundary, but it throws the following error when trying to run it:
Map from URL : http://tile.stamen.com/terrain/5/4/11.jpg
Error in readJPEG(tmp) :
JPEG decompression error: Not a JPEG file: starts with 0x89 0x50
Any comment on how to fix the issue?

Importing an excel file in RStudio [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Actually, I'm having trouble with importing a CSV file in my script in Rstudio. I am trying:
d <- read.table(file="table1.csv",sep="\t",header=T)
but it says that there is an error in file and "rt".
Type 'getwd()' in the console. If what returns isn't the same path as the file you're trying to read in, change this with setwd("[your filepath here]"). If you want a graphical solution instead, you can use the Set As / Go To Working Directory commands under the 'More' menu in RStudio's Files viewer (bottom right window).
Then try d <- read.csv("table1.csv")

"there is no package called 'xlsx'": having trouble reading .xlsx file [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
Looking to read in an .xlsx file. This is an assignment so I specifically can't use Excel first to convert it to .csv.
Tried using read.xlsx which couldn't be found so I tried 'library(xlsx)' which was not a package according to R.
Does anyone know if there's something glaringly obvious that I'm not doing? Is the package called something different? Is there a different/better way to read an xlsx file?
Thanks!

Not able to install packages in R with install.packages() [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have installed R Version 3.0.2. I am trying to run association analysis on a dataset.
While trying to install the arules package, using the code:
install.packages(“arules”)
I get and error:
Error: unexpected input in "install.packages(“arules")
Can you guide as to how I can install this package and use it to run association on an imported txt file using R?
You appear to be using "smartquotes" instead of straight quotes like " around arules. R cannot recognize these. Change to straight quotes and everything should work.

Frame around R code and output in knitr and Latex [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am using knitr and Latex to write an intro into and overview of R. How can I get a box around R code chunks and R output in Latex? I can get them when using R Markdown and knitr to generate HTML. The Sweave way to frame chunks with a box does not work with knitr.
Thanks and regards,
Andreas

Resources