Hi,
I would like to have help in converting from one image format to another
(between the packages EBImage, magick and imager). The magick package has
functions for this. But the EBImage and imager packages do not have
in-built functions for the conversion. It is, of course, possible to save
the images and then open with the other packages. But I am looking for more
direct options. I do not know how to assign data to the "slots" in the
functions.
### convert image formats
library(magick)
nuc_MAG_o <- image_read(system.file("images", "nuclei.tif",
package="EBImage"))
nuc_MAG_to_EB <- as_EBImage(manMAG)
nuc_MAG_to_IMG <- magick2cimg(manMAG,alpha="flatten")
# convert from EBImage
library(EBImage)
nucEBo <- readImage(system.file("images", "nuclei.tif", package="EBImage"))
writeImage(nucEBo, "C:/Rfiles/nuclei-3.jpg")
nucEB_to_IMG <-
nucEB_to_MAG <-
#convert from imager
library(imager)
nuc_IMG_o <- load.image("C:/Rfiles/nuclei-3.jpg")
nuc_IMG_to_EB <-
nuc_IMG_to_MAG <-
All help is appreciated.
Thanks,
Vivek
converting image formats
7 messages · Vivek Sutradhara, e-mail ma015k3113, Rui Barradas +3 more
Hi,
I have made a few corrections to my previous message in the naming of my
objects.
I would like to have help in converting from one image format to another
(between the packages EBImage, magick and imager). The magick package has
functions for this. But the EBImage and imager packages do not have
in-built functions for the conversion. It is, of course, possible to save
the images and then open with the other packages. But I am looking for more
direct options. I do not know how to assign data to the "slots" in the
functions.
### convert image formats
library(magick)
nuc_MAG_o <- image_read(system.file("images", "nuclei.tif",
package="EBImage"))
nuc_MAG_to_EB <- as_EBImage(nuc_MAG_o)
nuc_MAG_to_IMG <- magick2cimg(nuc_MAG_o,alpha="flatten")
# convert from EBImage
library(EBImage)
nuc_EB_o <- readImage(system.file("images", "nuclei.tif",
package="EBImage"))
writeImage(nucEBo, "C:/Rfiles/nuclei-3.jpg")
# to convert nuc_EB_o
nucEB_to_IMG <-
nucEB_to_MAG <-
#convert from imager
library(imager)
nuc_IMG_o <- load.image("C:/Rfiles/nuclei-3.jpg")
# to convert nuc_IMG_o
nuc_IMG_to_EB <-
nuc_IMG_to_MAG <-
Thanks,
Vivek
Den ons 24 mars 2021 kl 18:54 skrev Vivek Sutradhara <viveksutra at gmail.com>:
Hi,
I would like to have help in converting from one image format to another
(between the packages EBImage, magick and imager). The magick package has
functions for this. But the EBImage and imager packages do not have
in-built functions for the conversion. It is, of course, possible to save
the images and then open with the other packages. But I am looking for more
direct options. I do not know how to assign data to the "slots" in the
functions.
### convert image formats
library(magick)
nuc_MAG_o <- image_read(system.file("images", "nuclei.tif",
package="EBImage"))
nuc_MAG_to_EB <- as_EBImage(manMAG)
nuc_MAG_to_IMG <- magick2cimg(manMAG,alpha="flatten")
# convert from EBImage
library(EBImage)
nucEBo <- readImage(system.file("images", "nuclei.tif",
package="EBImage"))
writeImage(nucEBo, "C:/Rfiles/nuclei-3.jpg")
nucEB_to_IMG <-
nucEB_to_MAG <-
#convert from imager
library(imager)
nuc_IMG_o <- load.image("C:/Rfiles/nuclei-3.jpg")
nuc_IMG_to_EB <-
nuc_IMG_to_MAG <-
All help is appreciated.
Thanks,
Vivek
I have a data frame "PLC" which has two variables Year_END_Date EPS YEAR_END_Date EPS 2010-09-10 .10 2009-08-10 .20 When I tried to convert Year_END_Date to character format using select(PLC, format(Year_END_Date,format = "%B %d, %Y"), EPS) I get an error Error: Can't subset columns that don't exist. x Column `Year_END_Date` doesn't exist. I tried using PLC_1 <- select(PLC, as.character(YEAR_END_DATE), EPS) I get the following error Error: Can't subset columns that don't exist. x Columns `2010-09-30`, `2009-09-30`, `2008-09-30`, `2007-09-30`, `2006-09-30`, etc. don't exist. Run `rlang::last_error()` to see where the error occurred. Can anyone please guide me what is happening and how can I resolve it?
Hello, R is case sensitive, the column name is YEAR_END_Date, neither of Year_END_Date YEAR_END_DATE matches that name. Try select(PLC, format(YEAR_END_Date,format = "%B %d, %Y"), EPS) Hope this helps, Rui Barradas ?s 19:11 de 24/03/21, e-mail ma015k3113 via R-help escreveu:
I have a data frame "PLC" which has two variables Year_END_Date EPS YEAR_END_Date EPS 2010-09-10 .10 2009-08-10 .20 When I tried to convert Year_END_Date to character format using select(PLC, format(Year_END_Date,format = "%B %d, %Y"), EPS) I get an error Error: Can't subset columns that don't exist. x Column `Year_END_Date` doesn't exist. I tried using PLC_1 <- select(PLC, as.character(YEAR_END_DATE), EPS) I get the following error Error: Can't subset columns that don't exist. x Columns `2010-09-30`, `2009-09-30`, `2008-09-30`, `2007-09-30`, `2006-09-30`, etc. don't exist. Run `rlang::last_error()` to see where the error occurred. Can anyone please guide me what is happening and how can I resolve it?
______________________________________________ R-help at 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.
Please don't reply to a thread to start a new question... create a new email to avoid linking your question with the one you replied to.
On March 24, 2021 12:11:07 PM PDT, e-mail ma015k3113 via R-help <r-help at r-project.org> wrote:
I have a data frame "PLC" which has two variables Year_END_Date EPS YEAR_END_Date EPS 2010-09-10 .10 2009-08-10 .20 When I tried to convert Year_END_Date to character format using select(PLC, format(Year_END_Date,format = "%B %d, %Y"), EPS) I get an error Error: Can't subset columns that don't exist. x Column `Year_END_Date` doesn't exist. I tried using PLC_1 <- select(PLC, as.character(YEAR_END_DATE), EPS) I get the following error Error: Can't subset columns that don't exist. x Columns `2010-09-30`, `2009-09-30`, `2008-09-30`, `2007-09-30`, `2006-09-30`, etc. don't exist. Run `rlang::last_error()` to see where the error occurred. Can anyone please guide me what is happening and how can I resolve it?
______________________________________________ R-help at 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.
What package is select() in? 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, Mar 24, 2021 at 4:42 PM Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
Please don't reply to a thread to start a new question... create a new email to avoid linking your question with the one you replied to. On March 24, 2021 12:11:07 PM PDT, e-mail ma015k3113 via R-help < r-help at r-project.org> wrote:
I have a data frame "PLC" which has two variables Year_END_Date EPS YEAR_END_Date EPS 2010-09-10 .10 2009-08-10 .20 When I tried to convert Year_END_Date to character format using select(PLC, format(Year_END_Date,format = "%B %d, %Y"), EPS) I get an error Error: Can't subset columns that don't exist. x Column `Year_END_Date` doesn't exist. I tried using PLC_1 <- select(PLC, as.character(YEAR_END_DATE), EPS) I get the following error Error: Can't subset columns that don't exist. x Columns `2010-09-30`, `2009-09-30`, `2008-09-30`, `2007-09-30`, `2006-09-30`, etc. don't exist. Run `rlang::last_error()` to see where the error occurred. Can anyone please guide me what is happening and how can I resolve it?
______________________________________________ R-help at 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 at 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.
Hi ma015k3113,
I suspect that you are asking the wrong question.
# create an example data frame with an extra field
PLC<-read.table(text="YEAR_END_Date EPS junk
2010-09-10 .10 A
2009-08-10 .20 B",
header=TRUE,
stringsAsFactors=FALSE)
# first, I think that you may already have the date in character format
# if you get this result, you don't need to convert it
sapply(PLC,"class")
YEAR_END_Date EPS junk
"character" "numeric" "character"
# however, if you get this result
sapply(PLC,"class")
$YEAR_END_Date
[1] "POSIXlt" "POSIXt"
$EPS
[1] "numeric"
$junk
[1] "character"
# then you do have a POSIX date in the first field,
# so you can do this:
PLC$YEAR_END_Date<-format(PLC$YEAR_END_Date,format="%Y-%m-%d")
# then if you want to select those two fields for further processing
# use this expression
PLC[,c("YEAR_END_Date","EPS")]
Jim
On Thu, Mar 25, 2021 at 6:11 AM e-mail ma015k3113 via R-help
<r-help at r-project.org> wrote:
I have a data frame "PLC" which has two variables Year_END_Date EPS YEAR_END_Date EPS 2010-09-10 .10 2009-08-10 .20 When I tried to convert Year_END_Date to character format using select(PLC, format(Year_END_Date,format = "%B %d, %Y"), EPS) I get an error Error: Can't subset columns that don't exist. x Column `Year_END_Date` doesn't exist. I tried using PLC_1 <- select(PLC, as.character(YEAR_END_DATE), EPS) I get the following error Error: Can't subset columns that don't exist. x Columns `2010-09-30`, `2009-09-30`, `2008-09-30`, `2007-09-30`, `2006-09-30`, etc. don't exist. Run `rlang::last_error()` to see where the error occurred. Can anyone please guide me what is happening and how can I resolve it?
______________________________________________ R-help at 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.