[R-pkg-devel] nparACT package: "working directory was changed to...resetting"

2017-12-19 Thread Blume Christine
Dear Community,



For Fedora my package now gives a warning message when running the example:



"Warning: working directory was changed to 
'/data/gannet/ripley/R/packages/tests-clang/nparACT.Rcheck/sleepstudy_example', 
resetting"



I do not really know how to approach/solve this, what has recently been changed 
in R devel so this error message started appearing?



The full message can be seen here: 
https://CRAN.R-project.org/web/checks/check_results_nparACT.html



Any help is appreciated and rewarded with gratitude.



Best,



Christine



[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] nparACT package: "working directory was changed to...resetting"

2017-12-19 Thread Blume Christine
Hi Duncan,



Thanks a lot! Good to see that you had a similar idea, I did just that...in my 
example it looks like this, however, that does not help, i.e. that is the code 
that is associated with the warning…



data(sleepstudy)

wd <- getwd()

name <- "sleepstudy_example"

newdir <- paste(wd,name, sep="/")

if (dir.exists(newdir)){

setwd(newdir)

write.table(sleepstudy, file = "sleepstudy.txt", row.names=FALSE, col.names = 
FALSE)

r <- nparACT_flex_loop(newdir, SR = 4/60, minutes = 435)

} else {

dir.create(newdir)

setwd(newdir)

write.table(sleepstudy, file = "sleepstudy.txt", row.names=FALSE, col.names = 
FALSE)

r <- nparACT_flex_loop(newdir, SR = 4/60, minutes = 435)

}

setwd(wd)

}



Best,

Christine





-Ursprüngliche Nachricht-
Von: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
Gesendet: Dienstag, 19. Dezember 2017 16:19
An: Blume Christine; r-package-devel@r-project.org
Betreff: Re: [R-pkg-devel] nparACT package: "working directory was changed 
to...resetting"



On 19/12/2017 9:42 AM, Blume Christine wrote:

> Dear Community,

>

>

>

> For Fedora my package now gives a warning message when running the example:

>

>

>

> "Warning: working directory was changed to 
> '/data/gannet/ripley/R/packages/tests-clang/nparACT.Rcheck/sleepstudy_example',
>  resetting"

>

>

>

> I do not really know how to approach/solve this, what has recently been 
> changed in R devel so this error message started appearing?



Previously you were allowed to change directory in an example.  Now you're not. 
 This makes sense:  the user might not want to change the working directory.



To fix this, just save the old directory, and restore it at the end of your 
example.  For example,



   olddir <- setwd(tempdir())

   # Run the rest of the example code here

   setwd(olddir)



Duncan Murdoch



>

>

>

> The full message can be seen here:

> https://CRAN.R-project.org/web/checks/check_results_nparACT.html

>

>

>

> Any help is appreciated and rewarded with gratitude.

>

>

>

> Best,

>

>

>

> Christine

>

>

>

> [[alternative HTML version deleted]]

>

> __

> R-package-devel@r-project.org<mailto:R-package-devel@r-project.org> mailing 
> list

> https://stat.ethz.ch/mailman/listinfo/r-package-devel

>



