trying to Upload .rmd file to wordpress - html

I'm having trouble uploading .rmd file to wordpress. I'm not exactly sure what's going on but the error suggests I don't have privileges to remotely publish to wordpress even though from what I understand Wordpress allows remote publishing even for free accounts. I've searched all the wordpress R queries on stack overflow and nothing seems to work. Here's my work flow:
devtools:::install_github("duncantl/RWordPress", force=T)
library(RWordPress)
# Set login parameters (replace admin,password and blog_url!)
options(WordPressLogin = c(admin = 'password'), WordPressURL = 'blog_url/xmlrpc.php')
library(markdown)
library(knitr)
options(markdown.HTML.options = c(markdownHTMLOptions(default = T),"toc"))
# Upload plots: set knitr options
opts_knit$set(upload.fun = function(file){library(RWordPress);uploadFile(file)$url;})
postThumbnail <- RWordPress::uploadFile("File.rmd",overwrite = TRUE)
That produces the following error:
Error: faultCode: 401 faultString: You do not have permission to upload files.
I also tried the following:
knit2wp('fake.rmd', title = 'TITLE', publish = FALSE)
And that produces the same error.
Here's my session info:
sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.5 (El Capitan)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] ggplot2_2.1.0 rmarkdown_1.0 knitr_1.13
[4] markdown_0.7.7 RWordPress_0.2-3
loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 formatR_1.4
[3] plyr_1.8.3 bitops_1.0-6
[5] base64enc_0.1-3 tools_3.3.0
[7] digest_0.6.10 jsonlite_1.0
[9] evaluate_0.9 tibble_1.1
[11] gtable_0.2.0 viridisLite_0.1.3
[13] lattice_0.20-33 png_0.1-7
[15] DBI_0.4-1 mapproj_1.2-4
[17] proto_0.3-10 gridExtra_2.2.1
[19] dplyr_0.5.0 httr_1.2.1
[21] stringr_1.0.0 caTools_1.17.1
[23] RgoogleMaps_1.2.0.7 htmlwidgets_0.7
[25] maps_3.1.0 grid_3.3.0
[27] R6_2.1.2 jpeg_0.1-8
[29] plotly_4.1.0 XML_3.98-1.4
[31] RSelenium_1.4.2 RJSONIO_1.3-0
[33] sp_1.2-3 ggmap_2.6.1
[35] tidyr_0.5.1 reshape2_1.4.1
[37] magrittr_1.5 XMLRPC_0.3-0
[39] scales_0.4.0 htmltools_0.3.5
[41] assertthat_0.1 formattable_0.2
[43] colorspace_1.2-6 geosphere_1.5-1
[45] labeling_0.3 stringi_1.0-1
[47] RCurl_1.95-4.8 lazyeval_0.2.0
[49] munsell_0.4.3 rjson_0.2.15
I'd also like to note, I checked the password and username and they're both correct (if I enter incorrect information I get a different error indicating that). I've also gotten a similar error trying user written functions:
Error: faultCode: 401 faultString: Sorry, you are not allowed to publish posts on this site.
By the way, when I run getUsersBlogs() I get:
$isAdmin
[1] TRUE
$isPrimary
[1] TRUE
$url
[1] "https://blogname.wordpress.com/"
$blogid
[1] "115210981"
$blogName
[1] "Site Title"
$xmlrpc
[1] "https://blogname.wordpress.com/xmlrpc.php"

As implied by #Lloyd Christmas, the problem is with your specification of options. If you change "WordPressURL" to "WordpressURL", you'll probably be fine.

Related

Incorporating Sliders into a Leaflet Map

I was following this tutorial here (https://rstudio.github.io/crosstalk/) and tried to run the code:
library(crosstalk)
library(leaflet)
library(DT)
# Wrap data frame in SharedData
sd <- SharedData$new(quakes[sample(nrow(quakes), 100),])
# Create a filter input
filter_slider("mag", "Magnitude", sd, column=~mag, step=0.1, width=250)
# Use SharedData like a dataframe with Crosstalk-enabled widgets
map = bscols(
leaflet(sd) %>% addTiles() %>% addMarkers(),
datatable(sd, extensions="Scroller", style="bootstrap", class="compact", width="100%",
options=list(deferRender=TRUE, scrollY=300, scroller=TRUE))
)
The map seems to render, but the "interactive slider" does not appear:
Also, I can not seem to save this map:
library(htmlwidgets)
saveWidget(map, "map.html", selfcontained = F, libdir = "lib")
Error in .getNamespace(pkg) :
invalid type/length (symbol/0) in vector allocation
I heard that the slider might require installing some further add-ons, but I have not been able to find out how to do this.
Does anyone know what I can do to resolve this problem?
Thank you!
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.23 leaflet_2.1.1 crosstalk_1.2.0
loaded via a namespace (and not attached):
[1] jquerylib_0.1.4 pillar_1.7.0 compiler_4.1.3 bslib_0.3.1 tools_4.1.3 digest_0.6.29 lubridate_1.8.0
[8] jsonlite_1.8.0 lifecycle_1.0.1 tibble_3.1.6 pkgconfig_2.0.3 rlang_1.0.2 cli_3.3.0 DBI_1.1.2
[15] yaml_2.3.5 xfun_0.30 fastmap_1.1.0 dplyr_1.0.9 stringr_1.4.0 generics_0.1.3 vctrs_0.4.1
[22] htmlwidgets_1.5.4 sass_0.4.1 hms_1.1.1 tidyselect_1.1.2 glue_1.6.2 R6_2.5.1 fansi_1.0.3
[29] purrr_0.3.4 tidyr_1.2.0 readr_2.1.2 tzdb_0.3.0 magrittr_2.0.2 ellipsis_0.3.2 htmltools_0.5.2
[36] assertthat_0.2.1 utf8_1.2.2 tinytex_0.40 stringi_1.7.6 lazyeval_0.2.2 crayon_1.5.1

Shiny not displaying table with HTML/JSON error message

I'm trying to put together a simply shiny app that will send a search request, return a data frame and display it in the UI. When I run the app, everything appears to be functioning correctly at first but when I run a query I get an html/json error.
Here is the code:
ui <- fluidPage(
# Application title
titlePanel("My App"),
sidebarLayout(
sidebarPanel(
textInput('dataset_name',
'Dataset:',
placeholder = 'Name')
,
br(),
actionButton("button", "Search"),
),
mainPanel(
tableOutput('userTable')
),
position = c("left"),
fluid=FALSE
)
)
server <- function(input, output) {
ut.df <- eventReactive(input$button, {
ds <- dataSearch(input$datset_name)
return(ds)
})
output$userTable <- renderTable({ut.df()})
}
dataSearch is the function I've created to send the input$dataset_name value to an api call and return a dataframe of the results. I've tested the function and it parses the response JSON and returns the dataframe without issue.
When I run the shiny app the page loads with no problem but when I submit a query, instead of rendering the data frame as a table I get:
Warning: Error in : lexical error: invalid char in json text.
<!DOCTYPE HTML PUBLIC "-//W3C//
(right here) ------^
Can anyone explain why the table is not being rendered and why shiny seems to think the html code is a json file?
Session info:
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.20 jsonlite_1.7.2 httr_1.4.2 shiny_1.7.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 jquerylib_0.1.4 bslib_0.3.1 compiler_4.1.2
[5] pillar_1.6.4 later_1.3.0 neo4r_0.1.1 tools_4.1.2
[9] digest_0.6.28 lattice_0.20-45 lifecycle_1.0.1 tibble_3.1.6
[13] png_0.1-7 pkgconfig_2.0.3 rlang_0.4.12 Matrix_1.3-4
[17] cli_3.1.0 rstudioapi_0.13 crosstalk_1.2.0 yaml_2.2.1
[21] curl_4.3.2 fastmap_1.1.0 withr_2.4.2 dplyr_1.0.7
[25] htmlwidgets_1.5.4 sass_0.4.0 rappdirs_0.3.3 generics_0.1.1
[29] vctrs_0.3.8 rprojroot_2.0.2 grid_4.1.2 attempt_0.3.1
[33] tidyselect_1.1.1 fontawesome_0.2.2 here_1.0.1 reticulate_1.22
[37] glue_1.5.0 data.table_1.14.2 R6_2.5.1 fansi_0.5.0
[41] purrr_0.3.4 tidyr_1.1.4 magrittr_2.0.1 promises_1.2.0.1
[45] ellipsis_0.3.2 htmltools_0.5.2 mime_0.12 xtable_1.8-4
[49] httpuv_1.6.3 utf8_1.2.2 cachem_1.0.6 crayon_1.4.2
This error means that the document you're trying to read with {jsonlite} is not a JSON file, but an HTML file.
For example, you can reproduce this error with:
> jsonlite::read_json("https://google.com")
Error in parse_con(txt, bigint_as_char) :
lexical error: invalid char in json text.
<!DOCTYPE html><html lang="fr"
(right here) ------^
So you need to make sure that the JSON you're reading is correct.
Colin

Plotting functions in Julia suddenly doesn't work

Yesterday I was playing with Julia, plotting various different functions and variables. And suddenly a very important feature stopped working. I cant plot a function with a simple "plot(f)" command. I would love some help, because this features simplifies my work greatly.
I tried to recompile the packages I used, yet it didn't help any.
I need to plot distributions and also my own functions (one variable).
I'm using packages Distributions.jl and StatsPlots.jl
There's a simple example that I know did work - but now it doesn't:
using Distributions
using StatsPlots
f(x) = x^2
plot(f)
It gives me this error:
ERROR: MethodError: no method matching Float64(::Array{Float64,1})
Closest candidates are:
Float64(::Int8) at float.jl:60
Float64(::Int16) at float.jl:60
Float64(::Int32) at float.jl:60
...
Stacktrace:
[1] (::getfield(Plots, Symbol("##108#109")){Symbol})(::Array{Float64,1}) at C:\Users\masen\.julia\packages\Plots\47Tik\src\axes.jl:152
[2] _broadcast_getindex at .\broadcast.jl:578 [inlined]
[3] (::getfield(Base.Broadcast, Symbol("##19#20")){Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple},Nothing,getfield(Plots, Symbol("##108#109")){Symbol},Tuple{Tuple{Array{Float64,1},Array{Float64,1}}}}})(::Int64) at .\broadcast.jl:953
[4] ntuple at .\tuple.jl:160 [inlined]
[5] copy at .\broadcast.jl:953 [inlined]
[6] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple},Nothing,getfield(Plots, Symbol("##108#109")){Symbol},Tuple{Tuple{Array{Float64,1},Array{Float64,1}}}}) at .\broadcast.jl:753
[7] _scaled_adapted_grid(::Function, ::Symbol, ::Symbol, ::Float64, ::Float64) at C:\Users\masen\.julia\packages\Plots\47Tik\src\series.jl:542
[8] macro expansion at C:\Users\masen\.julia\packages\Plots\47Tik\src\series.jl:529 [inlined]
[9] apply_recipe(::Dict{Symbol,Any}, ::Function, ::Float64, ::Float64) at C:\Users\masen\.julia\packages\RecipesBase\zBoFG\src\RecipesBase.jl:275
[10] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{typeof(f)}) at C:\Users\masen\.julia\packages\Plots\47Tik\src\pipeline.jl:83
[11] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{typeof(f)}) at C:\Users\masen\.julia\packages\Plots\47Tik\src\plot.jl:178
[12] #plot#137(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function) at C:\Users\masen\.julia\packages\Plots\47Tik\src\plot.jl:57
[13] plot(::Function) at C:\Users\masen\.julia\packages\Plots\47Tik\src\plot.jl:51
[14] top-level scope at none:0

