I like to create bunch of googleVis charts and one I create the charts, I like to create a different html files with custom names so that I can reference them in my front page with divs.
For example, I am doing this:
x <- gvisTable(mtcars)
writeLines(x, "cars.html")
I get this error:
Error in writeLines(x, "cars.html") : invalid 'text' argument
Ideas how would I address this problem?
I got the answer, I can simply to this and write it to any html file I like:
cat(x$html$chart, file="tmp.html")
Related
I have written a simple script to create some PowerPoint sheets based on an Excel dataset. For the original script see Picture1. I noticed that the code becomes very unreadable if you add to many objects to one PowerPoint sheet. That's why I wanted to write a function of this part of the code. One of the things I tried is shown in Picture 2 (I know this code won't work). The problem is that the function doesn't recognize ph_with. Is there anyway to solve this problem?
Thank you!
AddContent <- function(content, label, ...){
ph_with(value = content, location = ph_location_label(ph_label = label))}
AddContent(company_name, Customername)
Error in UseMethod("ph_with", value) : no applicable method for 'ph_with' applied to an object of class "rpptx"
[Picture 1 - original code][1]
[1]: https://i.stack.imgur.com/NYCmb.png
[Picture 2 - Function test][2]
[2]: https://i.stack.imgur.com/57zaX.png
[Picture 3 - Error message][3]
[3]: https://i.stack.imgur.com/TIBgr.png
When I try to generate the exams' solution with the exams2nops(...template="solution"...) I get the following error message:
Error in exams2pdf(file, n = n, nsamp = nsamp, dir = dir, name = name, :
formal argument "template" matched by multiple actual arguments
How can I produce an exams' solution with the exams2nops?
You cannot do that in one go, you need two runs after setting the same seed, e.g.,
set.seed(1)
exams2nops(my_exam)
set.seed(1)
exams2pdf(my_exam, template = "my_solution.tex")
You can use the solution.tex provided within the package as a starting point for my_solution.tex. But you may want to translate it to your natural language, use the name of your university, possibly insert a logo, add your actual exam name, possibly some into text etc. In exams2pdf() you need to add these things in the template LaTeX file directly.
won't the template="solution" not work in the exams2pdf? Also, can we do something like:
usepackage = "pdfpages", intro = intro2,... ?
I want to be able to take the normal output for an object and insert it into custom HTML components. Specifically, I want to allow things like putting several charts into an accordion UI element, or having hidden dataframes that are shown when a button is clicked. Is there a way to get the HTML that would normally be output, wrap it in my own HTML components, and then output that?
I have tried:
import IPython.display as dp
dp.display(dp.HTML('<div id="mycontainer">')) # Just a simple div,
# but ideally would be e.g. bootstrap component
dp.display(my_obj) # my_obj here could be a (potentially styled) dataframe
# or a plot from matplotlib/altair/etc.
dp.display(dp.HTML('</div>'))
However, the unclosed <div> just gets automatically closed, so my_obj doesn't get inserted into it. Some objects have _repr_html_(), but not all do (particularly charts). Still, Jupyter obviously has some way of extracting HTML from arbitrary objects.
It seems from trying to read the source that nbconvert is used to change the object to HTML, but I'm not sure if A) I'm understanding that right or B) how to get HTML from an arbitrary object that is not in a notebook node object (or how to construct such an object myself).
this seams to work for me :
from IPython.core.display import display, HTML
myString = 'Hello, world!'
prependHtmlTag = '<h1>'
appendHtmlTag = '</h1>'
display(HTML(prependHtmlTag + myString + appendHtmlTag )
just put any html formated string in the display(HTML([yourString]))
I am using R to extract HTML Tables from a website.
However, the language for the HTML Table is in Hindi and the text is displayed as unicodes.
Any way where I can set/install the font family and get the actual text instead of the unicode.
The code I follow is :
library('XML')
table<-readHTMLTable(<the html file>)
n.rows <- unlist(lapply(table, function(t) dim(t)[1]))
table[[which.max(n.rows)]]
The sample site is : http://mpbhuabhilekh.nic.in/bhunakshaweb/reports/mpror.jsp?base=wz/CP8M/wj/DP8I/wz/CoA==&vsrno=26-03-02-00049-082&year=2013&plotno=71
The output comes as :
"< U+092A>"
etc.
Note:For some reason, the readHTMLTable works only when I remove the first two unwanted tables in the HTML file. So if you have to test with the file, please edit out the first two tables or simply delete the first two table headers from the file.
Any help will be appreciated. Thanks
update:
The issue seems to be related to locale set in R on windows OS Machines. Unable to figure out how to get it working though!
The solution I have found for this locale related bug would be to callthe corresponding encoding..
library('XML')
table<-readHTMLTable(<the html file>)
n.rows <- unlist(lapply(table, function(t) dim(t)[1]))
output <- table[[which.max(n.rows)]]
for (n in names(output)) Encoding(levels(output[[n]])) <-"UTF-16"
The output in R console might still look gibberish, but the advantage is that once you export the dataset (say a csv), it would all appear in Hindi on other editors.
I am trying to use the xlsx package to fill a spreadsheet with information from an external file. Up until now, I have used addDataFrame() to put information into the spreadsheet, and everything about it that I have tried has been successful (fonts, colors, borders, etc.)
The issue now is that I need to have a column of hyperlinks, and to do that I need to get or create the specific cells (I'm not sure which, and both give the same error). The following code:
library(xlsx)
wb = createWorkbook(type="xlsx")
sheet = createSheet(wb, sheetName="InProduction")
createCell(1, 2)
Produces the error:
Error in .jcall(row[[ir]], "Lorg/apache/poi/ss/usermodel/Cell;",
"createCell", : RcallMethod: cannot determine object class
After doing some poking around, I found the method it is trying to call is from this API with the call:
minColIx <- .jcall(row[[ir]], "T", "getFirstCellNum")
Which seems to me like it ought to work, but it clearly doesn't. Can anyone shed some light on this?
Thanks in advance!
You need to create rows using createRow or getRows before you can create cells in these rows using createCells.