[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Re: [R-pkg-devel] nparACT package: "working directory was changed to...resetting"

2017-12-19 Thread Blume Christine
Actually, the report I received refers to the old 0.7 version…for whatever 
reason? The version I had submitted  was 0.8 in which I had corrected this. 
Well, let’s see…



Another issue seems to be that the text file the example is supposed to read in 
is not read (properly) using Debian:



Warning in is.na(data$activity) :

 is.na() applied to non-(list or vector) of type 'NULL'

Error in 1:a : argument of length 0



I am reading in a text file with a numeric column (data$activity) and date or 
datetime (which is then converted using as.POSIXct. Subsequently, I check if 
there are NAs…



Any ideas what might be happening here?



Best,

Christine





-Ursprüngliche Nachricht-
Von: Iñaki Úcar [mailto:i.uca...@gmail.com]
Gesendet: Dienstag, 19. Dezember 2017 16:48
An: Blume Christine
Cc: r-package-devel@r-project.org
Betreff: Re: [R-pkg-devel] nparACT package: "working directory was changed 
to...resetting"



2017-12-19 16:27 GMT+01:00 Blume Christine 
mailto:christine.bl...@sbg.ac.at>>:

> Hi Duncan,

>

> Thanks a lot! Good to see that you had a similar idea, I did just that...in 
> my example it looks like this, however, that does not help, i.e. that is the 
> code that is associated with the warning…

>

> data(sleepstudy)

>

> wd <- getwd()

>

> name <- "sleepstudy_example"

>

> newdir <- paste(wd,name, sep="/")

>

> if (dir.exists(newdir)){

>

> setwd(newdir)

>

> write.table(sleepstudy, file = "sleepstudy.txt", row.names=FALSE, col.names = 
> FALSE)

>

> r <- nparACT_flex_loop(newdir, SR = 4/60, minutes = 435)

>

> } else {

>

> dir.create(newdir)

>

> setwd(newdir)

>

> write.table(sleepstudy, file = "sleepstudy.txt", row.names=FALSE, col.names = 
> FALSE)

>

> r <- nparACT_flex_loop(newdir, SR = 4/60, minutes = 435)

>

> }

>

> setwd(wd)

>

> }



I see:



$ wget https://cran.r-project.org/src/contrib/nparACT_0.7.tar.gz

$ tar xf nparACT_0.7.tar.gz

$ grep -r setwd nparACT

nparACT/man/nparACT_flex_loop.Rd:setwd(newdir)

nparACT/man/nparACT_base_loop.Rd:setwd(newdir)



so two examples don't restore the wd as Duncan was pointing out.



Iñaki



>

>

>

> Best,

>

> Christine

>

>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

[R-pkg-devel] Debian: example file is no longer read correctly

2017-12-20 Thread Blume Christine
Dear all,

I guess I need your help again. With debian my package (nparACT) gives an error 
message that seems to be related to loading the data:

 Warning in is.na(data$activity) :
 is.na() applied to non-(list or vector) of type 'NULL'
Error in 1:a : argument of length 0

Although I have set up a virtual machine to test the package using the R devel 
version with Linux (Debian), it gives me a hard time to find out what is wrong 
since I do not manage to install packages using the devel version...

Does anyone know what has changed so this text file is not read in any longer? 
The code for reading in the text file is:

data <- read.table(paste(path,name, sep="/"), header = F)
if (is.data.frame(data)==F){
  data = as.data.frame(data)
}
if(ncol(data) == 2){
  data[,1] <- as.POSIXct(data[,1])
  data[,2] <- as.numeric(as.character(data[,2]))
  names(data)[1] <- "time"
  names(data)[2] <- "activity"
   }
if(ncol(data) == 3){
  names(data)[1] <- "date"
  names(data)[2] <- "time"
  names(data)[3] <- "activity"
  data$date <- NULL
  data$time <- as.POSIXct(data$time, format="%H:%M:%S")
  data$activity <- as.numeric(as.character(data$activity))
}

Or can someone tell me how to install the package using R devel on Linux?

Thanks a lot!
Christine


[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Debian: example file is no longer read correctly

2017-12-20 Thread Blume Christine
Dear all,

Thanks a lot for all your suggestions, which I was happy to include. All my 
coding skills are self-taught so I am especially thankful for suggestions on 
how to improve the code regarding defensiveness etc..

I have also followed Iñaki's excellent suggestion and checked the package with 
the latest changes to the example (to circumvent the path-setting problems) 
using rhub using different platforms. 

I have submitted the version with the corrections again earlier and it is on 
its way to CRAN now.

Thanks again,
Christine



-Ursprüngliche Nachricht-
Von: Georgi Boshnakov [mailto:georgi.boshna...@manchester.ac.uk] 
Gesendet: Mittwoch, 20. Dezember 2017 14:49
An: Göran Broström; r-package-devel@r-project.org; Blume Christine
Betreff: RE: [R-pkg-devel] Debian: example file is no longer read correctly

The package on CRAN doesn't use tempdir()  to change directories. 
Given that the error occurs on some linux-es only, it may be worth a try to 
submit the package and see if these errors will resurface. 

It is difficult to debug errors on systems you don't have but some cleanup of 
your code might help your users and you.
In particular, write more defensively. For example, in your function (see a 
copy further bbelow) you may consider if it is fine to convert each file to a 
data.frame. Even if this is successful,  the data frame may not be what you 
expect.
 One good idea is to write exhaustive checks.

The check for nofiles > 0 was already suggested, another suggestion is after 
the signature below. 

Kind regards,
Georgi Boshnakov

The chunk:

=
if (ncol(data) == 2) {
...
}
if (ncol(data) == 3) {
  ... 
}
==

can be made more robust by simply adding an 'else' (note also the else if) to 
cover for a condition that "cannot" happen.

=
if (ncol(data) == 2) {
...
}  else if (ncol(data) == 3) {
  ... 
} else {
 stop(""I thought that this can never happen!")
   }
==


=

nparACT_flex_loop()
function (path, SR, cutoff = 1, minutes, plot = T, fulldays = T) {
files <- list.files(path)
fileext <- file_ext(files[1])
nofiles <- length(files)
bin_hr <- 60
nparACT_result <- matrix(NA, nofiles, 9)
nparACT_result <- as.data.frame(nparACT_result)
colnames(nparACT_result) <- c("IS", "IV", "RA", "L5", "L5_starttime", 
"M10", "M10_starttime", "Lflex", "Lflex_starttime")
matrix_hraverage <- matrix(NA, nofiles, 24)
for (zz in 1:nofiles) {
name <- files[zz]
if (fileext == "txt") {
data <- read.table(paste(path, name, sep = "/"), 
header = F)
}
else {
data <- read.csv(paste(path, name, sep = "/"), header = F)
}
if (is.data.frame(data) == F) {
data = as.data.frame(data)
}
if (ncol(data) == 2) {
data[, 1] <- as.POSIXct(data[, 1])
data[, 2] <- as.numeric(as.character(data[, 2]))
names(data)[1] <- "time"
names(data)[2] <- "activity"
}
if (ncol(data) == 3) {
names(data)[1] <- "date"
names(data)[2] <- "time"
names(data)[3] <- "activity"
data$date <- NULL
data$time <- as.POSIXct(data$time, format = "%H:%M:%S")
data$activity <- as.numeric(as.character(data$activity))
}
if (any(is.na(data$activity)) == TRUE) 
stop("Please check your data! It must not contain NAs")
a <- nrow(data)
e <- SR * 60
m <- bin_hr * SR * 60
full_days <- floor(a/(e * bin_hr * 24))
if (fulldays == T) {
data <- data[1:(e * bin_hr * 24 * full_days), ]
}
a <- nrow(data)
b <- floor(a/(SR * 60))
nparACT_auxfunctions1$nparACT_filt(data, a, cutoff)
if (SR != 1/60) {
data_min <- nparACT_auxfunctions1$nparACT_data_min(b, 
SR, data)
}
else {
data_min <- data$activity
}
data_hrs <- nparACT_auxfunctions1$nparACT_data_hrs(data, 
a, m)
result_ISIV <- nparACT_ISIVfunctions$nparACT_ISIV(data_hrs, 
bin_hr)
IS <- result_ISIV[1]
IV <- result_ISIV[2]
nparACT_result[zz, 1] <- IS
nparACT_result[zz, 2] <- IV
minaverage <- nparACT_auxfunctions1$nparACT_minaverage(a, 
data_min)
if (plot == T) {
hraverage_sorted <- 
nparACT_auxfunctions1$nparACT_hraverage_GA

Re: [R-pkg-devel] File name error

2017-12-21 Thread Blume Christine
Hi Cathy,

I also had troubles with debian (Fedora only gave warnings) and no problems 
with other systems. Mine was related to me writing a file (or rather trying to 
write) in a working directory other than tempdir (can be retrieved by 
tempdir()). I now write it to tempdir and then set the old working directory 
again at the end of the example. Perhaps that is somehow helpful for your case 
too?

I can highly recommend to test your tar.gz file with the check() function of 
the rhub package. You can for example run check("pathtoyourpackage", platform = 
"debian-gcc-devel") or 
check_for_cran("pathtoyourpackage", platform = "debian-gcc-devel"), i.e. test 
your package on debian without troubles.

Best,
Christine


-Ursprüngliche Nachricht-
Von: R-package-devel [mailto:r-package-devel-boun...@r-project.org] Im Auftrag 
von Cathy Lee Gierke
Gesendet: Donnerstag, 21. Dezember 2017 07:15
An: R Package Development
Betreff: [R-pkg-devel] File name error

I am getting the following error from the auto-checks when trying to submit a 
package to CRAN:
r-devel-linux-x86_64-debian-gcc

3.0.0.2 3.63 56.71 60.34 ERROR


Error in pdf(file = fileName4, width = 8, height = 10) :
  cannot open file
'/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/CATkit/extdata/activity-stress-c57-2-part.txt--20Dec2017--03-51-46CAToutput.pdf'

Since this works for ALL other flavors, I am assuming it may be some file name 
restrictions unique to debian-gcc???  I can't think what else would cause it to 
fail only in the OS.

debian doesn't like "--"?

Cathy Lee Gierke


*“Darkness cannot drive out darkness: only light can do that. Hate cannot drive 
out hate: only love can do that.” * *“The arc of the moral universe is long, 
but it bends towards justice.”* *“Nothing in the world is more dangerous than 
sincere ignorance and conscientious stupidity.” *
*“Never forget that everything Hitler did in Germany was legal.”   *
*“Forgiveness is not an occasional act, it is a constant attitude.” * 
*“Injustice anywhere is a threat to justice everywhere.”  *

― Martin Luther King Jr.



[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list 
https://stat.ethz.ch/mailman/listinfo/r-package-devel
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

[R-pkg-devel] ERROR (re)building vignettes

2021-09-22 Thread Blume Christine
Dear community,

When building my package 'SleepCycles' using devtools::check, 
devtools::check_win_devel, and devtools::check_rhub, I do not get warnings, 
errors, or notes. Nevertheless, there seems to be an error when building the 
vignettes eventually 
(https://cran-archive.r-project.org/web/checks/2021/2021-09-06_check_results_SleepCycles.html),
 which I did not notice and which led to the removal of the package.

Does anyone know how to solve this? I read something about changing the 
vignette engine, but when I tried this, I ran into other issues.

I cannot replicate the error, but simply resubmitting will most likely result 
in the same issue again.

Best,
Christine


[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel