Re: [R] Need help testing a problem

2024-02-01 Thread Roy Mendelssohn - NOAA Federal via R-help
HI Rui:

First and foremost thanks  for taking the time to do this.  That was a typo,  
it was httr and is not needed,  I was careless.  That request works fine on a 
Mac and a Linux box.  We needed to check if there was something about  iour 
internal network settings, our Windows setup or something else that was causing 
the problem.  Bill Dunlop got the same results so it is something else,  We do 
not know how much Akamai is interfering with this,  we have had issues with 
folks running Windows behind Cloudfare that caused problems.

Again,  thanks for taking the time,  it eliminates on possible cause.

-Roy



> On Feb 1, 2024, at 2:16 AM, Rui Barradas  wrote:
> 
> Às 23:47 de 31/01/2024, Roy Mendelssohn - NOAA Federal via R-help escreveu:
>> HI All:
>> We are trying to figure out a problem that is occurring with a package,  and 
>> we need a non-NOAA person with a Windows computer with the latest R to test 
>> for us what is failing (but works on Macs and Linux from different sites).  
>> Part of the problem is there is an Akamai service in between that we feel 
>> may be messing up things. To do this you would need to be willing to:
>> 1.  install the ‘rerddap’ package from CRAN,  with all dependencies - or if 
>> installed make certain it is the latest
>> 2. make certain that the packages ‘curl’, ‘crul’ and ‘http’ are up to date.
>> 3.  Run the following:
>> # load rerddap
>> library("rerddap”)
>> # delete rerddap cache just in case
>> cache_delete_all()
>> # get the data extract
>> dat <- tabledap('FED_JSATS_detects', url = 
>> "https://oceanview.pfeg.noaa.gov/erddap/;, 'study_id="RBDD_2018"', callopts 
>> = list(verbose = TRUE), store = memory())
>> 4. If it works also do:
>>  head(dat)
>> Either way if all the output could be sent to me it would be very helpful.  
>> The download may take a couple of minutes,
>> the file size is about 3.5MB.
>> If anyone has concerns about what is being downloaded you can check the 
>> ‘rerddap’ docs to see these are all legitimate ‘rerddap' commands,  the 
>> datasets being accessed is 
>> https://oceanview.pfeg.noaa.gov/erddap/tabledap/FED_JSATS_detects.html.  The 
>> downloaded file goes to R temp space, and its location,  if successful is 
>> given in the output.
>> Thanks to anyone willing to help.  One of my issues is I have been unable to 
>> reproduce the error,  but I also do not have ready access to a Windows 
>> machine.
>> -ROy
>>  [[alternative HTML version deleted]]
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> Hello,
> 
> Tested with R 4.3.2 running on Windows 11.
> 
> 1. You mention package http but there is no package http on CRAN, did you 
> mean package httr?
> 
> 2. I wrote a script rhelp.R, ran it on a command window and here is what I 
> got on the command window output.
> 
> 
> 
> C:\Users\ruipb\Documents>R -q -f rhelp.R > rhelp_out.txt
> * WARNING: failed to open cookie file ""
> * Found bundle for host: 0x21cb7410670 [serially]
> * Can not multiplex, even if we wanted to
> * Re-using existing connection with host oceanview.pfeg.noaa.gov
> > GET /erddap/tabledap/FED_JSATS_detects.csv?_id%3D%22RBDD_2018%22 
> > HTTP/1.1
> Host: oceanview.pfeg.noaa.gov
> User-Agent: libcurl/8.3.0 r-curl/5.2.0 crul/1.4.0
> Accept-Encoding: gzip, deflate
> Accept: application/json, text/xml, application/xml, */*
> 
> < HTTP/1.1 504 Gateway Time-out
> < Server: AkamaiGHost
> < Mime-Version: 1.0
> < Content-Type: text/html
> < Content-Length: 176
> < Expires: Thu, 01 Feb 2024 09:56:40 GMT
> < Date: Thu, 01 Feb 2024 09:56:40 GMT
> < Connection: keep-alive
> < Strict-Transport-Security: max-age=31536000
> <
> * Connection #0 to host oceanview.pfeg.noaa.gov left intact
> 
> 
> 3. The file rhelp_out.txt was created and its contents are the following. (I 
> installed package "hoardr" separately because for some reason it was not 
> being recognized as a dependency)
> 
> 
> 
> > # pkgs <- c("hoardr", "rerddap", "curl", "crul", "httr")
> > # utils::install.packages(
> > # pkgs = pkgs,
> > # lib = .libPaths()[1],
> > # repos = "https://cloud.r-project.org;,
> > # dependencies = TRUE
> > # )
> >
> > # load rerddap
> > library("rerddap")
> > # delete rerddap cache just in case
> > cache_delete_all()
> > # get the data extract
> > dat <- tryCatch(
> +   tabledap(
> + 'FED_JSATS_detects',
> + url = "https://oceanview.pfeg.noaa.gov/erddap/;,
> + 'study_id="RBDD_2018"',
> + callopts = list(verbose = TRUE),
> + store = memory()
> +   ),
> +   warning = function(w) w,
> +   error = function(e) e,
> +   finally = print("download end")
> + )
> [1] "download end"
> >
> > # 4. If it works also do:
> > head(dat)
> $message
> [1] ""
> 
> $call
> NULL
> 
> >
> > str(dat)
> 

Re: [R] Need help testing a problem

2024-02-01 Thread Rui Barradas

Às 23:47 de 31/01/2024, Roy Mendelssohn - NOAA Federal via R-help escreveu:

HI All:

We are trying to figure out a problem that is occurring with a package,  and we 
need a non-NOAA person with a Windows computer with the latest R to test for us 
what is failing (but works on Macs and Linux from different sites).  Part of 
the problem is there is an Akamai service in between that we feel may be 
messing up things. To do this you would need to be willing to:

1.  install the ‘rerddap’ package from CRAN,  with all dependencies - or if 
installed make certain it is the latest

2. make certain that the packages ‘curl’, ‘crul’ and ‘http’ are up to date.

3.  Run the following:

# load rerddap
library("rerddap”)
# delete rerddap cache just in case
cache_delete_all()
# get the data extract
dat <- tabledap('FED_JSATS_detects', url = "https://oceanview.pfeg.noaa.gov/erddap/;, 
'study_id="RBDD_2018"', callopts = list(verbose = TRUE), store = memory())

4. If it works also do:

  head(dat)

Either way if all the output could be sent to me it would be very helpful.  The 
download may take a couple of minutes,
the file size is about 3.5MB.

If anyone has concerns about what is being downloaded you can check the 
‘rerddap’ docs to see these are all legitimate ‘rerddap' commands,  the 
datasets being accessed is 
https://oceanview.pfeg.noaa.gov/erddap/tabledap/FED_JSATS_detects.html.  The 
downloaded file goes to R temp space, and its location,  if successful is given 
in the output.

Thanks to anyone willing to help.  One of my issues is I have been unable to 
reproduce the error,  but I also do not have ready access to a Windows machine.

-ROy
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Hello,

Tested with R 4.3.2 running on Windows 11.

1. You mention package http but there is no package http on CRAN, did 
you mean package httr?


2. I wrote a script rhelp.R, ran it on a command window and here is what 
I got on the command window output.




C:\Users\ruipb\Documents>R -q -f rhelp.R > rhelp_out.txt
* WARNING: failed to open cookie file ""
* Found bundle for host: 0x21cb7410670 [serially]
* Can not multiplex, even if we wanted to
* Re-using existing connection with host oceanview.pfeg.noaa.gov
> GET 
/erddap/tabledap/FED_JSATS_detects.csv?_id%3D%22RBDD_2018%22 HTTP/1.1

Host: oceanview.pfeg.noaa.gov
User-Agent: libcurl/8.3.0 r-curl/5.2.0 crul/1.4.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*

< HTTP/1.1 504 Gateway Time-out
< Server: AkamaiGHost
< Mime-Version: 1.0
< Content-Type: text/html
< Content-Length: 176
< Expires: Thu, 01 Feb 2024 09:56:40 GMT
< Date: Thu, 01 Feb 2024 09:56:40 GMT
< Connection: keep-alive
< Strict-Transport-Security: max-age=31536000
<
* Connection #0 to host oceanview.pfeg.noaa.gov left intact


3. The file rhelp_out.txt was created and its contents are the 
following. (I installed package "hoardr" separately because for some 
reason it was not being recognized as a dependency)




> # pkgs <- c("hoardr", "rerddap", "curl", "crul", "httr")
> # utils::install.packages(
># pkgs = pkgs,
># lib = .libPaths()[1],
># repos = "https://cloud.r-project.org;,
># dependencies = TRUE
> # )
>
> # load rerddap
> library("rerddap")
> # delete rerddap cache just in case
> cache_delete_all()
> # get the data extract
> dat <- tryCatch(
+   tabledap(
+ 'FED_JSATS_detects',
+ url = "https://oceanview.pfeg.noaa.gov/erddap/;,
+   'study_id="RBDD_2018"',
+   callopts = list(verbose = TRUE),
+   store = memory()
+   ),
+   warning = function(w) w,
+   error = function(e) e,
+   finally = print("download end")
+ )
[1] "download end"
>
> # 4. If it works also do:
> head(dat)
$message
[1] ""

$call
NULL

>
> str(dat)
List of 2
 $ message: chr ""
 $ call   : NULL
 - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
>
> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8 
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C 


[5] LC_TIME=Portuguese_Portugal.utf8

time zone: Europe/Lisbon
tzcode source: internal

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] rerddap_1.1.0

loaded via a namespace (and not attached):
 [1] vctrs_0.6.3   cli_3.6.1 rlang_1.1.1   ncdf4_1.22 

 [5] crul_1.4.0generics_0.1.3jsonlite_1.8.7 
data.table_1.14.8
 [9] glue_1.6.2httpcode_0.3.0triebeard_0.4.1   fansi_1.0.5 


[13] rappdirs_0.3.3

[R] Need help testing a problem

2024-01-31 Thread Roy Mendelssohn - NOAA Federal via R-help
HI All:

We are trying to figure out a problem that is occurring with a package,  and we 
need a non-NOAA person with a Windows computer with the latest R to test for us 
what is failing (but works on Macs and Linux from different sites).  Part of 
the problem is there is an Akamai service in between that we feel may be 
messing up things. To do this you would need to be willing to:

1.  install the ‘rerddap’ package from CRAN,  with all dependencies - or if 
installed make certain it is the latest

2. make certain that the packages ‘curl’, ‘crul’ and ‘http’ are up to date.  

3.  Run the following:

# load rerddap
library("rerddap”)
# delete rerddap cache just in case
cache_delete_all()
# get the data extract
dat <- tabledap('FED_JSATS_detects', url = 
"https://oceanview.pfeg.noaa.gov/erddap/;, 'study_id="RBDD_2018"', callopts = 
list(verbose = TRUE), store = memory())

4. If it works also do:

 head(dat)

Either way if all the output could be sent to me it would be very helpful.  The 
download may take a couple of minutes,
the file size is about 3.5MB.

If anyone has concerns about what is being downloaded you can check the 
‘rerddap’ docs to see these are all legitimate ‘rerddap' commands,  the 
datasets being accessed is 
https://oceanview.pfeg.noaa.gov/erddap/tabledap/FED_JSATS_detects.html.  The 
downloaded file goes to R temp space, and its location,  if successful is given 
in the output.

Thanks to anyone willing to help.  One of my issues is I have been unable to 
reproduce the error,  but I also do not have ready access to a Windows machine.

-ROy
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to resolve the Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Execution halted

2023-10-26 Thread Ben Bolker
  Hmm, I can't replicate (i.e., it works fine for me).  What are the 
results of your sessionInfo() (from a *clean* R session)?


==
R Under development (unstable) (2023-10-25 r85410)
Platform: x86_64-pc-linux-gnu
Running under: Pop!_OS 22.04 LTS

Matrix products: default
BLAS:   /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3; 
LAPACK version 3.10.0




attached base packages:
[1] stats graphics  grDevices datasets  utils methods   base

loaded via a namespace (and not attached):
 [1] desc_1.4.2R6_2.5.1  bspm_0.5.3 
remotes_2.4.2.1
 [5] ps_1.7.5  cli_3.6.1 processx_3.8.2callr_3.7.3 

 [9] compiler_4.4.0prettyunits_1.2.0 rprojroot_2.0.3   tools_4.4.0 


[13] pkgbuild_1.4.2curl_5.0.1crayon_1.5.2


On 2023-10-26 9:59 a.m., siddharth sahasrabudhe via R-help wrote:

Hello Colleagues,

I am trying to get the Git repository using *remotes* package. I am
using *remotes::install_github("dcl-docs/dcldata")
*to get the Git repo.

However, I am getting the following error message. I have absolutely no
idea on what this error message means and how to get away with this. Can
anyone please suggest the way out...?

Here is the error message that i am getting:


remotes::install_github("dcl-docs/dcldata")Downloading GitHub repo 
dcl-docs/dcldata@HEADRunning `R CMD build`...* checking for file 
'C:\Users\admin\AppData\Local\Temp\RtmpWmVvZI\remotes2ddc1b982b8\dcl-docs-dcldata-0a08cbb/DESCRIPTION'
 ... OK

* preparing 'dcldata':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'dcldata_0.1.2.9000.tar.gz'Installing package into
‘C:/Users/admin/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)Error: evaluation nested too deeply: infinite
recursion / options(expressions=)?
Execution haltedWarning: installation of package
‘C:/Users/admin/AppData/Local/Temp/RtmpWmVvZI/file2ddc7bed1881/dcldata_0.1.2.9000.tar.gz’
had non-zero exit status


Many thanks for the prompt help as always!

Regards
Siddharth
--

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help to resolve the Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Execution halted

2023-10-26 Thread siddharth sahasrabudhe via R-help
Hello Colleagues,

I am trying to get the Git repository using *remotes* package. I am
using *remotes::install_github("dcl-docs/dcldata")
*to get the Git repo.

However, I am getting the following error message. I have absolutely no
idea on what this error message means and how to get away with this. Can
anyone please suggest the way out...?

Here is the error message that i am getting:

> remotes::install_github("dcl-docs/dcldata")Downloading GitHub repo 
> dcl-docs/dcldata@HEADRunning `R CMD build`...* checking for file 
> 'C:\Users\admin\AppData\Local\Temp\RtmpWmVvZI\remotes2ddc1b982b8\dcl-docs-dcldata-0a08cbb/DESCRIPTION'
>  ... OK
* preparing 'dcldata':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'dcldata_0.1.2.9000.tar.gz'Installing package into
‘C:/Users/admin/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)Error: evaluation nested too deeply: infinite
recursion / options(expressions=)?
Execution haltedWarning: installation of package
‘C:/Users/admin/AppData/Local/Temp/RtmpWmVvZI/file2ddc7bed1881/dcldata_0.1.2.9000.tar.gz’
had non-zero exit status


Many thanks for the prompt help as always!

Regards
Siddharth
--

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help with plotmath and/or plotting unicode characters

2023-06-08 Thread Ivan Krylov
On Wed, 7 Jun 2023 19:14:58 -0700
Dennis Fisher  wrote:

> UNICODE: If I can generate "≥" via unicode, the problem is solved:
>   mtext(side=3, paste0("N ", UNICODE, " ", XX, ": ", YY))

It should be possible to just copy & paste "≥" in the R source code
nowadays. If for some reason the script has to stay ASCII-encoded, use
'\u2265'.

> PLOTMATH:
>   mtext(side=3, bquote(N <= .(XX) ~":" ~ .(YY)))
> This comes close:
>   N ≤ 2 : 13
> but I want to remove the space between the 2 and ":"

Use paste(.(XX), ":") or even just .(XX) * ":" to output them close
together.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] need help with plotmath and/or plotting unicode characters

2023-06-08 Thread Dennis Fisher
R 4.2.3
OS X

Colleagues

This should be easy -- but not for me.

I want to plot text similar to this:
N ≥ XX: YY

where XX can be either 1 or 50 and YY is an integer

I envision that there would be two solutions:

UNICODE: If I can generate "≥" via unicode, the problem is solved:
mtext(side=3, paste0("N ", UNICODE, " ", XX, ": ", YY))

PLOTMATH:
mtext(side=3, bquote(N <= .(XX) ~":" ~ .(YY)))
This comes close:
N ≤ 2 : 13
but I want to remove the space between the 2 and ":"

Dennis



Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-23 Thread Jim Lemon
Hi David,
No, read.table converts a text representation of data into a data frame object.

Jim

On Sat, Sep 24, 2022 at 2:29 AM DFP  wrote:
>
> Do I need that read.table if the tst dataframe already exists in my
> system?  If so, why?
>
> --
>
> Hello,
>
> You have to load the packages involved:
>
>
> library(dplyr)
> library(tidyr)
> library(ggplot2)
>
>
> then run the full sequence. Though this is not important, if you are
> pivotting columnns named y1 and y2, why not name the result just y?
>
>
> pivot_longer(-time, names_to = "y")
>
>
> And here is complete code, runs in a fresh R session.
>
>
> tst  <- read.table(text = "
> time y1 y2
> 1  18:55 30 19
> 2  18:56 30 19
> 3  18:57 29 19
> 4  18:58 31 19
> 5  18:59 28 19
> 6  19:00 28 19
> 7  19:01 28 19
> 8  19:02 28 19
> 9  19:03 28 19
> 10 19:04 28 19
> 11 19:05 29 19
> ", header = TRUE)
>
> library(dplyr)
> library(tidyr)
> library(ggplot2)
>
> tst %>%
> mutate(time = paste(Sys.Date(), time),
>time = as.POSIXct(time)) %>%
> select(time, y1, y2) %>%
> # reshape to long format
> pivot_longer(-time, names_to = "y") %>%
> # now plot
> ggplot(aes(time, value, color = y)) +
> geom_line() +
> geom_point() +
> scale_color_manual(values = c("orange", "skyblue")) +
> # make datetime labels
> scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
> theme_bw()
>
>
> Hope this helps,
>
> Rui Barradas
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-23 Thread DFP
Do I need that read.table if the tst dataframe already exists in my 
system?  If so, why?

--

Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are
pivotting columnns named y1 and y2, why not name the result just y?


pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
    mutate(time = paste(Sys.Date(), time),
   time = as.POSIXct(time)) %>%
    select(time, y1, y2) %>%
    # reshape to long format
    pivot_longer(-time, names_to = "y") %>%
    # now plot
    ggplot(aes(time, value, color = y)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


Hope this helps,

Rui Barradas

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-22 Thread DFP
That worked, and helped my understanding.  Thank you.



Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are
pivotting columnns named y1 and y2, why not name the result just y?


pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
    mutate(time = paste(Sys.Date(), time),
   time = as.POSIXct(time)) %>%
    select(time, y1, y2) %>%
    # reshape to long format
    pivot_longer(-time, names_to = "y") %>%
    # now plot
    ggplot(aes(time, value, color = y)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


Hope this helps,

Rui Barradas

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-22 Thread Rui Barradas

No you don't! I do!
I don't have tst on my system.

Rui Barradas

Às 22:11 de 22/09/2022, DFP escreveu:
Do I need that read.table if the tst dataframe already exists in my 
system?  If so, why?


--

Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are
pivotting columnns named y1 and y2, why not name the result just y?


pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
    mutate(time = paste(Sys.Date(), time),
   time = as.POSIXct(time)) %>%
    select(time, y1, y2) %>%
    # reshape to long format
    pivot_longer(-time, names_to = "y") %>%
    # now plot
    ggplot(aes(time, value, color = y)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


Hope this helps,

Rui Barradas



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-22 Thread Rui Barradas

Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are 
pivotting columnns named y1 and y2, why not name the result just y?



pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
  mutate(time = paste(Sys.Date(), time),
 time = as.POSIXct(time)) %>%
  select(time, y1, y2) %>%
  # reshape to long format
  pivot_longer(-time, names_to = "y") %>%
  # now plot
  ggplot(aes(time, value, color = y)) +
  geom_line() +
  geom_point() +
  scale_color_manual(values = c("orange", "skyblue")) +
  # make datetime labels
  scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
  theme_bw()


Hope this helps,

Rui Barradas

Às 20:40 de 22/09/2022, DFP escreveu:
I'm trying to do as you suggest, but I'm not understanding what I need 
to do.  I asked what the line pivot_longer(-time, names_to = "y1") would 
do if applied to this df:


 > tst
     time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19

I tried to run these lines and then look at tst, but this is what I get:

 > tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1")
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

   could not find function "%>%"

How can I learn what the pivot_longer has done to tst?

Darn it--Now I try to run the whole sequence that Rui suggested--it 
worked before--and now I get this:


 > tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1") %>%
+    # now plot
+    ggplot(aes(time, value, color = y1)) +
+    geom_line() +
+    geom_point() +
+    scale_color_manual(values = c("orange", "skyblue")) +
+    # make datetime labels
+    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
+    theme_bw()
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

   could not find function "%>%"
 >

What should I try next?



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-22 Thread DFP
I'm trying to do as you suggest, but I'm not understanding what I need 
to do.  I asked what the line pivot_longer(-time, names_to = "y1") would 
do if applied to this df:


> tst
    time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19

I tried to run these lines and then look at tst, but this is what I get:

> tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1")
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

  could not find function "%>%"

How can I learn what the pivot_longer has done to tst?

Darn it--Now I try to run the whole sequence that Rui suggested--it 
worked before--and now I get this:


> tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1") %>%
+    # now plot
+    ggplot(aes(time, value, color = y1)) +
+    geom_line() +
+    geom_point() +
+    scale_color_manual(values = c("orange", "skyblue")) +
+    # make datetime labels
+    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
+    theme_bw()
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

  could not find function "%>%"
>

What should I try next?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-21 Thread Rui Barradas

Hello,

This type of problems generally has to do with reshaping the data. The 
format should be the long format and the data is in wide format.


Inline.

Às 23:35 de 21/09/2022, DFP escreveu:
As I said, the lines below that you provided worked well for me. Can you 
explain what this line does?:


# reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%

-

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
    mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime)) %>%
    select(Dtime, DNO2, MNO2) %>%
    # reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%



After selecting only the columns Dtime and *NO2 you need to reshape the 
data to long format. Some ways of telling pivot_longer what are the 
columns to become one are


 - explicitly writing all columns to be pivotted;
 - with negative indexing, all others will be put under the new name "NO2";
 - with a selection function such as ends_with("NO2"). This is probably 
more readable code if you return to it some time from now.



pivot_longer(ends_with("NO2"), names_to = "NO2") %>%


With data in the long format map column NO2 to the color aesthetic and 
ggplot will automatically understand that you have 2 groups, DNO2 and 
MNO2, and plot 2 lines and 2 groups of points (one for each color) .


Hope this helps,

Rui Barradas



    # now plot
    ggplot(aes(Dtime, value, color = NO2)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-21 Thread Ebert,Timothy Aaron
Yes, but if you want to learn R (or relearn R) it would be better for you to 
decompress the code.
You know what b looks like so add the next step. If you want to be able to see 
the original then save the output to another data frame.
New_df <- b %>%
mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime))

What do you have now?
Then add the next pipe %>% and code until the next %>%. 
When you look at the dataframe after reshape() it will be very obvious, though 
if you still have questions please ask.

Tim

-Original Message-
From: R-help  On Behalf Of DFP
Sent: Wednesday, September 21, 2022 6:35 PM
To: Rui Barradas ; r-help@r-project.org
Subject: Re: [R] Need help plotting

[External Email]

As I said, the lines below that you provided worked well for me. Can you 
explain what this line does?:

# reshape to long format
pivot_longer(-Dtime, names_to = "NO2") %>%

-

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime)) %>%
select(Dtime, DNO2, MNO2) %>%
# reshape to long format
pivot_longer(-Dtime, names_to = "NO2") %>%
# now plot
ggplot(aes(Dtime, value, color = NO2)) +
geom_line() +
geom_point() +
scale_color_manual(values = c("orange", "skyblue")) +
# make datetime labels
scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
theme_bw()


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C2e922af564854b594aae08da9c21a172%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637993965506049641%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=gnPZJIDTjVr8cv9s3foPjzYYUXWYX5Y18%2FLRKQpXyp4%3Dreserved=0
PLEASE do read the posting guide 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%7C2e922af564854b594aae08da9c21a172%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637993965506049641%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=aLDvzRXPm3MSdulLOCbKDUSL59bO3RvhwAAkGl%2B%2BJ8M%3Dreserved=0
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-21 Thread DFP
As I said, the lines below that you provided worked well for me. Can you 
explain what this line does?:

# reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%

-

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
    mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime)) %>%
    select(Dtime, DNO2, MNO2) %>%
    # reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%
    # now plot
    ggplot(aes(Dtime, value, color = NO2)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help plotting

2022-09-21 Thread DFP
Thank you for the ideas below.  That did work.  I thought I had tried 
"10 mins" before, but maybe I used just 10 min.

===

Yes, you can have date_breaks = "n mins" where n is any integer.

date_breaks = "15 mins"
date_breaks = "30 mins"
date_breaks = "1 hour"   # or "1 hours", plural

The only way I know is to try different values until you find one suitable.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-20 Thread Ebert,Timothy Aaron
Have you done something like this first?
install.packages("chron")

After that comes

library(chron)

and the rest of your code.

Tim
-Original Message-
From: R-help  On Behalf Of Bert Gunter
Sent: Tuesday, September 20, 2022 11:57 AM
To: Parkhurst, David 
Cc: r-help@r-project.org
Subject: Re: [R] Need help plotting

[External Email]

"Also, IU's tech support told me yesterday that if I responded to a message 
that came as plain text, my response would go out as plain text.  Is that true 
for this response, or is it in HTML?"

Nope, HTML. You need to set your email client to send in plain text. Do an 
internet search on how to do this, e.g. with "How to send plain text email for 
<>".

Also see "?download.packages" for how to get packages from an R package 
repository (though RStudio and no doubt other IDE's have an interface through 
which to do this).

Cheers,
Bert

On Tue, Sep 20, 2022 at 8:49 AM Parkhurst, David 
wrote:

> I like the looks of what you are doing here.
>
> However, this from my system:
> > library(chron)
> Error in library(chron) : there is no package called 'chron'
>
> How can I get chron?
>
> Also, IU's tech support told me yesterday that if I responded to a 
> message that came as plain text, my response would go out as plain 
> text.  Is that true for this response, or is it in HTML?
>
> From: Rui Barradas 
> Date: Tuesday, September 20, 2022 at 4:52 AM
> To: Jim Lemon , Parkhurst, David < 
> parkh...@indiana.edu>, r-help mailing list 
> Subject: Re: [R] Need help plotting
> Hello,
>
> Now with data, here are base R and ggplot2 plots.
>
>
> b <- read.table(text=
>  "Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2
> MVOCMpm10 Mpm2.5 Mpm1
>   18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00
>   21
>   18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00
>   21
>   18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00
>   21",
>header=TRUE,stringsAsFactors=FALSE)
>
>
> # This base R plot needs package chron
> library(chron)
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat
> .ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl
> .edu%7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e
> 1b84%7C0%7C0%7C637992863653204275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w
> LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> sdata=aiBOxqQsZI1Mc1vF3tDW5skxG7dTAw2J0ZOCvnJdJFc%3Dreserved
> =0
> PLEASE do read the posting guide
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r
> -project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%
> 7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e1b84%
> 7C0%7C0%7C637992863653204275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
> DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> sdata=ujwOnmg30fp6NUKoTk17Uev0pg2LBf0i8qvUtM%2F%2Fjvk%3Dreserved=
> 0 and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637992863653204275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=aiBOxqQsZI1Mc1vF3tDW5skxG7dTAw2J0ZOCvnJdJFc%3Dreserved=0
PLEASE do read the posting guide 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637992863653360508%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=dFIosQzsmHgaofIKXLjVlEOcHUSlSpchBhyr%2BMMKJiU%3Dreserved=0
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-20 Thread Bert Gunter
"Also, IU’s tech support told me yesterday that if I responded to a message
that came as plain text, my response would go out as plain text.  Is that
true for this response, or is it in HTML?"

Nope, HTML. You need to set your email client to send in plain text. Do an
internet search on how to do this, e.g. with "How to send plain text email
for <>".

Also see "?download.packages" for how to get packages from an R package
repository (though RStudio and no doubt other IDE's have an interface
through which to do this).

Cheers,
Bert

On Tue, Sep 20, 2022 at 8:49 AM Parkhurst, David 
wrote:

> I like the looks of what you are doing here.
>
> However, this from my system:
> > library(chron)
> Error in library(chron) : there is no package called ‘chron’
>
> How can I get chron?
>
> Also, IU’s tech support told me yesterday that if I responded to a message
> that came as plain text, my response would go out as plain text.  Is that
> true for this response, or is it in HTML?
>
> From: Rui Barradas 
> Date: Tuesday, September 20, 2022 at 4:52 AM
> To: Jim Lemon , Parkhurst, David <
> parkh...@indiana.edu>, r-help mailing list 
> Subject: Re: [R] Need help plotting
> Hello,
>
> Now with data, here are base R and ggplot2 plots.
>
>
> b <- read.table(text=
>  "Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2
> MVOCMpm10 Mpm2.5 Mpm1
>   18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00
>   21
>   18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00
>   21
>   18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00
>   21",
>header=TRUE,stringsAsFactors=FALSE)
>
>
> # This base R plot needs package chron
> library(chron)
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-20 Thread Parkhurst, David
I like the looks of what you are doing here.

However, this from my system:
> library(chron)
Error in library(chron) : there is no package called �chron�

How can I get chron?

Also, IU�s tech support told me yesterday that if I responded to a message that 
came as plain text, my response would go out as plain text.  Is that true for 
this response, or is it in HTML?

From: Rui Barradas 
Date: Tuesday, September 20, 2022 at 4:52 AM
To: Jim Lemon , Parkhurst, David , 
r-help mailing list 
Subject: Re: [R] Need help plotting
Hello,

Now with data, here are base R and ggplot2 plots.


b <- read.table(text=
 "Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2
MVOCMpm10 Mpm2.5 Mpm1
  18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00
  21
  18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00
  21
  18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00
  21",
   header=TRUE,stringsAsFactors=FALSE)


# This base R plot needs package chron
library(chron)


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-20 Thread Rui Barradas

Hello,

Now with data, here are base R and ggplot2 plots.


b <- read.table(text=
"Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2 
MVOCMpm10 Mpm2.5 Mpm1
 18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00 
 21
 18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00 
 21
 18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00 
 21",

  header=TRUE,stringsAsFactors=FALSE)


# This base R plot needs package chron
library(chron)

# first make a real time class column
b$Dtime2 <- paste(b$Dtime, "00", sep = ":")
b$Dtime2 <- as.times(b$Dtime2)

# get the plot height and make room for
# the legend by adding 2 to y max
ylim <- range(unlist(b[c("DNO2", "MNO2")])) + c(0, 2)

# now plot one line
plot(DNO2 ~ Dtime2, b, type = "b", col = "orange", ylim = ylim)
# add the second line
points(MNO2 ~ Dtime2, b, type = "b", col = "skyblue")
# and the horizontal legend at the top center
legend("top", legend = c("DNO2", "MNO2"), horiz = TRUE,
   lty = "solid", col = c("orange", "skyblue"))


#---

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
  mutate(Dtime = paste(Sys.Date(), Dtime),
Dtime = as.POSIXct(Dtime)) %>%
  select(Dtime, DNO2, MNO2) %>%
  # reshape to long format
  pivot_longer(-Dtime, names_to = "NO2") %>%
  # now plot
  ggplot(aes(Dtime, value, color = NO2)) +
  geom_line() +
  geom_point() +
  scale_color_manual(values = c("orange", "skyblue")) +
  # make datetime labels
  scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
  theme_bw()


Hope this helps,

Rui Barradas


Às 08:37 de 20/09/2022, Jim Lemon escreveu:

Hi David,
I'm back home again. Try this:

b<-read.table(text=
"Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2 MVOCMpm10 Mpm2.5 Mpm1
  18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00  21
  18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00  21
  18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00  2
1",
  header=TRUE,stringsAsFactors=FALSE)
b$POSIXtime<-strptime(paste("2022-09-20",b$Dtime),"%Y-%m-%d %H:%M")
png("DFPNO2.png")
plot(b$POSIXtime,b$DNO2,type="b",main="NO2 readings (2022-09-20)",
  xlab="Date/time",ylab="NO2",ylim=range(c(b$DNO2,b$MNO2)),
  pch=19,col="red")
  points(b$POSIXtime,b$MNO2,type="b",pch=19,col="blue")
  legend("center",legend=c("DNO2","MNO2"),pch=19,col=c("red","blue"))
dev.off()

If you have more than one day, it will show up on the x axis. You can
also format the tick labels if you want the full dates for only one
day.

Jim

PS thanks Avi

On Tue, Sep 20, 2022 at 4:49 PM Parkhurst, David  wrote:


Thank you.

DFP (iPad)


On Sep 19, 2022, at 8:15 AM, Ebert,Timothy Aaron  wrote:

My version of this email has a bunch of ? that I do not know how to interpret. 
Emails to this group need to be in plain text. HTML content is deleted or 
converted and impossible or at least difficult to interpret.

Do not share confidential data. Please change some numbers or variable names 
and share that.
If this helps:
1) Make sure your time variable is a datetime object.
2) At least in ggplot it should now behave as expected.
ggplot(df, aes(y=NO2, x=datetime)) + geom_point()

That will be a start as a scatterplot, but the graph can be customized or 
changed if scatterplot was not desired.

Tim

-Original Message-
From: R-help  On Behalf Of Parkhurst, David
Sent: Sunday, September 18, 2022 4:27 PM
To: r-help@r-project.org
Subject: [R] Need help plotting

[External Email]

I�ve been retired since �06 and have forgotten most of R.  Now I have a use for 
it, with some data from Bloomington�s Environmental Commission.

I have a dataframe (obtained from read.csv) that contains numerous columns, 
including time (in Excel�s 18:00 format), and DNO2, and MNO2 from two air 
quality instruments.

I�d like a plot of both the NO2 measurements against time.  I be happy to use 
either ordinary R plots or ggplot2 ones, if that would be a better way.  I�d 
much appreciate help.

[[alternative HTML version deleted]]


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http

Re: [R] Need help plotting

2022-09-20 Thread Jim Lemon
Hi David,
I'm back home again. Try this:

b<-read.table(text=
"Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2 MVOCMpm10 Mpm2.5 Mpm1
 18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00  21
 18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00  21
 18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00  21",
 header=TRUE,stringsAsFactors=FALSE)
b$POSIXtime<-strptime(paste("2022-09-20",b$Dtime),"%Y-%m-%d %H:%M")
png("DFPNO2.png")
plot(b$POSIXtime,b$DNO2,type="b",main="NO2 readings (2022-09-20)",
 xlab="Date/time",ylab="NO2",ylim=range(c(b$DNO2,b$MNO2)),
 pch=19,col="red")
 points(b$POSIXtime,b$MNO2,type="b",pch=19,col="blue")
 legend("center",legend=c("DNO2","MNO2"),pch=19,col=c("red","blue"))
dev.off()

If you have more than one day, it will show up on the x axis. You can
also format the tick labels if you want the full dates for only one
day.

Jim

PS thanks Avi

On Tue, Sep 20, 2022 at 4:49 PM Parkhurst, David  wrote:
>
> Thank you.
>
> DFP (iPad)
>
> > On Sep 19, 2022, at 8:15 AM, Ebert,Timothy Aaron  wrote:
> >
> > My version of this email has a bunch of ? that I do not know how to 
> > interpret. Emails to this group need to be in plain text. HTML content is 
> > deleted or converted and impossible or at least difficult to interpret.
> >
> > Do not share confidential data. Please change some numbers or variable 
> > names and share that.
> > If this helps:
> > 1) Make sure your time variable is a datetime object.
> > 2) At least in ggplot it should now behave as expected.
> > ggplot(df, aes(y=NO2, x=datetime)) + geom_point()
> >
> > That will be a start as a scatterplot, but the graph can be customized or 
> > changed if scatterplot was not desired.
> >
> > Tim
> >
> > -Original Message-
> > From: R-help  On Behalf Of Parkhurst, David
> > Sent: Sunday, September 18, 2022 4:27 PM
> > To: r-help@r-project.org
> > Subject: [R] Need help plotting
> >
> > [External Email]
> >
> > I�ve been retired since �06 and have forgotten most of R.  Now I have a use 
> > for it, with some data from Bloomington�s Environmental Commission.
> >
> > I have a dataframe (obtained from read.csv) that contains numerous columns, 
> > including time (in Excel�s 18:00 format), and DNO2, and MNO2 from two air 
> > quality instruments.
> >
> > I�d like a plot of both the NO2 measurements against time.  I be happy to 
> > use either ordinary R plots or ggplot2 ones, if that would be a better way. 
> >  I�d much appreciate help.
> >
> >[[alternative HTML version deleted]]
> >
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-20 Thread Parkhurst, David
Thank you.

DFP (iPad)

> On Sep 19, 2022, at 8:15 AM, Ebert,Timothy Aaron  wrote:
> 
> My version of this email has a bunch of ? that I do not know how to 
> interpret. Emails to this group need to be in plain text. HTML content is 
> deleted or converted and impossible or at least difficult to interpret.
> 
> Do not share confidential data. Please change some numbers or variable names 
> and share that.
> If this helps:
> 1) Make sure your time variable is a datetime object. 
> 2) At least in ggplot it should now behave as expected.
> ggplot(df, aes(y=NO2, x=datetime)) + geom_point()
> 
> That will be a start as a scatterplot, but the graph can be customized or 
> changed if scatterplot was not desired.
> 
> Tim
> 
> -Original Message-
> From: R-help  On Behalf Of Parkhurst, David
> Sent: Sunday, September 18, 2022 4:27 PM
> To: r-help@r-project.org
> Subject: [R] Need help plotting
> 
> [External Email]
> 
> I�ve been retired since �06 and have forgotten most of R.  Now I have a use 
> for it, with some data from Bloomington�s Environmental Commission.
> 
> I have a dataframe (obtained from read.csv) that contains numerous columns, 
> including time (in Excel�s 18:00 format), and DNO2, and MNO2 from two air 
> quality instruments.
> 
> I�d like a plot of both the NO2 measurements against time.  I be happy to use 
> either ordinary R plots or ggplot2 ones, if that would be a better way.  I�d 
> much appreciate help.
> 
>[[alternative HTML version deleted]]
> 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-19 Thread Jim Lemon
Hi David,
All I got was the rather cryptic "DFP (iPad)" below your message.
Whatever format you used for the data was blocked by the R-help mail
server. Try this command in your R session:

dput(test)

and cut and paste the output into your email. That should do it.

Jim

On Tue, Sep 20, 2022 at 7:41 AM Parkhurst, David  wrote:
>
> I just sent a subset of the data, with a dataframe called test.  Can you see 
> that?  It may not have been approved by the moderator yet.
>
> DFP (iPad)
>
> > On Sep 19, 2022, at 5:29 PM, Jim Lemon  wrote:
> >
> > Hi David,
> > Since you used read.csv to get the data frame, the file must be i text
> > format. If you can include a few lines of the input (with made up NO2
> > values if necessary), it would be easy to respond with the required
> > commands and a plot.
> >
> > Jim
> >
> >> On Mon, Sep 19, 2022 at 9:12 PM Parkhurst, David  
> >> wrote:
> >>
> >> I’ve been retired since ‘06 and have forgotten most of R.  Now I have a 
> >> use for it, with some data from Bloomington’s Environmental Commission.
> >>
> >> I have a dataframe (obtained from read.csv) that contains numerous 
> >> columns, including time (in Excel’s 18:00 format), and DNO2, and MNO2 from 
> >> two air quality instruments.
> >>
> >> I’d like a plot of both the NO2 measurements against time.  I be happy to 
> >> use either ordinary R plots or ggplot2 ones, if that would be a better 
> >> way.  I’d much appreciate help.
> >>
> >>[[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-19 Thread Jim Lemon
Hi David,
Since you used read.csv to get the data frame, the file must be i text
format. If you can include a few lines of the input (with made up NO2
values if necessary), it would be easy to respond with the required
commands and a plot.

Jim

On Mon, Sep 19, 2022 at 9:12 PM Parkhurst, David  wrote:
>
> I’ve been retired since ‘06 and have forgotten most of R.  Now I have a use 
> for it, with some data from Bloomington’s Environmental Commission.
>
> I have a dataframe (obtained from read.csv) that contains numerous columns, 
> including time (in Excel’s 18:00 format), and DNO2, and MNO2 from two air 
> quality instruments.
>
> I’d like a plot of both the NO2 measurements against time.  I be happy to use 
> either ordinary R plots or ggplot2 ones, if that would be a better way.  I’d 
> much appreciate help.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-19 Thread Ebert,Timothy Aaron
David,
   Do these work for you? (I am resending this so others can see. The original 
only went to you.)

library(lubridate)
a<-c(4, 5, 6)
b<-c("18:00", "18:01", "18:02")
c<-as.data.frame(cbind(a,b))
c$d<-hm(c$b)
c$d$minute[2]

I could do it manually like this (where FrHour is fractional hour)
a<-c(4, 5, 6)
b<-c("18:00", "18:09", "18:42")
c<-as.data.frame(cbind(a,b))
c$d<-hm(c$b)
c$d$minute[2]
c$Hour=as.numeric(substr(c$b,1,2))
c$Second=as.numeric(substr(c$b,4,5))
c$FrHour <- c$Hour + c$Second/60

As I was writing Rui posted another option with code for graphing.

Tim

-Original Message-
From: R-help  On Behalf Of Parkhurst, David
Sent: Sunday, September 18, 2022 4:27 PM
To: r-help@r-project.org
Subject: [R] Need help plotting

[External Email]

I�ve been retired since �06 and have forgotten most of R.  Now I have a use for 
it, with some data from Bloomington�s Environmental Commission.

I have a dataframe (obtained from read.csv) that contains numerous columns, 
including time (in Excel�s 18:00 format), and DNO2, and MNO2 from two air 
quality instruments.

I�d like a plot of both the NO2 measurements against time.  I be happy to use 
either ordinary R plots or ggplot2 ones, if that would be a better way.  I�d 
much appreciate help.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-19 Thread Bert Gunter
See ?date-time and/or ?strptime for how to convert what I presume is
character data in your datetime column to a POSIXct object. (you may first
need to convert from a factor to character with as.character() ). Then
follow Tim's prescription for ggplot or see ?axis.Date (especially the
examples) for how to do it with base R plots.

Cheers,
Bert

On Mon, Sep 19, 2022 at 5:15 AM Ebert,Timothy Aaron  wrote:

> My version of this email has a bunch of ? that I do not know how to
> interpret. Emails to this group need to be in plain text. HTML content is
> deleted or converted and impossible or at least difficult to interpret.
>
> Do not share confidential data. Please change some numbers or variable
> names and share that.
> If this helps:
> 1) Make sure your time variable is a datetime object.
> 2) At least in ggplot it should now behave as expected.
> ggplot(df, aes(y=NO2, x=datetime)) + geom_point()
>
> That will be a start as a scatterplot, but the graph can be customized or
> changed if scatterplot was not desired.
>
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of Parkhurst, David
> Sent: Sunday, September 18, 2022 4:27 PM
> To: r-help@r-project.org
> Subject: [R] Need help plotting
>
> [External Email]
>
> I�ve been retired since �06 and have forgotten most of R.  Now I have a
> use for it, with some data from Bloomington�s Environmental Commission.
>
> I have a dataframe (obtained from read.csv) that contains numerous
> columns, including time (in Excel�s 18:00 format), and DNO2, and MNO2 from
> two air quality instruments.
>
> I�d like a plot of both the NO2 measurements against time.  I be happy to
> use either ordinary R plots or ggplot2 ones, if that would be a better
> way.  I�d much appreciate help.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help plotting

2022-09-19 Thread Ebert,Timothy Aaron
My version of this email has a bunch of ? that I do not know how to interpret. 
Emails to this group need to be in plain text. HTML content is deleted or 
converted and impossible or at least difficult to interpret.

Do not share confidential data. Please change some numbers or variable names 
and share that.
If this helps:
1) Make sure your time variable is a datetime object. 
2) At least in ggplot it should now behave as expected.
ggplot(df, aes(y=NO2, x=datetime)) + geom_point()

That will be a start as a scatterplot, but the graph can be customized or 
changed if scatterplot was not desired.

Tim

-Original Message-
From: R-help  On Behalf Of Parkhurst, David
Sent: Sunday, September 18, 2022 4:27 PM
To: r-help@r-project.org
Subject: [R] Need help plotting

[External Email]

I�ve been retired since �06 and have forgotten most of R.  Now I have a use for 
it, with some data from Bloomington�s Environmental Commission.

I have a dataframe (obtained from read.csv) that contains numerous columns, 
including time (in Excel�s 18:00 format), and DNO2, and MNO2 from two air 
quality instruments.

I�d like a plot of both the NO2 measurements against time.  I be happy to use 
either ordinary R plots or ggplot2 ones, if that would be a better way.  I�d 
much appreciate help.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help plotting

2022-09-19 Thread Parkhurst, David
I�ve been retired since �06 and have forgotten most of R.  Now I have a use for 
it, with some data from Bloomington�s Environmental Commission.

I have a dataframe (obtained from read.csv) that contains numerous columns, 
including time (in Excel�s 18:00 format), and DNO2, and MNO2 from two air 
quality instruments.

I�d like a plot of both the NO2 measurements against time.  I be happy to use 
either ordinary R plots or ggplot2 ones, if that would be a better way.  I�d 
much appreciate help.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help

2022-08-05 Thread Md. Moyazzem Hossain
Dear All,

Thank you very much for all of your help. If anyone feels unhappy with my
words then I apologize.

Actually, I am not an expert user as a result my coding seems to be wrong
on some points. Now, it is working.

I am thankful to all of you for your kind support. Take care.

Hossain



On Fri, Aug 5, 2022 at 4:27 AM Andrew Simmons  wrote:

> Hello again,
>
>
> Since the GEV distribution and the GPD distribution are similar, I was
> able to make dgpd, pgpd, qgpd, and rgpd with no trouble. You should be able
> to use the same piece of code I gave earlier to install the package, here
> it is again:
>
> install.packages(c("this.path", "essentials"), repos = "
> https://raw.githubusercontent.com/ArcadeAntics/PACKAGES;)
>
> I tried to make your code a little nicer and also use 'pgpd', let me know
> if this behaves as expected.
>
> #
> library(essentials)
> a <- rnorm(1000, 110, 5)
> b <- rnorm(1000, -0.3, 0.4)
> s <- length(a)
> lam <- 0.15
> thr <- 70
> r <- 10
>
> ff <- function(zz) {
> inner <- numeric(s)
> for (k in 1:s) {
> inner[k] <- 1 - lam * pgpd(zz, location = thr, scale = a[k], shape
> = b[k], lower.tail = FALSE)
> }
>
>
> # if zz is length 1 (it is for uniroot), it would be much faster to do
> this:
> # inner <- 1 - lam * pgpd(zz, location = thr, scale = a, shape = b,
> lower.tail = FALSE)
> #
> # use whichever you please
>
> mean(inner) - (1 - 1/r)
> }
> 
> out <- uniroot(ff, lower = 0, upper = 1)$root
> out
>
> On Thu, Aug 4, 2022 at 3:17 PM Md. Moyazzem Hossain 
> wrote:
>
>> Dear Andrew Simmons,
>>
>> Thank you very much.
>>
>> Actually, I want to calculate the predictive return level of GPD and
>> compare it with the return level to see the difference. I have used the
>> following function before but it does not provide the results as expected.
>> It is OK for GEV but not GPD.
>>
>> inner[k] = pgpd(zz, scale = a[k],  shape = b[k] )
>>
>> Other lines of the code were the same.
>>
>> Please help me to calculate the predictive return level of GPD.
>>
>> Thanks in advance.
>>
>> Hossain
>>
>> On Thu, Aug 4, 2022 at 5:11 PM Andrew Simmons  wrote:
>>
>>> Is this a GEV distribution by chance? If so, I made functions dgev,
>>> pgev, qgev, and rgev that you can find install with:
>>>
>>> install.packages(c("this.path", "essentials"), repos = "
>>> https://raw.githubusercontent.com/ArcadeAntics/PACKAGES;)
>>>
>>> and then in your R script
>>>
>>> library(essentials)
>>> dgev(...) or pgev or qgev as needed
>>>
>>> On Thu, Aug 4, 2022, 09:31 Md. Moyazzem Hossain 
>>> wrote:
>>>
 Dear R Experts,

 I hope that you are doing well.

 I am facing a problem to find out the value of the following function. I
 need help in this regard.

 #
 a=rnorm(1000, 110, 5)
 b = rnorm(1000, -0.3, 0.4)
 s = length(a)
 lam=0.15
 thr=70
 r= 10

 ff = function(zz){
   inner = vector("numeric", length = s)
  for(k in 1:s){
   inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
   }
   answer = mean(inner)- (1- (1/r))
   return(answer)
   }
 
 out=uniroot(ff, lower = 0, upper = 1 )$root
 out

 ### Error 
 Error in uniroot(ff, lower = 0, upper = 1) :
   f.upper = f(upper) is NA

 Please help me. Thanks in advance.

 Take care.

 Hossain

 --
 Best Regards,
 Md. Moyazzem Hossain
 Associate Professor
 Department of Statistics
 Jahangirnagar University
 Savar, Dhaka-1342, Bangladesh

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

>>>
>>
>> --
>> Best Regards,
>> Md. Moyazzem Hossain
>> Associate Professor
>> Department of Statistics
>> Jahangirnagar University
>> Savar, Dhaka-1342, Bangladesh
>> Website: http://www.juniv.edu/teachers/hossainmm
>> Research: *[image: Google Scholar]
>> * | 
>> *ResearchGate
>> * | *ORCID iD
>> *
>>
>

-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342, Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *[image: Google Scholar]
* | *ResearchGate
* | *ORCID iD
*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing 

Re: [R] Need help

2022-08-04 Thread avi.e.gross


Another exceedingly polite questioner. Cultural differences!

I think we can skip discussing if we are doing well, and get to the point.

To start with, I got thrown by these two lines:

a=rnorm(1000, 110, 5)
s = length(a)

This does not relate to the difficulty, but is a sort of sloppy use as a was
created with a request to be 1,000 random numbers. No need to calculate the
length. You could just say 

s <- 1000

We have no idea what the purpose of your function ff is meant to be used for
and what it is normally given as an argument as you seem to just pass the
function as an argument to a stats package function called uniroot. As such,
the function should return values for a given argument that can be evaluated
between lower and upper bounds. OK, it took some time to look things up that
would have been easier had you told us a bit more.
 
But it gets worse as your function references "s" in this line within:

inner = vector("numeric", length = s)

You are not passing s to the function but using it from outside to make an
empty variable of the same length? Similarly, you are putting other
variables like r, lam, thr  in a global environment and using it within the
function. Is this a good design?

As other have pointed out, you should evaluate the function ff to see what
it returns on it's own, not wait for uniroot to fail in calling it.

Your function ff seems to make a vector of 1,000 complicated values based on
the global values including the values in "a" and 'b" that are random then
take the mean of the results with an adjustment.  I have no idea if your
code is modeled after anything in particular or is correct. But I exercised
it in the lower range and it produces reasonable numbers:

sapply(0:10,ff)
 [1] -0.1715207 -0.1693173 -0.1671317 -0.1649635 -0.1628125 -0.1606784
-0.1585609 -0.1564598
 [9] -0.1543749 -0.1523059 -0.1502526

But in the upper range your function returns a NaN or NOT A NUMBER

sapply(9995:1,ff)
[1] NaN NaN NaN NaN NaN NaN

That would explain the error message.

So you need to look at ff and see how the NaN is introduced perhaps just for
larger numbers. You may have an overflow problem for example where you are
making number too large to fit. Who knows?

What I know is when I make your 10,001 calculations only the first 140 or so
are not Nan. ff(142) and beyond all fail.

> sapply(0:1,ff) -> temp
> sum(is.nan(temp))
[1] 9859

So it may be obvious to you why zz-thr has such a threshold, but not to me.

I would try to make sure you implemented the algorithm required correctly in
the code and that the range of random numbers you select fits the needs. If
you can get ff() to return only valid numbers, it may be a step. And note
that when I change the mean() function you call to add na.rm=TRUE, it
removes the NaN from the calculation (albeit that should not mean it is now
correct) and a new error shows up:

> ff = function(zz){
+ inner = vector("numeric", length = s)
+ for(k in 1:s){
+ inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
+ }
+ answer = mean(inner, na.rm=TRUE)- (1- (1/r))
+ return(answer)
+ }

> out=uniroot(ff, lower = 0, upper = 1 )$root out
Error: unexpected symbol in "out=uniroot(ff, lower = 0, upper = 1 )$root
out"

You left a dangling " out" at the end. You may mean:

out=uniroot(ff, lower = 0, upper = 1 )$root

My current result is 111.6597 but as noted is meaningless as I threw out
lots of NaN.



-Original Message-
From: R-help  On Behalf Of Md. Moyazzem
Hossain
Sent: Thursday, August 4, 2022 9:31 AM
To: r-help mailing list 
Subject: [R] Need help

Dear R Experts,

I hope that you are doing well.

I am facing a problem to find out the value of the following function. I
need help in this regard.

#
a=rnorm(1000, 110, 5)
b = rnorm(1000, -0.3, 0.4)
s = length(a)
lam=0.15
thr=70
r= 10

ff = function(zz){
  inner = vector("numeric", length = s)
 for(k in 1:s){
  inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
  }
  answer = mean(inner)- (1- (1/r))
  return(answer)
  }

out=uniroot(ff, lower = 0, upper = 1 )$root out

### Error 
Error in uniroot(ff, lower = 0, upper = 1) :
  f.upper = f(upper) is NA

Please help me. Thanks in advance.

Take care.

Hossain

--
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342, Bangladesh

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://s

Re: [R] Need help

2022-08-04 Thread Rui Barradas

And for the sake of completeness


which(!ok)
sapply(out_list[!ok], conditionMessage)

Hope this helps,

Rui Barradas

Às 16:24 de 04/08/2022, Rui Barradas escreveu:

Hello,

Like others have said, the root does depend on the seed but not by much.
Here is a loop finding the roots for seeds from 1 to 10,000.

I have defined a variable n == 1000 instead of having the calls to rnorm 
depend on a hard-coded constant.




ff <- function(zz){
   inner = vector("numeric", length = s)
   for(k in 1:s){
     inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
   }
   answer = mean(inner) - (1 - (1/r))
   return(answer)
}

n <- 1000
s <- n
lam <- 0.15
thr <- 70
r <- 10

up_lims <- 112.5   # found by trial and error to be nice most
    # of the time, see mean(ok) below
out_list <- vector("list", length = 1e4)

for(i in seq_along(out_list)) {
   # give the user feedback
   if(i %% 100 == 0) print(i)

   set.seed(i)
   a <- rnorm(n, 110, 5)
   b <- rnorm(n, -0.3, 0.4)

   out_list[[i]] <- tryCatch(
     uniroot(ff, lower = 0, upper = up_lims),
     error = function(e) e
   )
}

ok <- !sapply(out_list, inherits, 'error')
mean(ok)
#[1] 0.9978

root <- sapply(out_list[ok], '[[', 'root')
hist(root)



Hope this helps,

Rui Barradas

Às 15:37 de 04/08/2022, Ebert,Timothy Aaron escreveu:

And one last edit.
Rstudio Environment shows out$root as 112. However, if I then print 
out$root I get 111.5303 which is much closer to the right answer.  
Entering values for ff, I can work out the answer to slightly more 
than 111.53030196.


Regards,
Tim

-Original Message-
From: Ebert,Timothy Aaron 
Sent: Thursday, August 4, 2022 10:28 AM
To: Ebert,Timothy Aaron ; Md. Moyazzem Hossain 
; J C Nash 

Cc: r-help mailing list 
Subject: RE: [R] Need help

I wish I could edit my earlier reply.
ff(144.43) returns 0.03142121, but ff(144.44) returns NaN.
ff(12) returns -0.1468287

out=uniroot(ff, lower=12, upper =144) does not have errors.
out is a list of 5.
$root is 112
$f.root is 1.09e-08
$iter is 5
$Init.it is NA
$estim.prec is 6.1e-05

Is this working?

Regards,
Tim

-Original Message-
From: R-help  On Behalf Of Ebert,Timothy 
Aaron

Sent: Thursday, August 4, 2022 10:09 AM
To: Md. Moyazzem Hossain ; J C Nash 


Cc: r-help mailing list 
Subject: Re: [R] Need help

[External Email]

A few issues
1) What does this function do? If you describe the problem and goal 
there might be a better answer. We appreciate seeing that you have 
attempted a solution, but you have trapped us all in blindly following 
your attempt.


2) This is an error checking phase of programming. Setting the seed is 
a good idea. Just remember to unset the seed after finishing the 
debugging phase.


3) In uniroot you call the function, but the function expects an 
argument (zz) that is not provided, and there is no default.


4) I set.seed(42), and entered ff(12) getting an answer of -0.1468287. 
Is this the expected result?


Regards,
Tim

-Original Message-
From: R-help  On Behalf Of Md. Moyazzem 
Hossain

Sent: Thursday, August 4, 2022 9:50 AM
To: J C Nash 
Cc: r-help mailing list 
Subject: Re: [R] Need help

[External Email]

Dear JN,

Thanks.

I do not check whether the function actually crosses zero or not. 
However, by assumption, the value would be greater than zero.


Hossain

On Thu, Aug 4, 2022 at 2:40 PM J C Nash  wrote:


Have you checked that your function actually crosses zero?

You should also set a seed if you want a reproducible result.

JN

On 2022-08-04 09:30, Md. Moyazzem Hossain wrote:

Dear R Experts,

I hope that you are doing well.

I am facing a problem to find out the value of the following
function. I need help in this regard.

#
a=rnorm(1000, 110, 5)
b = rnorm(1000, -0.3, 0.4)
s = length(a)
lam=0.15
thr=70
r= 10

ff = function(zz){
    inner = vector("numeric", length = s)
   for(k in 1:s){
    inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
    }
    answer = mean(inner)- (1- (1/r))
    return(answer)
    }

out=uniroot(ff, lower = 0, upper = 1 )$root out

### Error 
Error in uniroot(ff, lower = 0, upper = 1) :
    f.upper = f(upper) is NA

Please help me. Thanks in advance.

Take care.

Hossain






--
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342, Bangladesh
Website: 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.juniv.edu%2Fteachers%2Fhossainmmdata=05%7C01%7Ctebert%40ufl.edu%7C92190c03aa824920e8a108da76258618%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637952200791209718%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=3GVM6FLCtmP9oKjjtVzE0LZpI6LL8ldXknodpFQJUbM%3Dreserved=0 


Research: *[image: Google Scholar]
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fscholar.google.com%2F

[R] Need help

2022-08-04 Thread Md. Moyazzem Hossain
Dear R Experts,

I hope that you are doing well.

I am facing a problem to find out the value of the following function. I
need help in this regard.

#
a=rnorm(1000, 110, 5)
b = rnorm(1000, -0.3, 0.4)
s = length(a)
lam=0.15
thr=70
r= 10

ff = function(zz){
  inner = vector("numeric", length = s)
 for(k in 1:s){
  inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
  }
  answer = mean(inner)- (1- (1/r))
  return(answer)
  }

out=uniroot(ff, lower = 0, upper = 1 )$root
out

### Error 
Error in uniroot(ff, lower = 0, upper = 1) :
  f.upper = f(upper) is NA

Please help me. Thanks in advance.

Take care.

Hossain

-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342, Bangladesh

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in ggplot

2022-06-28 Thread Md. Moyazzem Hossain
Dear Rui Barradas

Thank you very much for your prompt reply.

It works. I am grateful for your help.

Take care and best wishes.

Hossain


On Tue, Jun 28, 2022 at 5:45 PM Rui Barradas  wrote:

> Hello,
>
> scale_*_manual expects a discrete vector as values, you are passing it a
> continuous one. The natural way of having a continuous variable set the
> color and fill values is with a gradient scale.
>
> I have changed geom_bar to geom_col.
> Map prob to the fill aesthetic. Then, in scale_fill_continuous set low
> and high values to
>
>   - the highest possible (all zeros is black).
>   - and to the lowest in the scale of probabilities (all binary ones or
> hexa FF's is bright white)
>
> Note that this reverses the real line order relation, you want to map
> low probabilities to high binary/hexa values and vice-versa.
>
> Don't mind the theme() setting a yellow panel background fill, it's just
> meant to see better that the bars are in shades of gray.
>
>
>
> library(ggplot2)
>
> predictors <- c("x1", "x2", "x3", "x4", "x5")
> values <- c(1.0, 0.67, 0.26, 0.18, 0.17)
> prob <- c(1.0, 0.001, 0.957, 0.924, 0.253)
>
> df <- data.frame(predictors, values, prob)
>
> ggplot(df, aes(x = predictors, y = values) ) +
>geom_col(aes(fill = prob)) +
>coord_flip() +
>scale_fill_gradient(low = "#FF", high = "#00") +
>theme(panel.background = element_rect(fill = "yellow"))
>
>
>
> If you want to use scale_fill_manual, create a vector of values first, then
>
>   - Map variable predictors to the fill aesthetic since each precitor
> value has an associated probability prob;
>   - make values equal to gray_vals.
>
>
> gray_vals <- setNames(gray(df$prob), df$predictors)
>
> ggplot(df, aes(x = predictors, y = values) ) +
>geom_col(aes(fill = predictors)) +
>coord_flip() +
>scale_fill_manual(values = gray_vals) +
>theme(panel.background = element_rect(fill = "yellow"))
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 15:07 de 28/06/2022, Md. Moyazzem Hossain escreveu:
> > Dear R- Experts,
> >
> > I hope that you are doing well.
> >
> > I am facing a problem with adding color to a barplot. My target is to
> add a
> > bar color conditioning on the following
> >
> > Values close to 1 represent "White" and values tend to 0 represent
> "Black".
> >
> > However, I failed. The code is given below. I will be happy and thankful
> if
> > anyone helps me in this regard.
> >
> > Thanks in advance.
> >
> > library(ggplot2)
> > predictors=c("x1", "x2", "x3", "x4", "x5")
> > values=c(1.0, 0.67, 0.26, 0.18, 0.17)
> > prob=c(1.0, 0.001, 0.957, 0.924, 0.253)
> >
> > df <- data.frame(predictors, values, prob)
> > ggplot(df, aes(x=predictors, y=values) ) +
> >geom_bar(stat="identity") +
> >coord_flip()+
> >scale_fill_manual(values=c("gray(prob)"))
> >
> > Best Regards,
> >
> > *Hossain*
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>


-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342, Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *[image: Google Scholar]
* | *ResearchGate
* | *ORCID iD
*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in ggplot

2022-06-28 Thread Rui Barradas

Hello,

scale_*_manual expects a discrete vector as values, you are passing it a 
continuous one. The natural way of having a continuous variable set the 
color and fill values is with a gradient scale.


I have changed geom_bar to geom_col.
Map prob to the fill aesthetic. Then, in scale_fill_continuous set low 
and high values to


 - the highest possible (all zeros is black).
 - and to the lowest in the scale of probabilities (all binary ones or 
hexa FF's is bright white)


Note that this reverses the real line order relation, you want to map 
low probabilities to high binary/hexa values and vice-versa.


Don't mind the theme() setting a yellow panel background fill, it's just 
meant to see better that the bars are in shades of gray.




library(ggplot2)

predictors <- c("x1", "x2", "x3", "x4", "x5")
values <- c(1.0, 0.67, 0.26, 0.18, 0.17)
prob <- c(1.0, 0.001, 0.957, 0.924, 0.253)

df <- data.frame(predictors, values, prob)

ggplot(df, aes(x = predictors, y = values) ) +
  geom_col(aes(fill = prob)) +
  coord_flip() +
  scale_fill_gradient(low = "#FF", high = "#00") +
  theme(panel.background = element_rect(fill = "yellow"))



If you want to use scale_fill_manual, create a vector of values first, then

 - Map variable predictors to the fill aesthetic since each precitor 
value has an associated probability prob;

 - make values equal to gray_vals.


gray_vals <- setNames(gray(df$prob), df$predictors)

ggplot(df, aes(x = predictors, y = values) ) +
  geom_col(aes(fill = predictors)) +
  coord_flip() +
  scale_fill_manual(values = gray_vals) +
  theme(panel.background = element_rect(fill = "yellow"))


Hope this helps,

Rui Barradas

Às 15:07 de 28/06/2022, Md. Moyazzem Hossain escreveu:

Dear R- Experts,

I hope that you are doing well.

I am facing a problem with adding color to a barplot. My target is to add a
bar color conditioning on the following

Values close to 1 represent "White" and values tend to 0 represent "Black".

However, I failed. The code is given below. I will be happy and thankful if
anyone helps me in this regard.

Thanks in advance.

library(ggplot2)
predictors=c("x1", "x2", "x3", "x4", "x5")
values=c(1.0, 0.67, 0.26, 0.18, 0.17)
prob=c(1.0, 0.001, 0.957, 0.924, 0.253)

df <- data.frame(predictors, values, prob)
ggplot(df, aes(x=predictors, y=values) ) +
   geom_bar(stat="identity") +
   coord_flip()+
   scale_fill_manual(values=c("gray(prob)"))

Best Regards,

*Hossain*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help in ggplot

2022-06-28 Thread Md. Moyazzem Hossain
Dear R- Experts,

I hope that you are doing well.

I am facing a problem with adding color to a barplot. My target is to add a
bar color conditioning on the following

Values close to 1 represent "White" and values tend to 0 represent "Black".

However, I failed. The code is given below. I will be happy and thankful if
anyone helps me in this regard.

Thanks in advance.

library(ggplot2)
predictors=c("x1", "x2", "x3", "x4", "x5")
values=c(1.0, 0.67, 0.26, 0.18, 0.17)
prob=c(1.0, 0.001, 0.957, 0.924, 0.253)

df <- data.frame(predictors, values, prob)
ggplot(df, aes(x=predictors, y=values) ) +
  geom_bar(stat="identity") +
  coord_flip()+
  scale_fill_manual(values=c("gray(prob)"))

Best Regards,

*Hossain*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with merging .RDS data frame yield value with district shapefile corresponding GDMID and plot the graph

2022-05-12 Thread Ranjeet Kumar Jha
Hi David,

As suggested earlier, providing the link of a folder contains all files.

https://drive.google.com/drive/folders/1dNmGTI8_c9PK1QqmfIjnpbyzuiCXgxFC?msclkid=4816425dd04111ec912cf8b4175aa93c

Thanks,
Ranjeet

On Wed, May 11, 2022 at 9:35 PM David Winsemius 
wrote:

>
> On 5/9/22 10:01, Ranjeet Kumar Jha wrote:
> > Thanks for your reply. Though codes are in
> > " yield. r" file.
>
>
> You need to pay better attention to what Bert said about your
> attachment. `.r` files are not allowed as an attachment type. You need
> to either provide a link to a publicly accessible location or include
> the code inline.
>
>
> --
>
> David
>
> >
> > Ranjeet
> >
> > On Mon, 9 May 2022, 7:58 pm Bert Gunter,  wrote:
> >
> >> 1. No code came through. Most attachments are filtered due to security
> >> concerns. See the posting guide (linked below) for details.
> >>
> >> 2. Geo-type questions are better posted on r-sig-geo,
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo, rather than here.
> >>
> >> Bert Gunter
> >>
> >> "The trouble with having an open mind is that people keep coming along
> and
> >> sticking things into it."
> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >>
> >>
> >> On Mon, May 9, 2022 at 5:22 AM Ranjeet Kumar Jha <
> >> ranjeetjhaiit...@gmail.com> wrote:
> >>
> >>> Hello Everyone,
> >>>
> >>> I am trying to plot an Indian district shapefile filled with modeled
> >>> yield,
> >>> corresponding to each GDMID. I needed to first merge the Yield data
> with
> >>> respect to each GDMID from the .RDS file with the district shapefile of
> >>> India. Each district is represented by a GDMID. After merging, the
> Indian
> >>> district map filled with modeled yield values needs to be plotted
> similar
> >>> to an example attached figure.
> >>>
> >>> I feel there is something wrong with my code for merging and plotting
> by
> >>> ggplot.
> >>>
> >>> I have attached herewith my code, .RDS dataframe, shapefile and sample
> >>> example fig.
> >>>
> >>> It would be great if you could help me with merging issue and plotting
> the
> >>> map, showing yield value, and legend in tile format.
> >>>
> >>> Regards and Thanks,
> >>> Ranjeet
> >>>
> >>> --
> >>> __
> >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> >>> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>


-- 
Ranjeet  Kumar Jha, M.Tech. (IIT Kharagpur), Ph.D. (USA)
https://www.linkedin.com/in/ranjeet-kumar-jha-ph-d-usa-73a5aa56
---
Email: *ranjeetjhaiit...@gmail.com *


*"Simple Heart, Humble Attitude and Surrender to Supreme Being make our
lives beautiful!"*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with netmeta package

2022-04-18 Thread Roopa Subbaiah
Dear Bert,


Thank you. Will do the same

Regards, Roopa

On Sat 16 Apr, 2022, 2:22 AM Bert Gunter  While you *may* get a useful reply here, there is an
> r-sig-meta-analysis list to which this would be better posted:
> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Fri, Apr 15, 2022 at 1:04 PM Roopa Subbaiah 
> wrote:
> >
> > Hi all,
> >
> > We are conducting network metaanalysis of 3 treatments compared to
> placebo
> > using netmeta analysis. We have mean sd values for an outcome. How do we
> > calculate z scores using netmeta package? Thank you
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help with netmeta package

2022-04-15 Thread Bert Gunter
While you *may* get a useful reply here, there is an
r-sig-meta-analysis list to which this would be better posted:
https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, Apr 15, 2022 at 1:04 PM Roopa Subbaiah  wrote:
>
> Hi all,
>
> We are conducting network metaanalysis of 3 treatments compared to placebo
> using netmeta analysis. We have mean sd values for an outcome. How do we
> calculate z scores using netmeta package? Thank you
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help with netmeta package

2022-04-15 Thread Roopa Subbaiah
Hi all,

We are conducting network metaanalysis of 3 treatments compared to placebo
using netmeta analysis. We have mean sd values for an outcome. How do we
calculate z scores using netmeta package? Thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help with writing survey design for multilevel analysis

2022-01-26 Thread Love Umesi
Hello,

I am new in using R, and I need to run a multilevel analysis (on two
levels) using Cox frailty survival model on a survey data (Nigeria
Demographic and Health Survey Data).

My problem is how to write the design weight using the two weights needed
and apply them to the analysis.

I have identified the needed variables for the survey design, which are :

psu/cluster=~v021
individual-level weight=~wt1_1
cluster-level weigh=~wt2_1
strata/stratum=~v022

Please can someone help me with the survey design (svydesign) code and how
to include it and the weights in a model.

I have tried to generate a minimum reproducible data

To view the minimum reproducible data: datapasta::df_paste (head(rcom2018,
10)[, c('pid', 'study_time', 'died', 'v021', 'v022', 'wt2_1', 'wt1_1',
'v024', 'v025', 'mat_edu')])


I understand I have to use svycoxph in the model. Please how do I include
survey design and account for the 2 weights in the gamma frailty model
below?

Frailty1 <- coxph (Surv(study_time, died) ~ factor(v024) + factor(mat_edu)
+ v025 + frailty(v021,distribution="gamma"), data=rcom2018)


Really looking forward to your help as my project is hanging on this.

Many thanks.

Love Umesi

library(survey)#> Warning: package 'survey' was built under R version
4.0.5#> Loading required package: grid#> Loading required package:
Matrix#> Loading required package: survival#> Warning: package
'survival' was built under R version 4.0.5#> #> Attaching package:
'survey'#> The following object is masked from 'package:graphics':#>
#> dotchart
library(survival)


rcom1 <- data.frame(
 pid = c(1,2,3,4,
 5,6,7,8,9,10,11,12,13,14,15,16,17,
 18,19,20,21,22,23,24,25,26,27,28,29,
 30,31,32,33,34,35,36,37,38,39,40,
 41,42,43,44,45,46,47,48,49,50),
  study_time = c(13,9,17,
 31,39,22,24,0,23,12,9,35,18,20,60,
 18,5,46,26,54,37,51,31,55,27,15,39,6,
 29,0,9,40,23,12,35,56,14,40,57,42,
 5,42,39,39,54,19,52,42,7,28),
died = c(0,0,0,0,
 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
v021 = c(1,1,1,1,
 1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,
 2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,
 3,3,3,3,3,3,3,3,3,3,3,3,3,4,4),
v022 = c("1","1",
 "1","1","1","1","1","1","1","1","1","1",
 "1","1","1","1","1","1","1","1","1",
 "1","1","1","1","1","1","1","1","1",
 "1","1","1","1","1","1","1","1","1","1",
 "1","1","1","1","1","1","1","1","1",
 "1"),
v012 = c(40,37,27,
 27,24,32,35,35,34,20,28,28,26,24,24,
 25,26,26,26,26,28,27,25,25,27,26,
 26,21,21,31,36,36,27,23,32,32,33,33,
 33,28,25,37,33,34,33,28,28,29,33,33),
   wt2_1 =
c(401.200012207031,401.200012207031,401.200012207031,
 401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,
 401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,
 401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,
 401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,
 401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,
 401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031,
 401.200012207031,401.200012207031,

401.200012207031,401.200012207031,401.200012207031),
   wt1_1 =
c(2.5074667930603,2.5074667930603,2.5074667930603,

2.5074667930603,2.5074667930603,2.5074667930603,

2.5074667930603,2.5074667930603,2.5074667930603,
 2.5074667930603,2.5074667930603,

2.5074667930603,2.5074667930603,2.5074667930603,

2.5074667930603,5.1194109916687,5.1194109916687,

5.1194109916687,5.1194109916687,5.1194109916687,
   

Re: [R] Need help to print matrix with element and position

2021-10-28 Thread Rui Barradas

Hello,

With no loops:


cbind(
  row = c(t(row(mat_1))),
  col = c(t(col(mat_1))),
  mat_1 = as.numeric(t(mat_1))
)


If the matrix entries are not numeric, use cbind.data.frame. This will 
keep the row and column numbers as numbers, the default cbind method 
would coerce them to the class of mat_1's elements.



cbind.data.frame(
  row = c(t(row(mat_1))),
  col = c(t(col(mat_1))),
  mat_1 = c(t(mat_1))
)


Hope this helps,

Rui Barradas


Às 09:19 de 28/10/21, Anas Jamshed escreveu:

I create a matrix of size 3x3 called mat_1 and then I want to iterate over
all the values one by one and print the element as well as the position in
the matrix:

My code is :

mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
3,byrow = TRUE)
mat_1
# Loop over my_matrix
for(row in 1:nrow(mat_1)) {
 for(col in 1:ncol(mat_1)) {
 print(mat_1[row, col])
 }
}

But I don't know how to print elements and positions as well of this matrix?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to print matrix with element and position

2021-10-28 Thread Jim Lemon
mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
3,byrow = TRUE)
mat_1
# Loop over my_matrix
for(row in 1:nrow(mat_1)) {
for(col in 1:ncol(mat_1)) {
cat(row,col,mat_1[row,col],"\n")
}
}

On Thu, Oct 28, 2021 at 8:01 PM Anas Jamshed  wrote:
>
> where should I place  cat(row,col,mat_1[row,col],"\n")?
>
> On Thu, Oct 28, 2021 at 1:58 PM Jim Lemon  wrote:
>>
>> Hi Anas,
>> How about:
>>
>> cat(row,col,mat_1[row,col],"\n")
>>
>> Jim
>>
>> On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed  
>> wrote:
>> >
>> > I create a matrix of size 3x3 called mat_1 and then I want to iterate over
>> > all the values one by one and print the element as well as the position in
>> > the matrix:
>> >
>> > My code is :
>> >
>> > mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
>> > 3,byrow = TRUE)
>> > mat_1
>> > # Loop over my_matrix
>> > for(row in 1:nrow(mat_1)) {
>> > for(col in 1:ncol(mat_1)) {
>> > print(mat_1[row, col])
>> > }
>> > }
>> >
>> > But I don't know how to print elements and positions as well of this 
>> > matrix?
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to print matrix with element and position

2021-10-28 Thread Anas Jamshed
where should I place  cat(row,col,mat_1[row,col],"\n")?

On Thu, Oct 28, 2021 at 1:58 PM Jim Lemon  wrote:

> Hi Anas,
> How about:
>
> cat(row,col,mat_1[row,col],"\n")
>
> Jim
>
> On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed 
> wrote:
> >
> > I create a matrix of size 3x3 called mat_1 and then I want to iterate
> over
> > all the values one by one and print the element as well as the position
> in
> > the matrix:
> >
> > My code is :
> >
> > mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
> > 3,byrow = TRUE)
> > mat_1
> > # Loop over my_matrix
> > for(row in 1:nrow(mat_1)) {
> > for(col in 1:ncol(mat_1)) {
> > print(mat_1[row, col])
> > }
> > }
> >
> > But I don't know how to print elements and positions as well of this
> matrix?
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to print matrix with element and position

2021-10-28 Thread Jim Lemon
Hi Anas,
How about:

cat(row,col,mat_1[row,col],"\n")

Jim

On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed  wrote:
>
> I create a matrix of size 3x3 called mat_1 and then I want to iterate over
> all the values one by one and print the element as well as the position in
> the matrix:
>
> My code is :
>
> mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
> 3,byrow = TRUE)
> mat_1
> # Loop over my_matrix
> for(row in 1:nrow(mat_1)) {
> for(col in 1:ncol(mat_1)) {
> print(mat_1[row, col])
> }
> }
>
> But I don't know how to print elements and positions as well of this matrix?
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help to print matrix with element and position

2021-10-28 Thread Anas Jamshed
I create a matrix of size 3x3 called mat_1 and then I want to iterate over
all the values one by one and print the element as well as the position in
the matrix:

My code is :

mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
3,byrow = TRUE)
mat_1
# Loop over my_matrix
for(row in 1:nrow(mat_1)) {
for(col in 1:ncol(mat_1)) {
print(mat_1[row, col])
}
}

But I don't know how to print elements and positions as well of this matrix?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R

2021-10-26 Thread Greg Minshall
Bert,

> findprm <- function(n){
>nn <- seq.int(2, n)
>i <- 2
>while(i <= floor(sqrt( n))){
>   nn <- nn[(nn <= i) | (nn %% i > 0)]
>   i <- nn[nn > i][1]
>}
>nn
> }

+1 -- thanks!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R

2021-10-26 Thread Avi Gross via R-help
There can be people doing homework for a course and as noted, the normal
expectation is to use the resources provided including classroom instruction
(or the often ZOOM or recordings) as well as textbooks.

Forums like this are not a substitute and some nice people will sometimes
volunteer not to do homework but help someone a bit such as asking them to
think about the problem, what data structures or loops might be needed OR
help them understand an error message or after seeing their attempts, point
out a subtle flaw.

There are some who are teaching themselves and are not being graded but are
trying little project to learn. But again, it is best they learn for
themselves and not be handed an answer.

Some mailing lists have rules and perhaps might answer someone more if it is
WORK question like how to fine tune a graph after they have most of it
working.

So, I am looking at the follow-up below with a jaundiced eye as I just saw
something similar enough being asked on a Python board. 

The first question strikes me as odd because it contains a completely
un-necessary looking part. 

> > ### Question 1
> > Create a variable containing a sequence of numbers from 1 to 100:
> >
> > Iterate over the variables and print those numbers which are prime.

You do not really need to create a sequence and then again loop over the
same sequence. The following code is shown:

n= seq(1,100)

for (j in n:100) {

Well, the look could have been using n directly or using 1:100 but uses
nonsense. To say n:100 requires n to be an integer, not some kind of
sequence or vector. And why go to 200 in any case? 

The rest gets worse and worse with oddities like using just letters of the
alphabet without meanings as variables, using integers like "f = 1" rather
than Booleans for such flags, and using the "=" operator rather than the
more accepted "<-" operator. The loop uses variable j then ignores it and
keeps manipulating i. 

Someone wanting help might want to let people know what the algorithm is
supposed to do. 

I won't try to guess and certainly won't supply a valid solution here!

-Original Message-
From: R-help  On Behalf Of Anas Jamshed
Sent: Tuesday, October 26, 2021 4:39 PM
To: Rolf Turner 
Cc: R-help Mailing List 
Subject: Re: [R] Need help in R

Its not homework . Basically i want to get easy solution:
I am trying this for ist problem:

n= seq(1,100)

for (j in n:100) {
  f = 1
  i = 2
  n = j
  while (i <= n / 2) {
if (n %% i == 0) {
  f = 0
  break
}
i = i + 1
  }
  if (f == 1) {
print(paste("Number is prime :", n))
  }
}

On Wed, Oct 27, 2021 at 1:35 AM Rolf Turner  wrote:

>
> On Wed, 27 Oct 2021 01:09:50 +0500
> Anas Jamshed  wrote:
>
> > I need help to these questions
> >
> > ### Question 1
> > Create a variable containing a sequence of numbers from 1 to 100:
> >
> > Iterate over the variables and print those numbers which are prime.
> >
> >
> > ### Question 2
> > Create a matrix of size 3x3 called mat_1:
> >
> >  Iterate over all the values one by one and print the element as 
> > well as the position in the matrix (row, col)
>
> You really should do your own homework.
>
> cheers,
>
> Rolf Turner
>
> --
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R

2021-10-26 Thread Bert Gunter
Well, OK. I'll provide you an alternative and explanation.

The way you are going about it would work, but it is usually not the best
approach in R. Typically, the key in R is to whenever possible use whole
object manipulation rather than iteration. This hides the iteration details
and often pushes them down to the much more efficient underlying C code. So
here's one way to do it in R:

findprm <- function(n){
   nn <- seq.int(2, n)
   i <- 2
   while(i <= floor(sqrt( n))){
  nn <- nn[(nn <= i) | (nn %% i > 0)]
  i <- nn[nn > i][1]
   }
   nn
}

Example:
> findprm(66)
 [1]  2  3  5  7 11 13 17 19 23 29 31 37 41 43 47 53 59 61

I'll leave it to you to work out the details for how it works. :-)
And, of course, there are almost certainly even better ways to do this, but
this should get you started.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Oct 26, 2021 at 1:59 PM Anas Jamshed 
wrote:

> Its not homework . Basically i want to get easy solution:
> I am trying this for ist problem:
>
> n= seq(1,100)
>
> for (j in n:100) {
>   f = 1
>   i = 2
>   n = j
>   while (i <= n / 2) {
> if (n %% i == 0) {
>   f = 0
>   break
> }
> i = i + 1
>   }
>   if (f == 1) {
> print(paste("Number is prime :", n))
>   }
> }
>
> On Wed, Oct 27, 2021 at 1:35 AM Rolf Turner 
> wrote:
>
> >
> > On Wed, 27 Oct 2021 01:09:50 +0500
> > Anas Jamshed  wrote:
> >
> > > I need help to these questions
> > >
> > > ### Question 1
> > > Create a variable containing a sequence of numbers from 1 to 100:
> > >
> > > Iterate over the variables and print those numbers which are prime.
> > >
> > >
> > > ### Question 2
> > > Create a matrix of size 3x3 called mat_1:
> > >
> > >  Iterate over all the values one by one and print the element as well
> > > as the position in the matrix (row, col)
> >
> > You really should do your own homework.
> >
> > cheers,
> >
> > Rolf Turner
> >
> > --
> > Honorary Research Fellow
> > Department of Statistics
> > University of Auckland
> > Phone: +64-9-373-7599 ext. 88276
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R

2021-10-26 Thread Anas Jamshed
Its not homework . Basically i want to get easy solution:
I am trying this for ist problem:

n= seq(1,100)

for (j in n:100) {
  f = 1
  i = 2
  n = j
  while (i <= n / 2) {
if (n %% i == 0) {
  f = 0
  break
}
i = i + 1
  }
  if (f == 1) {
print(paste("Number is prime :", n))
  }
}

On Wed, Oct 27, 2021 at 1:35 AM Rolf Turner  wrote:

>
> On Wed, 27 Oct 2021 01:09:50 +0500
> Anas Jamshed  wrote:
>
> > I need help to these questions
> >
> > ### Question 1
> > Create a variable containing a sequence of numbers from 1 to 100:
> >
> > Iterate over the variables and print those numbers which are prime.
> >
> >
> > ### Question 2
> > Create a matrix of size 3x3 called mat_1:
> >
> >  Iterate over all the values one by one and print the element as well
> > as the position in the matrix (row, col)
>
> You really should do your own homework.
>
> cheers,
>
> Rolf Turner
>
> --
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R

2021-10-26 Thread Jeff Newmiller
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

One of the items mentioned in the Posting Guide is that homework questions are 
not okay... we don't know what your instructor is looking for, and they are 
expected to provide support for their instruction plan.

On October 26, 2021 1:09:50 PM PDT, Anas Jamshed  
wrote:
>I need help to these questions
>
>### Question 1
>Create a variable containing a sequence of numbers from 1 to 100:
>
>Iterate over the variables and print those numbers which are prime.
>
>
>### Question 2
>Create a matrix of size 3x3 called mat_1:
>
> Iterate over all the values one by one and print the element as well as
>the position in the matrix (row, col)
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R

2021-10-26 Thread Rolf Turner


On Wed, 27 Oct 2021 01:09:50 +0500
Anas Jamshed  wrote:

> I need help to these questions
> 
> ### Question 1
> Create a variable containing a sequence of numbers from 1 to 100:
> 
> Iterate over the variables and print those numbers which are prime.
> 
> 
> ### Question 2
> Create a matrix of size 3x3 called mat_1:
> 
>  Iterate over all the values one by one and print the element as well
> as the position in the matrix (row, col)

You really should do your own homework.

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R

2021-10-26 Thread Kevin Thorpe
This looks suspiciously like homework and this list does have a no homework 
policy. If it is not homework, please forgive the assumption.


> On Oct 26, 2021, at 4:09 PM, Anas Jamshed  wrote:
> 
> I need help to these questions
> 
> ### Question 1
> Create a variable containing a sequence of numbers from 1 to 100:
> 
> Iterate over the variables and print those numbers which are prime.
> 
> 
> ### Question 2
> Create a matrix of size 3x3 called mat_1:
> 
> Iterate over all the values one by one and print the element as well as
> the position in the matrix (row, col)
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help in R

2021-10-26 Thread Anas Jamshed
I need help to these questions

### Question 1
Create a variable containing a sequence of numbers from 1 to 100:

Iterate over the variables and print those numbers which are prime.


### Question 2
Create a matrix of size 3x3 called mat_1:

 Iterate over all the values one by one and print the element as well as
the position in the matrix (row, col)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to unzip files in Windows

2021-08-25 Thread Rui Barradas

Hello,

Are you looking for what follows Andrew's code below to download and 
untar the files?




read_one_gz_file <- function(x, path){
  fl <- file.path(path, x)
  tryCatch({
read.table(zz <- gzfile(fl))
  },
  warning = function(w) w,
  error = function(e) e
  )
}

URL <- 
"https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar;

FILE <- file.path(tempdir(), basename(URL))
utils::download.file(URL, FILE, mode = "wb")
utils::untar(FILE, exdir = dirname(FILE))

fls <- list.files(path = dirname(FILE), pattern = "\\.gz$")
length(fls)
#[1] 108

data_list <- lapply(fls, read_one_gz_file, path = dirname(FILE))
length(data_list)
#[1] 108

head(data_list[[1]])
#V1  V2
#1 A1BG   4
#2 A1BG-AS1  52
#3 A1CF  12
#4  A2M 645
#5  A2M-AS1 113
#6A2ML1  21



I don't understand what you mean by to aggregate the files but if you 
want them all in one df, maybe this will do it.




sapply(data_list, ncol) # All files have 2 columns

# create a column with the original dataset name
data_list <- lapply(seq_along(data_list), function(i){
  dftmp <- data_list[[i]]
  dftmp$dataset <- sub("\\.txt\\.gz$", "", fls[i])
  dftmp
})

# put all data sets in one data.frame
df1 <- do.call(rbind, data_list)

dim(df1)  # Over 2.8 million rows, 3 columns
head(df1) # see the first 6 rows
#V1  V2 dataset
#1 A1BG   4 GSM4954457_A_1_Asymptom
#2 A1BG-AS1  52 GSM4954457_A_1_Asymptom
#3 A1CF  12 GSM4954457_A_1_Asymptom
#4  A2M 645 GSM4954457_A_1_Asymptom
#5  A2M-AS1 113 GSM4954457_A_1_Asymptom
#6A2ML1  21 GSM4954457_A_1_Asymptom




Hope this helps,

Rui Barradas


Às 01:16 de 24/08/21, Anas Jamshed escreveu:

sir after that I want to run:
#get the list of sample names
GSMnames <- t(list.files("~/Desktop/GSE162562_RAW", full.names = F))

#remove .txt from file/sample names
GSMnames <- gsub(pattern = ".txt", replacement = "", GSMnames)

#make a vector of the list of files to aggregate
files <- list.files("~/Desktop/GSE162562_RAW", full.names = TRUE)


but it is not running as after running utils::untar(FILE, exdir =
dirname(FILE)) it creates another 108 archieves

On Tue, Aug 24, 2021 at 2:03 AM Andrew Simmons  wrote:


Hello,


I tried downloading that file using 'utils::download.file' (which worked),
but then continued to complain about "damaged archive" when trying to use
'utils::untar'. However, it seemed to work when I downloaded the archive
manually. Finally, the solution I found is that you have to specify the
mode in which you're downloading the file. Something like:


URL <- "
https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
"
FILE <- file.path(tempdir(), basename(URL))


utils::download.file(URL, FILE, mode = "wb")
utils::untar(FILE, exdir = dirname(FILE))


worked perfectly for me. It seems to also work still on Ubuntu, but you
can let us know if you find it doesn't. I hope this helps!



On Mon, Aug 23, 2021 at 3:20 PM Anas Jamshed 
wrote:


I am trying this URL: "
https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
"

but it is not giving me any file

On Mon, Aug 23, 2021 at 11:42 PM Andrew Simmons 
wrote:


Hello,


I don't think you need to use a system command directly, I think
'utils::untar' is all you need. I tried the same thing myself, something
like:


URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
FILE <- file.path(tempdir(), basename(URL))


utils::download.file(URL, FILE)
utils::untar(FILE, exdir = dirname(FILE))


and it makes a folder "Image-ExifTool-12.30". It seems to work perfectly
fine in Windows 10 x64 build 19042. Can you send the specific file (or
provide a URL to the specific file) that isn't working for you?

On Mon, Aug 23, 2021 at 12:53 PM Anas Jamshed 
wrote:


I have the file GSE162562_RAW. First I untar them
by untar("GSE162562_RAW.tar")
then I am running like:
  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")


This is running fine in Linux but not in windows. What changes I
should make to run this command in windows as well

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] Need help to unzip files in Windows

2021-08-23 Thread Anas Jamshed
but the point is that where should I start from now

On Tue, Aug 24, 2021 at 7:43 AM Andrew Simmons  wrote:

> Hello,
>
>
> I see what you're saying that the .tar archive contains many more
> compressed files, but that's not necessarily a problem. R can read directly
> from a compressed file without having to decompress it beforehand. I
> modified my code to look a little more like yours:
>
>
> # need to do 'path.expand' or 'untar' will fail
> # this is where we put the downloaded files
> exdir <- path.expand("~/GSE162562_RAW")
> dir.create(exdir, showWarnings = FALSE)
>
>
> URL <- "
> https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
> "
> FILE <- file.path(tempdir(), basename(URL))
>
>
> utils::download.file(URL, FILE, mode = "wb")
> utils::untar(FILE, exdir = exdir)
> unlink(FILE, recursive = TRUE, force = TRUE)
>
>
> # 'files' is the full path to the downloaded files
> # attribute 'names' is the basename with '.txt.gz' removed from the end
> files <- list.files(exdir, full.names = TRUE)
> names(files) <- sub("\\.txt\\.gz$", "", basename(files))
>
>
> # R can open compressed files without decompressing beforehand
> print(utils::read.table(files[[1]], sep = "\t"))
> print(utils::read.delim(files[[2]], header = FALSE))
>
>
> Does this work better than before for you?
>
> On Mon, Aug 23, 2021 at 8:16 PM Anas Jamshed 
> wrote:
>
>> sir after that I want to run:
>> #get the list of sample names
>> GSMnames <- t(list.files("~/Desktop/GSE162562_RAW", full.names = F))
>>
>> #remove .txt from file/sample names
>> GSMnames <- gsub(pattern = ".txt", replacement = "", GSMnames)
>>
>> #make a vector of the list of files to aggregate
>> files <- list.files("~/Desktop/GSE162562_RAW", full.names = TRUE)
>>
>>
>> but it is not running as after running utils::untar(FILE, exdir =
>> dirname(FILE)) it creates another 108 archieves
>>
>> On Tue, Aug 24, 2021 at 2:03 AM Andrew Simmons 
>> wrote:
>>
>>> Hello,
>>>
>>>
>>> I tried downloading that file using 'utils::download.file' (which
>>> worked), but then continued to complain about "damaged archive" when trying
>>> to use 'utils::untar'. However, it seemed to work when I downloaded the
>>> archive manually. Finally, the solution I found is that you have to specify
>>> the mode in which you're downloading the file. Something like:
>>>
>>>
>>> URL <- "
>>> https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
>>> "
>>> FILE <- file.path(tempdir(), basename(URL))
>>>
>>>
>>> utils::download.file(URL, FILE, mode = "wb")
>>> utils::untar(FILE, exdir = dirname(FILE))
>>>
>>>
>>> worked perfectly for me. It seems to also work still on Ubuntu, but you
>>> can let us know if you find it doesn't. I hope this helps!
>>>
>>>
>>>
>>> On Mon, Aug 23, 2021 at 3:20 PM Anas Jamshed 
>>> wrote:
>>>
 I am trying this URL: "
 https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
 "

 but it is not giving me any file

 On Mon, Aug 23, 2021 at 11:42 PM Andrew Simmons 
 wrote:

> Hello,
>
>
> I don't think you need to use a system command directly, I think
> 'utils::untar' is all you need. I tried the same thing myself, something
> like:
>
>
> URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
> FILE <- file.path(tempdir(), basename(URL))
>
>
> utils::download.file(URL, FILE)
> utils::untar(FILE, exdir = dirname(FILE))
>
>
> and it makes a folder "Image-ExifTool-12.30". It seems to work
> perfectly fine in Windows 10 x64 build 19042. Can you send the specific
> file (or provide a URL to the specific file) that isn't working for you?
>
> On Mon, Aug 23, 2021 at 12:53 PM Anas Jamshed <
> anasjamshed1...@gmail.com> wrote:
>
>> I have the file GSE162562_RAW. First I untar them
>> by untar("GSE162562_RAW.tar")
>> then I am running like:
>>  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")
>>
>>
>> This is running fine in Linux but not in windows. What changes I
>> should make to run this command in windows as well
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to unzip files in Windows

2021-08-23 Thread Andrew Simmons
Hello,


I see what you're saying that the .tar archive contains many more
compressed files, but that's not necessarily a problem. R can read directly
from a compressed file without having to decompress it beforehand. I
modified my code to look a little more like yours:


# need to do 'path.expand' or 'untar' will fail
# this is where we put the downloaded files
exdir <- path.expand("~/GSE162562_RAW")
dir.create(exdir, showWarnings = FALSE)


URL <- "
https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
"
FILE <- file.path(tempdir(), basename(URL))


utils::download.file(URL, FILE, mode = "wb")
utils::untar(FILE, exdir = exdir)
unlink(FILE, recursive = TRUE, force = TRUE)


# 'files' is the full path to the downloaded files
# attribute 'names' is the basename with '.txt.gz' removed from the end
files <- list.files(exdir, full.names = TRUE)
names(files) <- sub("\\.txt\\.gz$", "", basename(files))


# R can open compressed files without decompressing beforehand
print(utils::read.table(files[[1]], sep = "\t"))
print(utils::read.delim(files[[2]], header = FALSE))


Does this work better than before for you?

On Mon, Aug 23, 2021 at 8:16 PM Anas Jamshed 
wrote:

> sir after that I want to run:
> #get the list of sample names
> GSMnames <- t(list.files("~/Desktop/GSE162562_RAW", full.names = F))
>
> #remove .txt from file/sample names
> GSMnames <- gsub(pattern = ".txt", replacement = "", GSMnames)
>
> #make a vector of the list of files to aggregate
> files <- list.files("~/Desktop/GSE162562_RAW", full.names = TRUE)
>
>
> but it is not running as after running utils::untar(FILE, exdir =
> dirname(FILE)) it creates another 108 archieves
>
> On Tue, Aug 24, 2021 at 2:03 AM Andrew Simmons  wrote:
>
>> Hello,
>>
>>
>> I tried downloading that file using 'utils::download.file' (which
>> worked), but then continued to complain about "damaged archive" when trying
>> to use 'utils::untar'. However, it seemed to work when I downloaded the
>> archive manually. Finally, the solution I found is that you have to specify
>> the mode in which you're downloading the file. Something like:
>>
>>
>> URL <- "
>> https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
>> "
>> FILE <- file.path(tempdir(), basename(URL))
>>
>>
>> utils::download.file(URL, FILE, mode = "wb")
>> utils::untar(FILE, exdir = dirname(FILE))
>>
>>
>> worked perfectly for me. It seems to also work still on Ubuntu, but you
>> can let us know if you find it doesn't. I hope this helps!
>>
>>
>>
>> On Mon, Aug 23, 2021 at 3:20 PM Anas Jamshed 
>> wrote:
>>
>>> I am trying this URL: "
>>> https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
>>> "
>>>
>>> but it is not giving me any file
>>>
>>> On Mon, Aug 23, 2021 at 11:42 PM Andrew Simmons 
>>> wrote:
>>>
 Hello,


 I don't think you need to use a system command directly, I think
 'utils::untar' is all you need. I tried the same thing myself, something
 like:


 URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
 FILE <- file.path(tempdir(), basename(URL))


 utils::download.file(URL, FILE)
 utils::untar(FILE, exdir = dirname(FILE))


 and it makes a folder "Image-ExifTool-12.30". It seems to work
 perfectly fine in Windows 10 x64 build 19042. Can you send the specific
 file (or provide a URL to the specific file) that isn't working for you?

 On Mon, Aug 23, 2021 at 12:53 PM Anas Jamshed <
 anasjamshed1...@gmail.com> wrote:

> I have the file GSE162562_RAW. First I untar them
> by untar("GSE162562_RAW.tar")
> then I am running like:
>  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")
>
>
> This is running fine in Linux but not in windows. What changes I
> should make to run this command in windows as well
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to unzip files in Windows

2021-08-23 Thread Anas Jamshed
sir after that I want to run:
#get the list of sample names
GSMnames <- t(list.files("~/Desktop/GSE162562_RAW", full.names = F))

#remove .txt from file/sample names
GSMnames <- gsub(pattern = ".txt", replacement = "", GSMnames)

#make a vector of the list of files to aggregate
files <- list.files("~/Desktop/GSE162562_RAW", full.names = TRUE)


but it is not running as after running utils::untar(FILE, exdir =
dirname(FILE)) it creates another 108 archieves

On Tue, Aug 24, 2021 at 2:03 AM Andrew Simmons  wrote:

> Hello,
>
>
> I tried downloading that file using 'utils::download.file' (which worked),
> but then continued to complain about "damaged archive" when trying to use
> 'utils::untar'. However, it seemed to work when I downloaded the archive
> manually. Finally, the solution I found is that you have to specify the
> mode in which you're downloading the file. Something like:
>
>
> URL <- "
> https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
> "
> FILE <- file.path(tempdir(), basename(URL))
>
>
> utils::download.file(URL, FILE, mode = "wb")
> utils::untar(FILE, exdir = dirname(FILE))
>
>
> worked perfectly for me. It seems to also work still on Ubuntu, but you
> can let us know if you find it doesn't. I hope this helps!
>
>
>
> On Mon, Aug 23, 2021 at 3:20 PM Anas Jamshed 
> wrote:
>
>> I am trying this URL: "
>> https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
>> "
>>
>> but it is not giving me any file
>>
>> On Mon, Aug 23, 2021 at 11:42 PM Andrew Simmons 
>> wrote:
>>
>>> Hello,
>>>
>>>
>>> I don't think you need to use a system command directly, I think
>>> 'utils::untar' is all you need. I tried the same thing myself, something
>>> like:
>>>
>>>
>>> URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
>>> FILE <- file.path(tempdir(), basename(URL))
>>>
>>>
>>> utils::download.file(URL, FILE)
>>> utils::untar(FILE, exdir = dirname(FILE))
>>>
>>>
>>> and it makes a folder "Image-ExifTool-12.30". It seems to work perfectly
>>> fine in Windows 10 x64 build 19042. Can you send the specific file (or
>>> provide a URL to the specific file) that isn't working for you?
>>>
>>> On Mon, Aug 23, 2021 at 12:53 PM Anas Jamshed 
>>> wrote:
>>>
 I have the file GSE162562_RAW. First I untar them
 by untar("GSE162562_RAW.tar")
 then I am running like:
  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")


 This is running fine in Linux but not in windows. What changes I
 should make to run this command in windows as well

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

>>>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to unzip files in Windows

2021-08-23 Thread Abby Spurdle
There are some differences in R, between Windows and Linux.
You could try the 'shell' command instead.

#On Windows
?shell

On Tue, Aug 24, 2021 at 4:53 AM Anas Jamshed  wrote:
>
> I have the file GSE162562_RAW. First I untar them
> by untar("GSE162562_RAW.tar")
> then I am running like:
>  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")
>
>
> This is running fine in Linux but not in windows. What changes I
> should make to run this command in windows as well
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to unzip files in Windows

2021-08-23 Thread Andrew Simmons
Hello,


I tried downloading that file using 'utils::download.file' (which worked),
but then continued to complain about "damaged archive" when trying to use
'utils::untar'. However, it seemed to work when I downloaded the archive
manually. Finally, the solution I found is that you have to specify the
mode in which you're downloading the file. Something like:


URL <- "
https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
"
FILE <- file.path(tempdir(), basename(URL))


utils::download.file(URL, FILE, mode = "wb")
utils::untar(FILE, exdir = dirname(FILE))


worked perfectly for me. It seems to also work still on Ubuntu, but you can
let us know if you find it doesn't. I hope this helps!



On Mon, Aug 23, 2021 at 3:20 PM Anas Jamshed 
wrote:

> I am trying this URL: "
> https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
> "
>
> but it is not giving me any file
>
> On Mon, Aug 23, 2021 at 11:42 PM Andrew Simmons 
> wrote:
>
>> Hello,
>>
>>
>> I don't think you need to use a system command directly, I think
>> 'utils::untar' is all you need. I tried the same thing myself, something
>> like:
>>
>>
>> URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
>> FILE <- file.path(tempdir(), basename(URL))
>>
>>
>> utils::download.file(URL, FILE)
>> utils::untar(FILE, exdir = dirname(FILE))
>>
>>
>> and it makes a folder "Image-ExifTool-12.30". It seems to work perfectly
>> fine in Windows 10 x64 build 19042. Can you send the specific file (or
>> provide a URL to the specific file) that isn't working for you?
>>
>> On Mon, Aug 23, 2021 at 12:53 PM Anas Jamshed 
>> wrote:
>>
>>> I have the file GSE162562_RAW. First I untar them
>>> by untar("GSE162562_RAW.tar")
>>> then I am running like:
>>>  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")
>>>
>>>
>>> This is running fine in Linux but not in windows. What changes I
>>> should make to run this command in windows as well
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to unzip files in Windows

2021-08-23 Thread Anas Jamshed
I am trying this URL: "
https://ftp.ncbi.nlm.nih.gov/geo/series/GSE162nnn/GSE162562/suppl/GSE162562_RAW.tar
"

but it is not giving me any file

On Mon, Aug 23, 2021 at 11:42 PM Andrew Simmons  wrote:

> Hello,
>
>
> I don't think you need to use a system command directly, I think
> 'utils::untar' is all you need. I tried the same thing myself, something
> like:
>
>
> URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
> FILE <- file.path(tempdir(), basename(URL))
>
>
> utils::download.file(URL, FILE)
> utils::untar(FILE, exdir = dirname(FILE))
>
>
> and it makes a folder "Image-ExifTool-12.30". It seems to work perfectly
> fine in Windows 10 x64 build 19042. Can you send the specific file (or
> provide a URL to the specific file) that isn't working for you?
>
> On Mon, Aug 23, 2021 at 12:53 PM Anas Jamshed 
> wrote:
>
>> I have the file GSE162562_RAW. First I untar them
>> by untar("GSE162562_RAW.tar")
>> then I am running like:
>>  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")
>>
>>
>> This is running fine in Linux but not in windows. What changes I
>> should make to run this command in windows as well
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to unzip files in Windows

2021-08-23 Thread Andrew Simmons
Hello,


I don't think you need to use a system command directly, I think
'utils::untar' is all you need. I tried the same thing myself, something
like:


URL <- "https://exiftool.org/Image-ExifTool-12.30.tar.gz;
FILE <- file.path(tempdir(), basename(URL))


utils::download.file(URL, FILE)
utils::untar(FILE, exdir = dirname(FILE))


and it makes a folder "Image-ExifTool-12.30". It seems to work perfectly
fine in Windows 10 x64 build 19042. Can you send the specific file (or
provide a URL to the specific file) that isn't working for you?

On Mon, Aug 23, 2021 at 12:53 PM Anas Jamshed 
wrote:

> I have the file GSE162562_RAW. First I untar them
> by untar("GSE162562_RAW.tar")
> then I am running like:
>  system("gunzip ~/Desktop/GSE162562_RAW/*.gz")
>
>
> This is running fine in Linux but not in windows. What changes I
> should make to run this command in windows as well
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help to unzip files in Windows

2021-08-23 Thread Anas Jamshed
I have the file GSE162562_RAW. First I untar them
by untar("GSE162562_RAW.tar")
then I am running like:
 system("gunzip ~/Desktop/GSE162562_RAW/*.gz")


This is running fine in Linux but not in windows. What changes I
should make to run this command in windows as well

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-09 Thread David Winsemius



On 6/9/21 5:06 AM, Biplab Nayak wrote:

Hi Greg,

Please find the objective of the code(bold) and code mentioned below. I was
trying to do to achieve the below objective but somehow it's not working.



The phrase "somehow not working" is not a useful description of an outcome.



1.Order assessment based on the latest due date so select input
automatically shows the order of assessment name.

2.Filter based on the one name or multiple names in the  select input



library(tidyverse)

#library(stringr)# attached with tidyverse

#library(readr)

library(shiny)

library(dplyr)



I'm pretty sure the tidyverse super-package includes most of the others 
with the exception of pkg:shiny (which does not appear to be needed anyway.)


Here's what my version of tidyverse loads:

Imports: broom (>= 0.5.2), cli (>= 1.1.0), crayon (>= 1.3.4), dbplyr (>= 
1.4.2), dplyr (>= 0.8.3), forcats (>= 0.4.0),
 ggplot2 (>= 3.2.1), haven (>= 2.2.0), hms (>= 0.5.2), httr 
(>= 1.4.1), jsonlite (>= 1.6), lubridate (>=
 1.7.4), magrittr (>= 1.5), modelr (>= 0.1.5), pillar (>= 
1.4.2), purrr (>= 0.3.3), readr (>= 1.3.1), readxl
 (>= 1.3.1), reprex (>= 0.3.0), rlang (>= 0.4.1), 
rstudioapi (>= 0.10), rvest (>= 0.3.5), stringr (>=

 1.4.0), tibble (>= 2.1.3), tidyr (>= 1.0.0), xml2 (>= 1.2.2)


ttclasses <- read_csv("~/tmp/ttclasses.csv")

We do not have your data.


#Filter data

ttclasses <-ttclasses %>%

filter(str_detect(assessment, "Assignment"))

  ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))
Without a result that summarizes the changes in the data composition at 
each step, we cannot make any guesses as to your problem

##Remove NA values.

ttclasses <-ttclasses %>% drop_na("score")



*## Sort  assessment based on max due_date*

  ttclasses  <- ttclasses [order( - due_date, assessment ),]



#Convert to factor

ttclasses$assessment <- factor(ttclasses$assessment)



# please see the formats in help("strptime")

ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")
Yes, do see ?strptime. That format assumes dates are in MM/DD/YY format, 
i.e slashes as separators and 2 digit years. Getting the date format 
wrong is a common way to create NA values. It is better not to overlay 
such efforts on top of the original column name. That way you can still 
make changes without redoing the entire data steps.


ttclasses$name <- factor(ttclasses$name)

Thanks & Regards
Biplab Nayak






On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:


Biplab,

i'm not sure how to help you here, but this list pretty much runs on
plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
attachments.  so, simply-formatted text, including code, with some
mechanism in the code to initialize any data structures (data frames,
matrices, etc.) needed for the example.

some of this is described in the posting guide

https://www.r-project.org/posting-guide.html


formatting your e-mail in this way will likely increase your odds of a
helpful reply.

cheers, Greg


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Jeff Newmiller
You seem to need to educate yourself as to what "plain text" means, and to read 
the Posting Guide for this mailing list. Word documents are very definitely NOT 
plain text. Stop attempting to communicate via formatted text on this mailing 
list.

For security reasons this mailing list removes most attachments and formatting. 
Your emails sent to the list have such features (e.g Word documents and HTML 
formatting) stripped (removed). If you happen to send such emails directly to 
specific people they might have software that can allow them to view that 
information if they choose to risk opening attachments from a stranger (I will 
not), but for those of us seeing your emails on the list "what you send is not 
what we receive". Such emails are repeatedly violating the Posting Guidelines 
which will make responses much less likely and may increase the chance of a 
negative moderator reaction.

On June 8, 2021 8:47:52 PM PDT, Biplab Nayak  wrote:
>Hi Greg,
>
>Please find the R Code in the word file attached here. Its plain text
>format
>
>Thanks & Regards
>Biplab Nayak
>
>On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall 
>wrote:
>
>> Biplab,
>>
>> i'm not sure how to help you here, but this list pretty much runs on
>> plain ASCII (or, these days, utf-8) e-mail.  for the most part,
>without
>> attachments.  so, simply-formatted text, including code, with some
>> mechanism in the code to initialize any data structures (data frames,
>> matrices, etc.) needed for the example.
>>
>> some of this is described in the posting guide
>> 
>> https://www.r-project.org/posting-guide.html
>> 
>>
>> formatting your e-mail in this way will likely increase your odds of
>a
>> helpful reply.
>>
>> cheers, Greg
>>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Biplab Nayak
Hi Greg,

Please find the objective of the code(bold) and code mentioned below. I was
trying to do to achieve the below objective but somehow it's not working.

1.Order assessment based on the latest due date so select input
automatically shows the order of assessment name.

2.Filter based on the one name or multiple names in the  select input



library(tidyverse)

#library(stringr)# attached with tidyverse

#library(readr)

library(shiny)

library(dplyr)



ttclasses <- read_csv("~/tmp/ttclasses.csv")



#Filter data

ttclasses <-ttclasses %>%

   filter(str_detect(assessment, "Assignment"))

 ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))



##Remove NA values.

ttclasses <-ttclasses %>% drop_na("score")



*## Sort  assessment based on max due_date*

 ttclasses  <- ttclasses [order( - due_date, assessment ),]



#Convert to factor

ttclasses$assessment <- factor(ttclasses$assessment)



# please see the formats in help("strptime")

ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")

ttclasses$name <- factor(ttclasses$name)

Thanks & Regards
Biplab Nayak

On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:

> Biplab,
>
> i'm not sure how to help you here, but this list pretty much runs on
> plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
> attachments.  so, simply-formatted text, including code, with some
> mechanism in the code to initialize any data structures (data frames,
> matrices, etc.) needed for the example.
>
> some of this is described in the posting guide
> 
> https://www.r-project.org/posting-guide.html
> 
>
> formatting your e-mail in this way will likely increase your odds of a
> helpful reply.
>
> cheers, Greg
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Biplab Nayak
Hi Greg,

Please find the objective of the code(bold) and code mentioned below. I was
trying to do to achieve the below objective but somehow it's not working.

1.Order assessment based on the latest due date so select input automatically
shows the order of assessment name.

2.Filter based on the one name or multiple names in the  select input



library(tidyverse)

#library(stringr)# attached with tidyverse

#library(readr)

library(shiny)

library(dplyr)



ttclasses <- read_csv("~/tmp/ttclasses.csv")



#Filter data

ttclasses <-ttclasses %>%

   filter(str_detect(assessment, "Assignment"))

 *ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))*



##Remove NA values.

ttclasses <-ttclasses %>% drop_na("score")



*## Sort  assessment based on max due_date*

 *ttclasses  <- ttclasses [order( - due_date, assessment ),]*



#Convert to factor

ttclasses$assessment <- factor(ttclasses$assessment)



# please see the formats in help("strptime")

ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")

*ttclasses$name <- factor(ttclasses$name)*





# Define UI 

ui <- fluidPage(



   # App title 

   titlePanel("Assessment Dashboard"),



   # Sidebar layout with input and output definitions 

   sidebarLayout(



 # Sidebar panel for inputs 

 sidebarPanel(



   # Input: Selector for variable to plot the grades for the selected

   # assignment 



 selectInput("assessment", "Assessment:",

 c("Assignment 1" = "Assignment 1",

   "Assignment 2" = "Assignment 2",

   "Assignment 3" = "Assignment 3",

   "Assignment 4" = "Assignment 4",

   "Assignment 5" = "Assignment 5")),

   selectInput("name", "Name:",

   ttclasses[,2]),



   dateRangeInput("due_date",

  "Due-Date:",start = max(ttclasses$due_date) ,

  separator = " - ")

 ),



 # Main panel for displaying outputs 

 mainPanel(



   # Output: Plot of the requested variable against grade 

   plotOutput("gradePlot")



 )

   )

)



# Define server logic to plot  

server <- function(input, output) {

   output$gradePlot <- renderPlot({

 grade_ad = input$assessment

 boxplot(ttclasses$score[ttclasses$assessment==grade_ad],

 frame.plot=FALSE, horizontal=TRUE, col="magenta",

main=grade_ad)

 ttclasses <-ttclasses %>%

   filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date

  <= input$due_date[2])

   })

}



# Create Shiny app 

shinyApp(ui, server)


Thanks & Regards
Biplab Nayak

On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:

> Biplab,
>
> i'm not sure how to help you here, but this list pretty much runs on
> plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
> attachments.  so, simply-formatted text, including code, with some
> mechanism in the code to initialize any data structures (data frames,
> matrices, etc.) needed for the example.
>
> some of this is described in the posting guide
> 
> https://www.r-project.org/posting-guide.html
> 
>
> formatting your e-mail in this way will likely increase your odds of a
> helpful reply.
>
> cheers, Greg
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Biplab Nayak
Hi Greg,

Please find the R Code in the word file attached here. Its plain text format

Thanks & Regards
Biplab Nayak

On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:

> Biplab,
>
> i'm not sure how to help you here, but this list pretty much runs on
> plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
> attachments.  so, simply-formatted text, including code, with some
> mechanism in the code to initialize any data structures (data frames,
> matrices, etc.) needed for the example.
>
> some of this is described in the posting guide
> 
> https://www.r-project.org/posting-guide.html
> 
>
> formatting your e-mail in this way will likely increase your odds of a
> helpful reply.
>
> cheers, Greg
>
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-08 Thread Greg Minshall
Biplab,

i'm not sure how to help you here, but this list pretty much runs on
plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
attachments.  so, simply-formatted text, including code, with some
mechanism in the code to initialize any data structures (data frames,
matrices, etc.) needed for the example.

some of this is described in the posting guide

https://www.r-project.org/posting-guide.html


formatting your e-mail in this way will likely increase your odds of a
helpful reply.

cheers, Greg

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-08 Thread Biplab Nayak
Hi Bert,

I have attached the word file with the R code.

Thanks & Regards
Biplab Nayak

On Tue, Jun 8, 2021 at 1:07 PM Bert Gunter  wrote:

> I do not wish to be involved in this thread other than to note that you
> were, I believe, asked not to post in HTML. And because you did, you will
> find that "Bold" highlighting does not exist in your text below. I have no
> idea whether that matters for your query or not, but there it is.
>
>
> Bert Gunter
>
>
>
> On Tue, Jun 8, 2021 at 8:13 AM Biplab Nayak  wrote:
>
>> Hi Rui,
>>
>> Please find the code(bold) below I was trying to do to achieve the
>> achieve:But somehow its not working.
>> 1.Order assessment based on the latest due date so select input
>> automatically show the order of assessment name.
>> 2.Filter based on the one name or multiple names in the  select input
>>
>> library(tidyverse)
>> #library(stringr)# attached with tidyverse
>> #library(readr)
>> library(shiny)
>> library(dplyr)
>>
>> ttclasses <- read_csv("~/tmp/ttclasses.csv")
>>
>> #Filter data
>> ttclasses <-ttclasses %>%
>>filter(str_detect(assessment, "Assignment"))
>>
>> # With the attached data this filter
>> # removes all rows so I have
>> # commented it out
>>
>>
>> *ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))*
>> ##Remove NA values.
>> ttclasses <-ttclasses %>% drop_na("score")
>>
>> *## Sort  assessment based on max due_date*
>> *  ttclasses  <- ttclasses [order( - due_date, assessment ),]*
>>
>> #Convert to factor
>> ttclasses$assessment <- factor(ttclasses$assessment)
>>
>> # please see the formats in help("strptime")
>> ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")
>> *ttclasses$name <- factor(ttclasses$name)*
>>
>> # Define UI 
>> ui <- fluidPage(
>>
>># App title 
>>titlePanel("Assessment Dashboard"),
>>
>># Sidebar layout with input and output definitions 
>>sidebarLayout(
>>
>>  # Sidebar panel for inputs 
>>  sidebarPanel(
>>
>># Input: Selector for variable to plot the grades for the selected
>># assignment 
>>
>>  selectInput("assessment", "Assessment:",
>>  c("Assignment 1" = "Assignment 1",
>>"Assignment 2" = "Assignment 2",
>>"Assignment 3" = "Assignment 3",
>>"Assignment 4" = "Assignment 4",
>>"Assignment 5" = "Assignment 5")),
>>selectInput("name", "Name:",
>>ttclasses[,2]),
>>
>>dateRangeInput("due_date",
>>   "Due-Date:",start = max(ttclasses$due_date) ,
>>   separator = " - ")
>>  ),
>>
>>  # Main panel for displaying outputs 
>>  mainPanel(
>>
>># Output: Plot of the requested variable against grade 
>>plotOutput("gradePlot")
>>
>>  )
>>)
>> )
>>
>> # Define server logic to plot  
>> server <- function(input, output) {
>>output$gradePlot <- renderPlot({
>>  grade_ad = input$assessment
>>  boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
>>  frame.plot=FALSE, horizontal=TRUE, col="magenta",
>> main=grade_ad)
>>  ttclasses <-ttclasses %>%
>>filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
>>   <= input$due_date[2])
>>})
>> }
>>
>> # Create Shiny app 
>> shinyApp(ui, server)
>>
>>
>> Thanks & Regards
>> Biplab Nayak
>>
>> On Tue, Jun 8, 2021 at 7:08 AM Rui Barradas  wrote:
>>
>> > Hello,
>> >
>> > Please cc the list.
>> > R-Help is not a code writing service, it's a mailing list for doubts on
>> > R code. I'm sorry but without answers to the below questions I am not
>> > going to answer.
>> >
>> >
>> > What have you tried? What went wrong?
>> >
>> >
>> > Hope this helps,
>> >
>> > Rui Barradas
>> >
>> > Às 04:01 de 08/06/21, Biplab Nayak escreveu:
>> > > Hi Rui,
>> > >
>> > > It's working fine. Now I need to achieve the following:
>> > >
>> > > * Default view of most recent distributions by most recent assignment
>> > > due date
>> > >
>> > > * Filter by one or more students
>> > >
>> > > Please help
>> > >
>> > > Thanks & Regards
>> > > Biplab Nayak
>> > >
>> > > On Mon, Jun 7, 2021 at 6:51 PM Rui Barradas > > > > wrote:
>> > >
>> > > Hello,
>> > >
>> > > Thanks for the data.
>> > > There were some, not many, bugs that I have corrected below.
>> > >
>> > >
>> > >
>> > > library(tidyverse)
>> > > #library(stringr)# attached with tidyverse
>> > > #library(readr)
>> > > library(shiny)
>> > >
>> > > ttclasses <- read_csv("~/tmp/ttclasses.csv")
>> > >
>> > > #Filter data
>> > > ttclasses <-ttclasses %>%
>> > > filter(str_detect(assessment, "Assignment"))
>> > >
>> > > # With the attached data this filter
>> > > # removes all rows so I have
>> > > # commented it out
>> > > #ttclasses <-ttclasses %>%
>> > > #  filter(str_detect(name, 

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-08 Thread Bert Gunter
I do not wish to be involved in this thread other than to note that you
were, I believe, asked not to post in HTML. And because you did, you will
find that "Bold" highlighting does not exist in your text below. I have no
idea whether that matters for your query or not, but there it is.


Bert Gunter



On Tue, Jun 8, 2021 at 8:13 AM Biplab Nayak  wrote:

> Hi Rui,
>
> Please find the code(bold) below I was trying to do to achieve the
> achieve:But somehow its not working.
> 1.Order assessment based on the latest due date so select input
> automatically show the order of assessment name.
> 2.Filter based on the one name or multiple names in the  select input
>
> library(tidyverse)
> #library(stringr)# attached with tidyverse
> #library(readr)
> library(shiny)
> library(dplyr)
>
> ttclasses <- read_csv("~/tmp/ttclasses.csv")
>
> #Filter data
> ttclasses <-ttclasses %>%
>filter(str_detect(assessment, "Assignment"))
>
> # With the attached data this filter
> # removes all rows so I have
> # commented it out
>
>
> *ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))*
> ##Remove NA values.
> ttclasses <-ttclasses %>% drop_na("score")
>
> *## Sort  assessment based on max due_date*
> *  ttclasses  <- ttclasses [order( - due_date, assessment ),]*
>
> #Convert to factor
> ttclasses$assessment <- factor(ttclasses$assessment)
>
> # please see the formats in help("strptime")
> ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")
> *ttclasses$name <- factor(ttclasses$name)*
>
> # Define UI 
> ui <- fluidPage(
>
># App title 
>titlePanel("Assessment Dashboard"),
>
># Sidebar layout with input and output definitions 
>sidebarLayout(
>
>  # Sidebar panel for inputs 
>  sidebarPanel(
>
># Input: Selector for variable to plot the grades for the selected
># assignment 
>
>  selectInput("assessment", "Assessment:",
>  c("Assignment 1" = "Assignment 1",
>"Assignment 2" = "Assignment 2",
>"Assignment 3" = "Assignment 3",
>"Assignment 4" = "Assignment 4",
>"Assignment 5" = "Assignment 5")),
>selectInput("name", "Name:",
>ttclasses[,2]),
>
>dateRangeInput("due_date",
>   "Due-Date:",start = max(ttclasses$due_date) ,
>   separator = " - ")
>  ),
>
>  # Main panel for displaying outputs 
>  mainPanel(
>
># Output: Plot of the requested variable against grade 
>plotOutput("gradePlot")
>
>  )
>)
> )
>
> # Define server logic to plot  
> server <- function(input, output) {
>output$gradePlot <- renderPlot({
>  grade_ad = input$assessment
>  boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
>  frame.plot=FALSE, horizontal=TRUE, col="magenta",
> main=grade_ad)
>  ttclasses <-ttclasses %>%
>filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
>   <= input$due_date[2])
>})
> }
>
> # Create Shiny app 
> shinyApp(ui, server)
>
>
> Thanks & Regards
> Biplab Nayak
>
> On Tue, Jun 8, 2021 at 7:08 AM Rui Barradas  wrote:
>
> > Hello,
> >
> > Please cc the list.
> > R-Help is not a code writing service, it's a mailing list for doubts on
> > R code. I'm sorry but without answers to the below questions I am not
> > going to answer.
> >
> >
> > What have you tried? What went wrong?
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 04:01 de 08/06/21, Biplab Nayak escreveu:
> > > Hi Rui,
> > >
> > > It's working fine. Now I need to achieve the following:
> > >
> > > * Default view of most recent distributions by most recent assignment
> > > due date
> > >
> > > * Filter by one or more students
> > >
> > > Please help
> > >
> > > Thanks & Regards
> > > Biplab Nayak
> > >
> > > On Mon, Jun 7, 2021 at 6:51 PM Rui Barradas  > > > wrote:
> > >
> > > Hello,
> > >
> > > Thanks for the data.
> > > There were some, not many, bugs that I have corrected below.
> > >
> > >
> > >
> > > library(tidyverse)
> > > #library(stringr)# attached with tidyverse
> > > #library(readr)
> > > library(shiny)
> > >
> > > ttclasses <- read_csv("~/tmp/ttclasses.csv")
> > >
> > > #Filter data
> > > ttclasses <-ttclasses %>%
> > > filter(str_detect(assessment, "Assignment"))
> > >
> > > # With the attached data this filter
> > > # removes all rows so I have
> > > # commented it out
> > > #ttclasses <-ttclasses %>%
> > > #  filter(str_detect(name, "Name"))
> > >
> > > ##Remove NA values.
> > > ttclasses <-ttclasses %>% drop_na("score")
> > >
> > > #Convert to factor
> > > ttclasses$assessment <- factor(ttclasses$assessment)
> > >
> > > # please see the formats in help("strptime")
> > > ttclasses$due_date <-  as.Date(ttclasses$due_date, 

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-08 Thread Biplab Nayak
Hi Rui,

Please find the code(bold) below I was trying to do to achieve the
achieve:But somehow its not working.
1.Order assessment based on the latest due date so select input
automatically show the order of assessment name.
2.Filter based on the one name or multiple names in the  select input

library(tidyverse)
#library(stringr)# attached with tidyverse
#library(readr)
library(shiny)
library(dplyr)

ttclasses <- read_csv("~/tmp/ttclasses.csv")

#Filter data
ttclasses <-ttclasses %>%
   filter(str_detect(assessment, "Assignment"))

# With the attached data this filter
# removes all rows so I have
# commented it out


*ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))*
##Remove NA values.
ttclasses <-ttclasses %>% drop_na("score")

*## Sort  assessment based on max due_date*
*  ttclasses  <- ttclasses [order( - due_date, assessment ),]*

#Convert to factor
ttclasses$assessment <- factor(ttclasses$assessment)

# please see the formats in help("strptime")
ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")
*ttclasses$name <- factor(ttclasses$name)*

# Define UI 
ui <- fluidPage(

   # App title 
   titlePanel("Assessment Dashboard"),

   # Sidebar layout with input and output definitions 
   sidebarLayout(

 # Sidebar panel for inputs 
 sidebarPanel(

   # Input: Selector for variable to plot the grades for the selected
   # assignment 

 selectInput("assessment", "Assessment:",
 c("Assignment 1" = "Assignment 1",
   "Assignment 2" = "Assignment 2",
   "Assignment 3" = "Assignment 3",
   "Assignment 4" = "Assignment 4",
   "Assignment 5" = "Assignment 5")),
   selectInput("name", "Name:",
   ttclasses[,2]),

   dateRangeInput("due_date",
  "Due-Date:",start = max(ttclasses$due_date) ,
  separator = " - ")
 ),

 # Main panel for displaying outputs 
 mainPanel(

   # Output: Plot of the requested variable against grade 
   plotOutput("gradePlot")

 )
   )
)

# Define server logic to plot  
server <- function(input, output) {
   output$gradePlot <- renderPlot({
 grade_ad = input$assessment
 boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
 frame.plot=FALSE, horizontal=TRUE, col="magenta",
main=grade_ad)
 ttclasses <-ttclasses %>%
   filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
  <= input$due_date[2])
   })
}

# Create Shiny app 
shinyApp(ui, server)


Thanks & Regards
Biplab Nayak

On Tue, Jun 8, 2021 at 7:08 AM Rui Barradas  wrote:

> Hello,
>
> Please cc the list.
> R-Help is not a code writing service, it's a mailing list for doubts on
> R code. I'm sorry but without answers to the below questions I am not
> going to answer.
>
>
> What have you tried? What went wrong?
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 04:01 de 08/06/21, Biplab Nayak escreveu:
> > Hi Rui,
> >
> > It's working fine. Now I need to achieve the following:
> >
> > * Default view of most recent distributions by most recent assignment
> > due date
> >
> > * Filter by one or more students
> >
> > Please help
> >
> > Thanks & Regards
> > Biplab Nayak
> >
> > On Mon, Jun 7, 2021 at 6:51 PM Rui Barradas  > > wrote:
> >
> > Hello,
> >
> > Thanks for the data.
> > There were some, not many, bugs that I have corrected below.
> >
> >
> >
> > library(tidyverse)
> > #library(stringr)# attached with tidyverse
> > #library(readr)
> > library(shiny)
> >
> > ttclasses <- read_csv("~/tmp/ttclasses.csv")
> >
> > #Filter data
> > ttclasses <-ttclasses %>%
> > filter(str_detect(assessment, "Assignment"))
> >
> > # With the attached data this filter
> > # removes all rows so I have
> > # commented it out
> > #ttclasses <-ttclasses %>%
> > #  filter(str_detect(name, "Name"))
> >
> > ##Remove NA values.
> > ttclasses <-ttclasses %>% drop_na("score")
> >
> > #Convert to factor
> > ttclasses$assessment <- factor(ttclasses$assessment)
> >
> > # please see the formats in help("strptime")
> > ttclasses$due_date <-  as.Date(ttclasses$due_date, format =
> "%m/%d/%y")
> > ##ttclasses$name <- factor(ttclasses$name)
> >
> > # Define UI 
> > ui <- fluidPage(
> >
> > # App title 
> > titlePanel("Assessment Dashboard"),
> >
> > # Sidebar layout with input and output definitions 
> > sidebarLayout(
> >
> >   # Sidebar panel for inputs 
> >   sidebarPanel(
> >
> > # Input: Selector for variable to plot the grades for the
> > selected
> > # assignment 
> >   selectInput("assessment", "Assessment:",
> >   c("Assignment 1" = "Assignment 1",
> >

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-08 Thread Rui Barradas

Hello,

Please cc the list.
R-Help is not a code writing service, it's a mailing list for doubts on 
R code. I'm sorry but without answers to the below questions I am not 
going to answer.



What have you tried? What went wrong?


Hope this helps,

Rui Barradas

Às 04:01 de 08/06/21, Biplab Nayak escreveu:

Hi Rui,

It's working fine. Now I need to achieve the following:

* Default view of most recent distributions by most recent assignment 
due date


* Filter by one or more students

Please help

Thanks & Regards
Biplab Nayak

On Mon, Jun 7, 2021 at 6:51 PM Rui Barradas > wrote:


Hello,

Thanks for the data.
There were some, not many, bugs that I have corrected below.



library(tidyverse)
#library(stringr)    # attached with tidyverse
#library(readr)
library(shiny)

ttclasses <- read_csv("~/tmp/ttclasses.csv")

#Filter data
ttclasses <-ttclasses %>%
    filter(str_detect(assessment, "Assignment"))

# With the attached data this filter
# removes all rows so I have
# commented it out
#ttclasses <-ttclasses %>%
#  filter(str_detect(name, "Name"))

##Remove NA values.
ttclasses <-ttclasses %>% drop_na("score")

#Convert to factor
ttclasses$assessment <- factor(ttclasses$assessment)

# please see the formats in help("strptime")
ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")
##ttclasses$name <- factor(ttclasses$name)

# Define UI 
ui <- fluidPage(

    # App title 
    titlePanel("Assessment Dashboard"),

    # Sidebar layout with input and output definitions 
    sidebarLayout(

      # Sidebar panel for inputs 
      sidebarPanel(

        # Input: Selector for variable to plot the grades for the
selected
        # assignment 
          selectInput("assessment", "Assessment:",
                      c("Assignment 1" = "Assignment 1",
                        "Assignment 2" = "Assignment 2",
                        "Assignment 3" = "Assignment 3",
                        "Assignment 4" = "Assignment 4",
                        "Assignment 5" = "Assignment 5")),
        selectInput("name", "Name:",
                    ttclasses[,2]),

        dateRangeInput("due_date",
                       "Due-Date:",start = max(ttclasses$due_date) ,
                       separator = " - ")
      ),

      # Main panel for displaying outputs 
      mainPanel(

        # Output: Plot of the requested variable against grade 
        plotOutput("gradePlot")

      )
    )
)

# Define server logic to plot  
server <- function(input, output) {
    output$gradePlot <- renderPlot({
      grade_ad = input$assessment
      boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
              frame.plot=FALSE, horizontal=TRUE, col="magenta",
main=grade_ad)
      ttclasses <-ttclasses %>%
        filter(ttclasses$due_date >= input$due_date[1] &
ttclasses$due_date
               <= input$due_date[2])
    })
}

# Create Shiny app 
shinyApp(ui, server)



Hope this helps,

Rui Barradas

Às 18:03 de 07/06/21, Biplab Nayak escreveu:
 > Hi All,
 > I Need a bit of help to fix the code.
 > Code:
 > library(readr)
 > library(shiny)
 > ttclasses <- read_csv("ttclasses.csv")
 >
 > #Filter data
 > library(stringr)
 > library(dplyr)
 > ttclasses <-ttclasses %>%
 >    filter(str_detect(assessment, "Assignment"))
 > ttclasses <-ttclasses %>%
 >    filter(str_detect(name, "Name"))
 >
 > ##Remove NA values.
 > library(tidyverse)
 > ttclasses <-ttclasses %>% drop_na("score")
 >
 > #Convert to factor
 > ttclasses$assessment <- as.factor(ttclasses$assessment)
 > ttclasses$due_date =  as.Date(ttclasses$due_date, format =
"mm/dd/yy")
 > ##ttclasses$name <- as.factor(ttclasses$name)
 >
 > # Define UI 
 > ui <- fluidPage(
 >
 >    # App title 
 >    titlePanel("Assessment Dashboard"),
 >
 >    # Sidebar layout with input and output definitions 
 >    sidebarLayout(
 >
 >      # Sidebar panel for inputs 
 >      sidebarPanel(
 >
 >        # Input: Selector for variable to plot the grades for the
selected
 > assignment 
 >        selectInput("assessment", "Assessment:",
 >                    c("Assignment 1" = "Assignment 1",
 >                      "Assignment 2" = "Assignment 2",
 >                      "Assignment 3" = "Assignment 3",
 >                      "Assignment 4" = "Assignment 4",
 >                      "Assignment 5" = "Assignment 5")),
 >        selectInput("name", "Name:",
 >                    ttclasses[,2]),
 >
 >      dateRangeInput("due_date",
 >   

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-07 Thread Biplab Nayak
Hi Rui,

Please find the data file attached here.

Thanks & Regards
Biplab Nayak

On Mon, Jun 7, 2021 at 4:21 PM Rui Barradas  wrote:

> Hello,
>
> This is not reproducible, we don't have access to ttclasses.csv.
> Can you post sample data? Please post the output of
>
> dput(ttclasses)
>
> Or, if it is too big, the output of
>
> dput(head(ttclasses, 20))
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> Às 18:03 de 07/06/21, Biplab Nayak escreveu:
> > Hi All,
> > I Need a bit of help to fix the code.
> > Code:
> > library(readr)
> > library(shiny)
> > ttclasses <- read_csv("ttclasses.csv")
> >
> > #Filter data
> > library(stringr)
> > library(dplyr)
> > ttclasses <-ttclasses %>%
> >filter(str_detect(assessment, "Assignment"))
> > ttclasses <-ttclasses %>%
> >filter(str_detect(name, "Name"))
> >
> > ##Remove NA values.
> > library(tidyverse)
> > ttclasses <-ttclasses %>% drop_na("score")
> >
> > #Convert to factor
> > ttclasses$assessment <- as.factor(ttclasses$assessment)
> > ttclasses$due_date =  as.Date(ttclasses$due_date, format = "mm/dd/yy")
> > ##ttclasses$name <- as.factor(ttclasses$name)
> >
> > # Define UI 
> > ui <- fluidPage(
> >
> ># App title 
> >titlePanel("Assessment Dashboard"),
> >
> ># Sidebar layout with input and output definitions 
> >sidebarLayout(
> >
> >  # Sidebar panel for inputs 
> >  sidebarPanel(
> >
> ># Input: Selector for variable to plot the grades for the selected
> > assignment 
> >selectInput("assessment", "Assessment:",
> >c("Assignment 1" = "Assignment 1",
> >  "Assignment 2" = "Assignment 2",
> >  "Assignment 3" = "Assignment 3",
> >  "Assignment 4" = "Assignment 4",
> >  "Assignment 5" = "Assignment 5")),
> >selectInput("name", "Name:",
> >ttclasses[,2]),
> >
> >  dateRangeInput("due_date",
> > "Due-Date:",start = max(ttclasses$due_date) ,
> > separator = " - ")
> >  ),
> >
> >  # Main panel for displaying outputs 
> >  mainPanel(
> >
> ># Output: Plot of the requested variable against grade 
> >plotOutput("gradePlot")
> >
> >  )
> >)
> > )
> >
> > # Define server logic to plot  
> > server <- function(input, output) {
> >  output$gradePlot <- renderPlot({
> >  grade_ad = input$assessment
> >  boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
> > frame.plot=FALSE, horizontal=TRUE, col="magenta", main=grade_ad)
> >  ttclasses <-ttclasses %>%
> >filter(ttclasses$due_date >= input$due_date[1] &
> ttclasses$due_date
> > <= input$due_date[2])
> >})
> > }
> >
> > # Create Shiny app 
> > shinyApp(ui, server)
> >
> > Thanks & Regards
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-07 Thread Rui Barradas

Hello,

Thanks for the data.
There were some, not many, bugs that I have corrected below.



library(tidyverse)
#library(stringr)# attached with tidyverse
#library(readr)
library(shiny)

ttclasses <- read_csv("~/tmp/ttclasses.csv")

#Filter data
ttclasses <-ttclasses %>%
  filter(str_detect(assessment, "Assignment"))

# With the attached data this filter
# removes all rows so I have
# commented it out
#ttclasses <-ttclasses %>%
#  filter(str_detect(name, "Name"))

##Remove NA values.
ttclasses <-ttclasses %>% drop_na("score")

#Convert to factor
ttclasses$assessment <- factor(ttclasses$assessment)

# please see the formats in help("strptime")
ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")
##ttclasses$name <- factor(ttclasses$name)

# Define UI 
ui <- fluidPage(

  # App title 
  titlePanel("Assessment Dashboard"),

  # Sidebar layout with input and output definitions 
  sidebarLayout(

# Sidebar panel for inputs 
sidebarPanel(

  # Input: Selector for variable to plot the grades for the selected
  # assignment 
selectInput("assessment", "Assessment:",
c("Assignment 1" = "Assignment 1",
  "Assignment 2" = "Assignment 2",
  "Assignment 3" = "Assignment 3",
  "Assignment 4" = "Assignment 4",
  "Assignment 5" = "Assignment 5")),
  selectInput("name", "Name:",
  ttclasses[,2]),

  dateRangeInput("due_date",
 "Due-Date:",start = max(ttclasses$due_date) ,
 separator = " - ")
),

# Main panel for displaying outputs 
mainPanel(

  # Output: Plot of the requested variable against grade 
  plotOutput("gradePlot")

)
  )
)

# Define server logic to plot  
server <- function(input, output) {
  output$gradePlot <- renderPlot({
grade_ad = input$assessment
boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
frame.plot=FALSE, horizontal=TRUE, col="magenta", 
main=grade_ad)

ttclasses <-ttclasses %>%
  filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
 <= input$due_date[2])
  })
}

# Create Shiny app 
shinyApp(ui, server)



Hope this helps,

Rui Barradas

Às 18:03 de 07/06/21, Biplab Nayak escreveu:

Hi All,
I Need a bit of help to fix the code.
Code:
library(readr)
library(shiny)
ttclasses <- read_csv("ttclasses.csv")

#Filter data
library(stringr)
library(dplyr)
ttclasses <-ttclasses %>%
   filter(str_detect(assessment, "Assignment"))
ttclasses <-ttclasses %>%
   filter(str_detect(name, "Name"))

##Remove NA values.
library(tidyverse)
ttclasses <-ttclasses %>% drop_na("score")

#Convert to factor
ttclasses$assessment <- as.factor(ttclasses$assessment)
ttclasses$due_date =  as.Date(ttclasses$due_date, format = "mm/dd/yy")
##ttclasses$name <- as.factor(ttclasses$name)

# Define UI 
ui <- fluidPage(

   # App title 
   titlePanel("Assessment Dashboard"),

   # Sidebar layout with input and output definitions 
   sidebarLayout(

 # Sidebar panel for inputs 
 sidebarPanel(

   # Input: Selector for variable to plot the grades for the selected
assignment 
   selectInput("assessment", "Assessment:",
   c("Assignment 1" = "Assignment 1",
 "Assignment 2" = "Assignment 2",
 "Assignment 3" = "Assignment 3",
 "Assignment 4" = "Assignment 4",
 "Assignment 5" = "Assignment 5")),
   selectInput("name", "Name:",
   ttclasses[,2]),

 dateRangeInput("due_date",
"Due-Date:",start = max(ttclasses$due_date) ,
separator = " - ")
 ),

 # Main panel for displaying outputs 
 mainPanel(

   # Output: Plot of the requested variable against grade 
   plotOutput("gradePlot")

 )
   )
)

# Define server logic to plot  
server <- function(input, output) {
 output$gradePlot <- renderPlot({
 grade_ad = input$assessment
 boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
frame.plot=FALSE, horizontal=TRUE, col="magenta", main=grade_ad)
 ttclasses <-ttclasses %>%
   filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
<= input$due_date[2])
   })
}

# Create Shiny app 
shinyApp(ui, server)

Thanks & Regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-07 Thread Rui Barradas

Hello,

This is not reproducible, we don't have access to ttclasses.csv.
Can you post sample data? Please post the output of

dput(ttclasses)

Or, if it is too big, the output of

dput(head(ttclasses, 20))


Hope this helps,

Rui Barradas


Às 18:03 de 07/06/21, Biplab Nayak escreveu:

Hi All,
I Need a bit of help to fix the code.
Code:
library(readr)
library(shiny)
ttclasses <- read_csv("ttclasses.csv")

#Filter data
library(stringr)
library(dplyr)
ttclasses <-ttclasses %>%
   filter(str_detect(assessment, "Assignment"))
ttclasses <-ttclasses %>%
   filter(str_detect(name, "Name"))

##Remove NA values.
library(tidyverse)
ttclasses <-ttclasses %>% drop_na("score")

#Convert to factor
ttclasses$assessment <- as.factor(ttclasses$assessment)
ttclasses$due_date =  as.Date(ttclasses$due_date, format = "mm/dd/yy")
##ttclasses$name <- as.factor(ttclasses$name)

# Define UI 
ui <- fluidPage(

   # App title 
   titlePanel("Assessment Dashboard"),

   # Sidebar layout with input and output definitions 
   sidebarLayout(

 # Sidebar panel for inputs 
 sidebarPanel(

   # Input: Selector for variable to plot the grades for the selected
assignment 
   selectInput("assessment", "Assessment:",
   c("Assignment 1" = "Assignment 1",
 "Assignment 2" = "Assignment 2",
 "Assignment 3" = "Assignment 3",
 "Assignment 4" = "Assignment 4",
 "Assignment 5" = "Assignment 5")),
   selectInput("name", "Name:",
   ttclasses[,2]),

 dateRangeInput("due_date",
"Due-Date:",start = max(ttclasses$due_date) ,
separator = " - ")
 ),

 # Main panel for displaying outputs 
 mainPanel(

   # Output: Plot of the requested variable against grade 
   plotOutput("gradePlot")

 )
   )
)

# Define server logic to plot  
server <- function(input, output) {
 output$gradePlot <- renderPlot({
 grade_ad = input$assessment
 boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
frame.plot=FALSE, horizontal=TRUE, col="magenta", main=grade_ad)
 ttclasses <-ttclasses %>%
   filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
<= input$due_date[2])
   })
}

# Create Shiny app 
shinyApp(ui, server)

Thanks & Regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help to fix the max date filter problem in the date input

2021-06-07 Thread Biplab Nayak
Hi All,
I Need a bit of help to fix the code.
Code:
library(readr)
library(shiny)
ttclasses <- read_csv("ttclasses.csv")

#Filter data
library(stringr)
library(dplyr)
ttclasses <-ttclasses %>%
  filter(str_detect(assessment, "Assignment"))
ttclasses <-ttclasses %>%
  filter(str_detect(name, "Name"))

##Remove NA values.
library(tidyverse)
ttclasses <-ttclasses %>% drop_na("score")

#Convert to factor
ttclasses$assessment <- as.factor(ttclasses$assessment)
ttclasses$due_date =  as.Date(ttclasses$due_date, format = "mm/dd/yy")
##ttclasses$name <- as.factor(ttclasses$name)

# Define UI 
ui <- fluidPage(

  # App title 
  titlePanel("Assessment Dashboard"),

  # Sidebar layout with input and output definitions 
  sidebarLayout(

# Sidebar panel for inputs 
sidebarPanel(

  # Input: Selector for variable to plot the grades for the selected
assignment 
  selectInput("assessment", "Assessment:",
  c("Assignment 1" = "Assignment 1",
"Assignment 2" = "Assignment 2",
"Assignment 3" = "Assignment 3",
"Assignment 4" = "Assignment 4",
"Assignment 5" = "Assignment 5")),
  selectInput("name", "Name:",
  ttclasses[,2]),

dateRangeInput("due_date",
   "Due-Date:",start = max(ttclasses$due_date) ,
   separator = " - ")
),

# Main panel for displaying outputs 
mainPanel(

  # Output: Plot of the requested variable against grade 
  plotOutput("gradePlot")

)
  )
)

# Define server logic to plot  
server <- function(input, output) {
output$gradePlot <- renderPlot({
grade_ad = input$assessment
boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
frame.plot=FALSE, horizontal=TRUE, col="magenta", main=grade_ad)
ttclasses <-ttclasses %>%
  filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
<= input$due_date[2])
  })
}

# Create Shiny app 
shinyApp(ui, server)

Thanks & Regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help using lattice

2021-02-09 Thread Parkhurst, David F.
Thanks.  What editor do you use?  I'm working in a Mac, if that makes a 
difference.

From: Gerrit Draisma 
Date: Tuesday, February 9, 2021 at 5:10 PM
To: Parkhurst, David F. 
Cc: r-help@r-project.org 
Subject: Re: [R] Need help using lattice
Ha David,
I do not know.
It must be that your AprtoDec object  is different from month.abb.
Anyhow it should contain the labels for all twelve months!
If I copy your command in an interactive session I just get the message
that AprtoDec is not defined.

I understand that you type the commands interactively in an R session?
I usually prefer using an editor to write the program, and execute with a
 > source("dotplot.R",echo=TRUE)
command.
I like an editor with syntax highlighting and shows matching brackets.

I have attached my dotplot.R to this mail.

Gerrit

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help using lattice

2021-02-09 Thread Gerrit Draisma

Ha David,
I do not know.
It must be that your AprtoDec object  is different from month.abb.
Anyhow it should contain the labels for all twelve months!
If I copy your command in an interactive session I just get the message
that AprtoDec is not defined.

I understand that you type the commands interactively in an R session?
I usually prefer using an editor to write the program, and execute with a
> source("dotplot.R",echo=TRUE)
command.
I like an editor with syntax highlighting and shows matching brackets.

I have attached my dotplot.R to this mail.

Gerrit

Op 09-02-2021 om 21:14 schreef Parkhurst, David F.:

When I enter your line:
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
   month=factor(3:12,levels=1:12,
    labels=month.abb, ordered=TRUE))
I get + signs in front of month and label, as expected, and it follows with <

When I convert that to use my own variable names to this:
df <- expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE"),
     monames=factor(3:12, levels=1:12,
        labels=AprToDec, ordered=TRUE))
  I get + signs in front of monames and labels, again as expected, but then it 
gives me another + sign.  And if I try to add another ), it keeps giving me + 
signs.  What is happening here?

From: Gerrit Draisma 
Date: Tuesday, February 9, 2021 at 6:14 AM
To: Parkhurst, David F. 
Cc: r-help@r-project.org 
Subject: Re: [R] Need help using lattice
Ha David,
Thanks for your reply.
For your last question, you have to change month into an ordered factor
variable:

library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
   month=factor(3:12,levels=1:12,
    labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH, Gerrit



Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:

That worked nicely;  thanks again.  Here’s what I used for our data:

library(lattice)

df <-
expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)

dotplot(months~conc | site, data=df)

The result is attached.  Is there a way to replace the month numbers on
the y axes with the names Apr-Dec?

David

library(lattice)
# month is defined as a factor with 12 levels, of which only levels 4 to 12
# are present in the data. 
# Note that month.abb is a predefined constant in R.
# Here it provides the labels for all 12 levels. 
df <- expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE"),
  month=factor(4:12,levels=1:12,
   labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
# introduce some missing values
i <- sample(1:dim(df)[1],6)
df$conc[i] <- NA
# so there some missing points in the plot
dotplot(month~conc|site,data=df)


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help using lattice

2021-02-09 Thread Parkhurst, David F.
When I enter your line:
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
  month=factor(3:12,levels=1:12,
   labels=month.abb, ordered=TRUE))
I get + signs in front of month and label, as expected, and it follows with <

When I convert that to use my own variable names to this:
df <- expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE"),
    monames=factor(3:12, levels=1:12,
       labels=AprToDec, ordered=TRUE))
 I get + signs in front of monames and labels, again as expected, but then it 
gives me another + sign.  And if I try to add another ), it keeps giving me + 
signs.  What is happening here?

From: Gerrit Draisma 
Date: Tuesday, February 9, 2021 at 6:14 AM
To: Parkhurst, David F. 
Cc: r-help@r-project.org 
Subject: Re: [R] Need help using lattice
Ha David,
Thanks for your reply.
For your last question, you have to change month into an ordered factor 
variable:

library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
  month=factor(3:12,levels=1:12,
   labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH, Gerrit



Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:
> That worked nicely;  thanks again.  Here’s what I used for our data:
> 
> library(lattice)
> 
> df <- 
> expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)
> 
> dotplot(months~conc | site, data=df)
> 
> The result is attached.  Is there a way to replace the month numbers on 
> the y axes with the names Apr-Dec?
> 
> David
> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help using lattice

2021-02-09 Thread Parkhurst, David F.
Thank you.

From: Gerrit Draisma 
Date: Tuesday, February 9, 2021 at 6:14 AM
To: Parkhurst, David F. 
Cc: r-help@r-project.org 
Subject: Re: [R] Need help using lattice
Ha David,
Thanks for your reply.
For your last question, you have to change month into an ordered factor
variable:

library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
  month=factor(3:12,levels=1:12,
   labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH, Gerrit



Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:
> That worked nicely;  thanks again.  Here�s what I used for our data:
>
> library(lattice)
>
> df <-
> expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)
>
> dotplot(months~conc | site, data=df)
>
> The result is attached.  Is there a way to replace the month numbers on
> the y axes with the names Apr-Dec?
>
> David
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help using lattice

2021-02-09 Thread Gerrit Draisma

Ha David,
Thanks for your reply.
For your last question, you have to change month into an ordered factor 
variable:


library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
 month=factor(3:12,levels=1:12,
  labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH, Gerrit



Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:

That worked nicely;  thanks again.  Here’s what I used for our data:

library(lattice)

df <- 
expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)


dotplot(months~conc | site, data=df)

The result is attached.  Is there a way to replace the month numbers on 
the y axes with the names Apr-Dec?


David



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help calculating the sum of the index function

2021-02-08 Thread Ablaye Ngalaba
Hello;


q=3 #dimension of variable Y
R=c(5,4,3);# Number of partition of each component of variable Y
if(length(R) != q) stop("The size of R must be equal to q")
n=25 # Sample size
N=c(25,50,100,200,300,400,500,1000) #different sample sizes

 # Creation of an n11 list containing the sizes of the different groups
  n11=list()
  for (i in 1:q){
n11[[i]]=rep(as.integer(n/R[i]),R[i])
n11[[i]][R[i]]=n-((R[i]-1)*n11[[i]][1])
  }




The present code calculates the sum of the indicator function (the
indicator function gives 1 if Y belongs to the partition R=c(5,4,3);#
Number of partition of each component of variable Y and takes the value 0
otherwise).


In my case I want to calculate the sum of the indicator function for i
=1,...,n , with the indicator function which takes the value 1 if Y==l and
0 if Y!=l. Y is a random variable with a value in F = {1,...,q} and l
belongs to F = {1,...,q}.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help using lattice

2021-02-08 Thread Gerrit Draisma

David,
Is this what you are looking for?
library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
 month=1:12)
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH Gerrit

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help using lattice

2021-02-08 Thread John Kane
 http://adv-r.had.co.nz/Reproducibility.html

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

On Mon, 8 Feb 2021 at 03:11, PIKAL Petr  wrote:

> Hi
>
> Please do not use HTML formating.
> Please provide some toy data if you want to get reasonable help.
>
> You could also look at ggplot package, e.g.
>
> https://ggplot2.tidyverse.org/reference/facet_grid.html
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help  On Behalf Of Parkhurst,
> David
> > F.
> > Sent: Sunday, February 7, 2021 8:02 PM
> > To: r-help@r-project.org
> > Subject: [R] Need help using lattice
> >
> > I have a dataframe comprising a vector of E. coli concentrations, a
> vector of
> > months when the samples were taken, and a vector of sampled sites.  I�d
> > like to produce a lattice with sites along the horizontal axis, and
> months on
> > the vertical.  Each site-month box would then contain concentrations
> ranging
> > along its x axis.
> >
> >
> >
> > I think this would use dotchart (or possibly stripchart) in the
> lattice.  I�ve
> > been reading the lattice and xyplot documents and I�m overwhelmed.  I�d
> > appreciate help in how to write the call.
> >
> >
> >
> > David
> >
> >
> >   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
John Kane
Kingston ON Canada

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help to create a 3-dimensional list

2021-02-08 Thread PIKAL Petr
Hallo again

 

Your attachment is discarded by listserv so we did not get it. Do not use 
attachments.

 

Cheers

Petr

 

 

From: Ablaye Ngalaba  
Sent: Monday, February 8, 2021 3:04 PM
To: PIKAL Petr 
Subject: Re: [R] need help to create a 3-dimensional list

 

Sorry, I thought I would make my question clear since with the pdf I clearly 
materialize the shape of what I want to calculate.



Thank you and have a nice day.

 

Le lun. 8 févr. 2021 à 13:56, PIKAL Petr mailto:petr.pi...@precheza.cz> > a écrit :

Hi

No attachments allowed (usually).

What do you mean by 3 dimensional list? List itself can contain objects
which could also be lists.

Cheers
Petr

> -Original Message-
> From: R-help  <mailto:r-help-boun...@r-project.org> > On Behalf Of Ablaye Ngalaba
> Sent: Monday, February 8, 2021 1:33 PM
> To: r-help@r-project.org <mailto:r-help@r-project.org> 
> Subject: [R] need help to create a 3-dimensional list
> 
> Hello,
> please, I need help to calculate n_l properly for my attachment.
> 
> 
> 
>   Sincerely
> __
> R-help@r-project.org <mailto:R-help@r-project.org>  mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help to create a 3-dimensional list

2021-02-08 Thread PIKAL Petr
Hi

No attachments allowed (usually).

What do you mean by 3 dimensional list? List itself can contain objects
which could also be lists.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Ablaye Ngalaba
> Sent: Monday, February 8, 2021 1:33 PM
> To: r-help@r-project.org
> Subject: [R] need help to create a 3-dimensional list
> 
> Hello,
> please, I need help to calculate n_l properly for my attachment.
> 
> 
> 
>   Sincerely
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] need help to create a 3-dimensional list

2021-02-08 Thread Ablaye Ngalaba
Hello,
please, I need help to calculate n_l properly for my attachment.



  Sincerely
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help using lattice

2021-02-08 Thread PIKAL Petr
Hi

Please do not use HTML formating.
Please provide some toy data if you want to get reasonable help.

You could also look at ggplot package, e.g.

https://ggplot2.tidyverse.org/reference/facet_grid.html

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Parkhurst, David
> F.
> Sent: Sunday, February 7, 2021 8:02 PM
> To: r-help@r-project.org
> Subject: [R] Need help using lattice
> 
> I have a dataframe comprising a vector of E. coli concentrations, a vector of
> months when the samples were taken, and a vector of sampled sites.  I�d
> like to produce a lattice with sites along the horizontal axis, and months on
> the vertical.  Each site-month box would then contain concentrations ranging
> along its x axis.
> 
> 
> 
> I think this would use dotchart (or possibly stripchart) in the lattice.  I�ve
> been reading the lattice and xyplot documents and I�m overwhelmed.  I�d
> appreciate help in how to write the call.
> 
> 
> 
> David
> 
> 
>   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help using lattice

2021-02-07 Thread Parkhurst, David F.
I have a dataframe comprising a vector of E. coli concentrations, a vector of 
months when the samples were taken, and a vector of sampled sites.  I�d like to 
produce a lattice with sites along the horizontal axis, and months on the 
vertical.  Each site-month box would then contain concentrations ranging along 
its x axis.



I think this would use dotchart (or possibly stripchart) in the lattice.  I�ve 
been reading the lattice and xyplot documents and I�m overwhelmed.  I�d 
appreciate help in how to write the call.



David


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help calculating the indicator function

2021-01-30 Thread Rui Barradas

Hello,

Please cc the list, R-Help is threaded and your doubt and answers might 
be of interest to others.


With a vector Y, you want 0 in all Y != l and 1 in all Y == l?


n_l <- function(Y, l) as.integer(Y == l)


Hope this helps,

Rui Barradas

Às 11:26 de 30/01/21, Ablaye Ngalaba escreveu:

Hello Rui,
thank you for answering me.
I compiled your code, it's true that it works but it still gives the 
value "3". What I want is to find either 1 if Y==l or 0 in case y 
differs from l.



Good day

Le sam. 30 janv. 2021 à 10:42, Ablaye Ngalaba > a écrit :


Thanks.

Le sam. 30 janv. 2021 à 05:38, Rui Barradas mailto:ruipbarra...@sapo.pt>> a écrit :

Hello,

Maybe this?

n_l <- function(Y, l, na.rm = FALSE) sum(Y == l, na.rm = na.rm)

set.seed(2020)
q <- 6
y <- sample(q, 10, TRUE)

l <- 4
n_l(y, l)
#[1] 3


Hope this helps,

Rui Barradas


Às 14:27 de 29/01/21, Ablaye Ngalaba escreveu:
 > Hello,
 > please, I need to calculate the indicator function as I
underlined in my
 > attached pdf file but I can't define a code in programming
language that
 > deals with this case. Please help me with a code whether it's
in python or
 > R can help me.
 >
 >
 >
 >     Sincerely.
 >
 >
 > __
 > R-help@r-project.org  mailing
list -- To UNSUBSCRIBE and more, see
 > https://stat.ethz.ch/mailman/listinfo/r-help
 > PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 > and provide commented, minimal, self-contained, reproducible
code.
 >



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help calculating the indicator function

2021-01-29 Thread Rui Barradas

Hello,

Maybe this?

n_l <- function(Y, l, na.rm = FALSE) sum(Y == l, na.rm = na.rm)

set.seed(2020)
q <- 6
y <- sample(q, 10, TRUE)

l <- 4
n_l(y, l)
#[1] 3


Hope this helps,

Rui Barradas


Às 14:27 de 29/01/21, Ablaye Ngalaba escreveu:

Hello,
please, I need to calculate the indicator function as I underlined in my
attached pdf file but I can't define a code in programming language that
deals with this case. Please help me with a code whether it's in python or
R can help me.



Sincerely.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help calculating the indicator function

2021-01-29 Thread David Winsemius
Perhaps (in R):


n_i <- cumsum( Y==l )


You should read further regarding R's logical class, and operators that 
work on it, and how it is coerced.

-- 

David

On 1/29/21 6:27 AM, Ablaye Ngalaba wrote:
> Hello,
> please, I need to calculate the indicator function as I underlined in my
> attached pdf file but I can't define a code in programming language that
> deals with this case. Please help me with a code whether it's in python or
> R can help me.
>
>
>
> Sincerely.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] need help calculating the indicator function

2021-01-29 Thread Bert Gunter
Is this a homework problem? The posting guide linked below explicitly says:

"*Basic statistics and classroom homework:* R-help is not intended for
these."



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Fri, Jan 29, 2021 at 2:20 PM Ablaye Ngalaba 
wrote:

> Hello,
> please, I need to calculate the indicator function as I underlined in my
> attached pdf file but I can't define a code in programming language that
> deals with this case. Please help me with a code whether it's in python or
> R can help me.
>
>
>
>Sincerely.
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to calculate allele score

2020-11-25 Thread Bert Gunter
This list has a no-homework policy. Referring to the posting guide linked
below:

"*Basic statistics and classroom homework:* R-help is not intended for
these."

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Nov 25, 2020 at 1:27 PM Anas Jamshed 
wrote:

> Go to page http://zzz.bwh.harvard.edu/plink/profile.shtml and follow the
> help to generate a basic allele score using your independently associated
> SNPs.  Use R to make the myprofile.rawfile required.
>
> I am unable to generate .raw file which will contain allele score
>
> I have tried this script:
> results_2049669_adjusted <-
> read.table("results_2049669.assoc.linear.adjusted", header=T)
>
> #display first 15 SNPs
> results_2049669_adjusted [1:15,]
>
> system("plink_mac/plink --bfile BB5707 --clump results_2049669.assoc.linear
> --clump-p1 5e-08 --clump-p2 0.05 --clump-r2 0.1 --clump-kb 250 --out
> results_2049669.assoc.linear_clumped")
>
> results_2049669_clumped <-
> read.table("results_2049669.assoc.linear_clumped.clumped", header=T)
> results_2049669_clumped[1:15 ,1:6] ## 2 hits we have
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help to calculate allele score

2020-11-25 Thread Anas Jamshed
Go to page http://zzz.bwh.harvard.edu/plink/profile.shtml and follow the
help to generate a basic allele score using your independently associated
SNPs.  Use R to make the myprofile.rawfile required.

I am unable to generate .raw file which will contain allele score

I have tried this script:
results_2049669_adjusted <-
read.table("results_2049669.assoc.linear.adjusted", header=T)

#display first 15 SNPs
results_2049669_adjusted [1:15,]

system("plink_mac/plink --bfile BB5707 --clump results_2049669.assoc.linear
--clump-p1 5e-08 --clump-p2 0.05 --clump-r2 0.1 --clump-kb 250 --out
results_2049669.assoc.linear_clumped")

results_2049669_clumped <-
read.table("results_2049669.assoc.linear_clumped.clumped", header=T)
results_2049669_clumped[1:15 ,1:6] ## 2 hits we have

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in programming R on functional data

2020-10-29 Thread Michael Dewey
You have already asked this and people gave you a variety of answers. 
Just asking again without clarifying why those answers did not help you 
is not going to solve your problem.


Tell us what you tried and why it failed might help.

Michael

On 29/10/2020 07:50, Ablaye Ngalaba wrote:

Hello,
I need to generate the functional data in R programming but I can't do it.
Please, an example of R code that generates the functional data can help me.



Thank you and have a nice day

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help in programming R on functional data

2020-10-29 Thread Ablaye Ngalaba
Hello,
I need to generate the functional data in R programming but I can't do it.
Please, an example of R code that generates the functional data can help me.



Thank you and have a nice day

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R code of the functional data .

2020-10-17 Thread Richard O'Keefe
I do not understand your question.

Are you talking about "functional data analysis", the statistical
analysis of data where some of the covariates are (samples from)
continuous functions?  There are books and tutorials about doing
that in R.

Are you talking about "functional data structures", as described
in Thomas Mailund's book "Functional Data Structures in R"?

Are you asking a more elementary question, about functions
*being* data values that can be passed as parameters, returned
from functions, stored in variables, and held as elements of
lists?  See Rui Barradas' response for that.

On Sat, 17 Oct 2020 at 04:10, Ablaye Ngalaba 
wrote:

> Hello,
> Please, I want to know how the functional data are defined in programming
> code R. If possible an illustrative example of code can help me to
> understand better.
>
>
>
>
>
>Yours sincerely.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in R code of the functional data .

2020-10-16 Thread Rui Barradas

Hello,

You have asked several times about functional data, I really do not 
understand what you mean but if you want to learn about writing R 
functions, take a look at


doc/manual/R-intro.pdf, that comes with any installation of R, chap. 10 
Writing your own functions.


And at any of Hadley Wickham's excelent


https://r4ds.had.co.nz/functions.html
http://adv-r.had.co.nz/Functions.html


Hope this helps,

Rui Barradas

Às 16:09 de 16/10/20, Ablaye Ngalaba escreveu:

Hello,
Please, I want to know how the functional data are defined in programming
code R. If possible an illustrative example of code can help me to
understand better.





Yours sincerely.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   3   4   5   6   7   8   9   >