blogdown::new_post not working with date="" - r

The function blogdown::new_post() recently stopped working for me with the parameter date="".
here's the line of code:
blogdown:::new_post("home", kind = "default-frontpage", open=F, date="", subdir="", ext = ".Rmd")
it gives this error:
Error in if (tryCatch(date > Sys.Date(), error = function(e) FALSE)) warning("The date of the post is in the future: ", :
missing value where TRUE/FALSE needed
Someone else who works in the lab has tried to reproduce this error on their computer, but wasn't able to. All of my R packages are up to date, according to RStudio.
When I call Sys.Date(), it returns today's date as: "2020-11-29"
I can specify a date in new_post(), but it would require re-writing a substantial amount of our code, and it seems like this changes the automatically generated title of the post.
Could anyone suggest a next step?
Thanks a bunch!
Caleb

I just fixed this issue on Github, and you may try
remotes::install_github('rstudio/blogdown')
Thanks for the report!

Related

Is there an issue with raster::writeRaster writing raster stacks in R4.2?

I am using some older code to write a raster stack with bylayer = T and I havent bothered to migrate it to terra yet so I am still using raster. This used to work fine:
raster::writeRaster(stack(rastList3), names(rastList3), bylayer = T, overwrite = TRUE, format = "GTiff")
Now it throws the hard to decipher error:
"Error in if (tolower(e) %in% c(".tiff", ".tif")) { :
the condition has length > 1"
Replies to similar error message here suggest it seems to have to do with R 4.2 but I am not fully sure that is what is happening. I can get it to write one layer at a time using
dsn <- here("Clipped_ENVData/Mask2022//")
nameT = paste(dsn, names(rastList3), ".tiff", sep = "")
writeRaster(rastList3[[3]], nameT[[3]], overwrite = TRUE)
but it wont write bylayer from the stack of 10 rasters :(
Does anyone know if there is a workaround in the writeRaster function that needs to be fixed or is it something broken in my code?
That is a bug. It goes away if you update the "raster" package to version 3.6-5. That is currently the development version. You can install that version with
install.packages('raster', repos='https://rspatial.r-universe.dev')
OH-KAY. I also found the answer to this post here which helped me work out my solution:
lapply(rastList3, function(x) writeRaster(x, filename=paste0(dsn,names(x)), format="GTiff", overwrite = TRUE))
While updating to a development version might fix the bug, I was hesitant as it possibly could create more headaches in other places.

Create CYT object in CytoTree in R

I want to create a CytoTree CYT object in R to analyse my .FCS files. When I am using the Quick start code in the package description, I will always get an error when running the createCYT() function that says:
Error in createCYT(raw.data = fcs.data, normalization.method = "log") :
2022-09-26 15:46:26 meta.data must be a data.frame
As the function should not rely on any meta data and that object is optional, I do not know how to solve the error.
Here is the description:
https://ytdai.github.io/CytoTree/quick-start.html#quick-start-code
I thank you very much in advance for your help!
BR
I have encountered same problem previously.
In the end it worked only when the data.frame was added (yes, even though it should not depend on it).
Here is how:
meta.data <- data.frame(cell = rownames(fcs.data), stage = gsub(".fcs.+", "", rownames(fcs.data)))
meta.data$stage <- factor(as.character(meta.data$stage))
You may as well have a look at the Cytotree PDF in case of more issues.

Error in Sys.sleep(reset + 2) : invalid 'time' value

I am currently trying to download data using the search_tweets command from the rtweet package. I have a list of over 400 requests that I want to loop it over. The code seems to run without problems, yet, after a while this happens:
retry on rate limit...
waiting about 16 minutes... #which it then counts down#
Error in Sys.sleep(reset + 2) : invalid 'time' value
Searching for related questions, I only found this: https://github.com/ropensci/rtweet/issues/277. There they say that in the latest rtweet version this issue has been solved. But I am using the latest R and rtweet versions.
Has someone experienced a similar issue? And how have you been able to solve it?
This is the code I am using. Please don't hesitate to tell me if it is a mistake in the code that causes the problem. I was wondering e.g. if it is possible to include a condition that only runs the next request as soon as the first request is fully downloaded?
for (x in 1:length(mdbs)) {
mdbName = mdbs[x]
print(mdbName)
myMDBSearch = paste0(mdbName,"lang:de -filter:retweets")
print(myMDBSearch)
req <- search_tweets(
q = myMDBSearch,
n = 100000,
retryonratelimit = TRUE,
token = bearer_token(),
parse=TRUE
)
data_total <- rbind(data_total,req)
print("sleeping 5 seconds")
Sys.sleep(5)
}

R shiny: validate(need()) with dateRangeInput

I've read the help pages and shiny webpages on validate() and need() 10 times, googled all variations I could think of, but I simply cannot find what is wrong with my code.
The only thing I require is for my app to show a custom error instead of the (empty) plot when a user inputs a wrong date range = 2nd date earlier than the 1st.
output$plotTemp <- renderPlot({
req(input$button)
validate(need(input$datums[1] < input$datums[2], "error: end date earlier than start"))
isolate({buttonFeedbackServer("button", { # if validate = ok, run functions
importdata(input$jaartal)
weerstation <- which(weerstations == input$weerstation)
temperatuur(input$datums, weerstation) # create plot
})
})
})
I get this error now: no applicable method for 'validate' applied to an object of class "NULL"
I bet it's gonna be something stupid, but I spent hours and hours on this without seeing it...
Without validate() everything works perfect, so it's no mistake in other code.
My R, Rstudio and all packages have been updated last week.
Other packages, including jsonlite have a validate function. This error can occur when you accidentally are using a validate function from a different package. Try using shiny::validate instead to make sure you are using the correct validate.

DataTable warning table ajax error for some people but not all with shiny

I recieved such error when, in created shiny app in R with DataTables packages in my mobile and one laptop. However, it didn't throw error with other laptops, Same code was working yesterday, and day before yesterday. I haven't changed code, but it is throwing error.
Why there is problem with some devices but not all devices. I used other devices, those devices are not throwing error.
Any idea how to fix this problem? The solution for this problem should be explained here http://datatables.net/manual/tech-notes/7
What is issue ?
Following is thrown error as follows:
DataTables warning: table id=DataTables_Table_0 - Ajax error. For more
information about this error, please see http://datatables.net/tn/7
I am also suffering. Please take a look at the discussion of this issue #269 on Github.
It seems to be a problem post version 0.1 where you need to "flatten" variables using as.numeric.
ISSUE
Example and solution given by XD-DENG was and to quote them:
"The error is gone when I use
temp <- tapply(iris$Sepal.Length, iris$Species, mean)
result <- data.frame(species = names(temp),
mean = as.numeric(temp))
return(result)
instead of:
temp <- tapply(iris$Sepal.Length, iris$Species, mean)
result <- data.frame(species = names(temp),
mean = temp)
return(result)
The main difference is whether the column mean has additional attribution, dimension. This is what caused the error.
But it's still weird given version 0.1 of DT works perfectly on both."
PATCH
#yihui has pushed a fix for this to the dev version so please try update your DT package. (You can use package devtools to install from github devtools::install_github('rstudio/DT'))
I hope this fixes this intermittent error.
I just explicitly made as.numeric() to all numeric columns within my data.frame (though they are already numeric when I do str()) and the problem is gone.

Resources