JuliaPro: Error when trying: Pkg.add("DataFrames")

When I try to install the package DataFrames it results in an error.
How can I get DataFrames installed?
I am using Julia Pro v1.0.2.1, Atom, Windows 10.
I have tried typing: Pkg.add("DataFrames") in the REPL.
I have tried to restart or turn off/turn on PC and retry.
In the JuliaPro folder in my C-drive there is a folder named "DataFrames".
julia> Pkg.add("DataFrames")
Resolving package versions...
ERROR: Unsatisfiable requirements detected for package ForwardDiff [f6369f11]:
ForwardDiff [f6369f11] log:
├─possible versions are: [0.0.2-0.0.3, 0.1.0-0.1.8, 0.2.0-0.2.5, 0.3.0-0.3.5, 0.4.0-0.4.2, 0.5.0, 0.6.0, 0.7.0-0.7.5, 0.8.0-0.8.5, 0.9.0, 0.10.0-0.10.3] or uninstalled
├─restricted by compatibility requirements with JuMP [4076af6c] to versions: [0.5.0, 0.6.0, 0.7.0-0.7.5, 0.8.0-0.8.5, 0.9.0]
│ └─JuMP [4076af6c] log:
│ ├─possible versions are: [0.1.1-0.1.2, 0.2.0, 0.3.0-0.3.2, 0.4.0-0.4.1, 0.5.0-0.5.8, 0.6.0-0.6.3, 0.7.0-0.7.4, 0.8.0, 0.9.0-0.9.3, 0.10.0-0.10.3, 0.11.0-0.11.3, 0.12.0-0.12.2, 0.13.0-0.13.2, 0.14.0-0.14.2, 0.15.0-0.15.1, 0.16.0-0.16.2, 0.17.0-0.17.1, 0.18.0-0.18.5, 0.19.0] or uninstalled
│ └─restricted to versions 0.18.5 by an explicit requirement, leaving only versions 0.18.5
├─restricted by julia compatibility requirements to versions: [0.9.0, 0.10.0-0.10.3] or uninstalled, leaving only versions: 0.9.0 └─restricted by compatibility requirements with DiffRules [b552c78f] to versions: [0.0.2-0.0.3, 0.1.0-0.1.8, 0.2.0-0.2.5, 0.3.0-0.3.5, 0.4.0-0.4.2, 0.5.0, 0.6.0, 0.7.0-0.7.1, 0.10.0-0.10.3] or uninstalled — no versions left
└─DiffRules [b552c78f] log:
├─possible versions are: 0.0.1-0.0.10 or uninstalled
└─restricted by julia compatibility requirements to versions: 0.0.8-0.0.10 or uninstalled
Stacktrace:
[1] #propagate_constraints!#61(::Bool, ::Function, ::Pkg.GraphType.Graph, ::Set{Int64}) at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\GraphType.jl:1005
[2] propagate_constraints! at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\GraphType.jl:946 [inlined] [3] #simplify_graph!#121(::Bool, ::Function, ::Pkg.GraphType.Graph, ::Set{Int64}) at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\GraphType.jl:1460
[4] simplify_graph! at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\GraphType.jl:1460 [inlined] (repeats 2 times)
[5] macro expansion at .\logging.jl:317 [inlined]
[6] resolve_versions!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Nothing) at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:354
[7] resolve_versions! at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:317 [inlined]
[8] #add_or_develop#62(::Array{Base.UUID,1}, ::Symbol, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:1223
[9] #add_or_develop at .\none:0 [inlined]
[10] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\API.jl:64
[11] #add_or_develop at .\none:0 [inlined]
[12] #add_or_develop#12 at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\API.jl:29 [inlined]
[13] #add_or_develop at .\none:0 [inlined]
[14] #add_or_develop#11 at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\API.jl:28 [inlined]
[15] #add_or_develop at .\none:0 [inlined]
[16] #add_or_develop#10 at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\API.jl:27 [inlined]
[17] #add_or_develop at .\none:0 [inlined]
[18] #add#18 at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\API.jl:69 [inlined]
[19] add(::String) at C:\Users\julia\AppData\Local\Julia-1.0.2\share\julia\stdlib\v1.0\Pkg\src\API.jl:69
[20] top-level scope at none:0
I would like the DataFrames package installed.
Eventually I installed Julia and Atom seperatly. Using this setup instead of JuliaPro is as blessing :-)

Format JSON data using tidyjson

I would love to use the tidyjson package as it seems to have very clear instructions on how to use it.
However, I am having a few issues. Could you please help check and let me know if these are user issues or something else.
I am using the world_bank.json data downloaded from http://jsonstudio.com/resources/
worldbank <- fromJSON(file = "world_bank.json")
I do see that a list of 50 in Rstudio. However, when I try to use read_json, I get the below error.
> read_json(worldbank, format = "json")
Error in file.info(path) : invalid filename argument
> worldbank[[1]] %>% prettify
Error: parse error: trailing garbage
52b213b38594d8a2be17c780
(right here) ------^
Use jsonlite::stream_in as lizzy suggested with stream unzip:
> download.file("http://jsonstudio.com/wp-content/uploads/2014/02/world_bank.zip", "world_bank.zip")
> world_bank <- jsonlite::stream_in(unz("world_bank.zip", "world_bank.json"))
> names(world_bank)
[1] "_id" "approvalfy" "board_approval_month"
[4] "boardapprovaldate" "borrower" "closingdate"
[7] "country_namecode" "countrycode" "countryname"
[10] "countryshortname" "docty" "envassesmentcategorycode"
[13] "grantamt" "ibrdcommamt" "id"
[16] "idacommamt" "impagency" "lendinginstr"
[19] "lendinginstrtype" "lendprojectcost" "majorsector_percent"
[22] "mjsector_namecode" "mjtheme" "mjtheme_namecode"
[25] "mjthemecode" "prodline" "prodlinetext"
[28] "productlinetype" "project_abstract" "project_name"
[31] "projectdocs" "projectfinancialtype" "projectstatusdisplay"
[34] "regionname" "sector" "sector1"
[37] "sector2" "sector3" "sector4"
[40] "sector_namecode" "sectorcode" "source"
[43] "status" "supplementprojectflg" "theme1"
[46] "theme_namecode" "themecode" "totalamt"
[49] "totalcommamt" "url"