Hi Team,I need to connect two MSSQL servers. One server ask me to enter user
name and password. I can use dbConnect (from DBI package) to connect the
serve.Another one do not ask me credential to access the serve. But when I
remove UID and PWD, it doesn't work. Then I tried to use my PC log in
Hi Team,I'm trying to run python in R markdown (flexdashboard). The code is
below:
try Python=
```{r, include=FALSE, echo=TRUE}library(reticulate)py_install("numpy")
use_condaenv("base")
```
```{python}import numpy as np```
I got error message below:
Error in py_call_impl(callable, d
Hi Team,I have multiple rmd files (~50) for difference study report. I did try
the source command to run them together, but it seems doesn't work.Is there a
way to run those rmd files from one script?Thanks,Kai
[[alternative HTML version deleted]]
ed to make some of these things fairly simple, such as dplyr
where you can ask to match names that start or end a certain way or that are of
certain types.
Avi
-Original Message-
From: R-help mailto:r-help-boun...@r-project.org> > On Behalf Of Kai Yang via R-help
Sent: Tuesday, Nove
Do you have any suggestion?
> Thanks,
> Kai On Tuesday, November 15, 2022 at 10:54:08 AM PST, Rui Barradas
> wrote:
>
> Às 16:18 de 15/11/2022, Kai Yang via R-help escreveu:
>> Hi Team,
>> I can write a for loop like this:
>> for (i in columns(df)){
>>
quot;ab2",["
I think I use [i] in a wrong way. Do you have any suggestion?
Thanks,
Kai On Tuesday, November 15, 2022 at 10:54:08 AM PST, Rui Barradas
wrote:
Às 16:18 de 15/11/2022, Kai Yang via R-help escreveu:
> Hi Team,
> I can write a for loop like this:
> for (i
d a certain way or that are of
certain types.
Avi
-Original Message-
From: R-help On Behalf Of Kai Yang via R-help
Sent: Tuesday, November 15, 2022 11:18 AM
To: R-help Mailing List
Subject: [R] add specific fields in for loop
Hi Team,
I can write a for loop like this:
for (i in columns(d
Hi Team,
I can write a for loop like this:
for (i in columns(df)){
..
}
But it will working on all column in dataframe df. If I want to work on some of
specific fields (say: the fields' name content 'date'), how should I modify the
for loop? I changed the code below, but it doesn't work.
f
It seems I cannot put names(i) into for loop, Could you please help me to
>> debug it?
>> Thank you,Kai On Monday, October 3, 2022 at 10:14:25 AM PDT, Rui Barradas
>> wrote:
>>
>> Hello,
>>
>>
>> list2env(file1, envir = .GlobalEnv)
t;
> will create data.frames dx1, dx2, etc, in the global environment.
> If you really need the names file1_dx1, file1_dx2, etc, you can first
> change the names
>
>
> names(file1) <- paste("file1", names(file1), sep = "_")
>
>
> and then r
t;)
and then run list2env like above.
Hope this helps,
Rui Barradas
Às 16:51 de 03/10/2022, Kai Yang via R-help escreveu:
> Hi R team,
> I can use rio package to read excel file into R as a list. The excel file
> content multiple sheets (30 - 40 data sheets). I can convert each data
>
Hi R team,
I can use rio package to read excel file into R as a list. The excel file
content multiple sheets (30 - 40 data sheets). I can convert each data elements
into dataframe manually. I have multiple excel files with multiple data sheets.
I need to load them into R and do the comparison fo
arget should be character (not factor) columns in your data
frame.
Cheers,Bert
On Mon, Sep 19, 2022 at 10:38 AM Kai Yang via R-help
wrote:
Hi Rui,I put original file names and target file names into data frame:
total_name. I can use
file.rename("out_1.pdf", "abc_title.pdf&q
- Using colnames to get the names of the
> columns that are in the first row, selecting the first element from
> colnames() and setting the file name equal to that.
>
> Do a for loop using current file names in some folder, and save to a new
> folder.
>
> Tim
>
>
range
> things will occur including data loss.
>
> Hope this helps,
>
> Rui Barradas
>
> Às 18:26 de 16/09/2022, Kai Yang via R-help escreveu:
>> Hello,I have a lot of files with not meaningful name, such as: file1.txt,
>> file2.txt .. I need to rename them us
Hello,I have a lot of files with not meaningful name, such as: file1.txt,
file2.txt .. I need to rename them using the information from the first row
of the files. Now I can get the information from the first row of each file.
Now, I need know how to rename them in R (using loop?). Thank yo
Hello Team,
I can run the function below:
library(tidyverse)
f2 <- function(indata, subgrp1){
indata0 <- indata
temp <- indata0 %>% select({{subgrp1}}) %>% arrange({{subgrp1}}) %>%
group_by({{subgrp1}}) %>%
mutate(numbering =row_number(), max=max(numbering))
view(temp)
f_table
Hi all,
I created a function in R. It will be generate a table "temp". I can view it in
R studio, but I cannot find it on the top right window in R studio. Can someone
tell me how to find it in there? Same thing for f_table.
Thank you,
Kai
library(tidyverse)
f1 <- function(indata , subgrp1){
s a data source or
perhaps select to pick only the data you want...
On 30 Dec 2021 18:42, Kai Yang via R-help wrote:
Hi R team,
I can create a plot using the code below:
library(ggplot2)
library(dplyr)
mpg %>%
filter(hwy <35) %>%
ggplot(aes(x = displ, y = hwy, color = cyl)) +
g
Hi R team,
I can create a plot using the code below:
library(ggplot2)
library(dplyr)
mpg %>%
filter(hwy <35) %>%
ggplot(aes(x = displ, y = hwy, color = cyl)) +
geom_point()
ggsave("c:/temp/hwy_cyl.jpg",width = 9, height = 6, dpi = 1200, units = "in")
I want to do the exactly same work usi
ylab(y) +
guides(
color = guide_legend(title = c)
)
ggsave(
filename = paste0("C:/temp/", f, ".jpg"),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
})
}
On Fri, D
eom_point() +
ylab(y) +
guides(
color = guide_legend(title = c)
)
ggsave(
filename = paste0("C:/temp/", f, ".jpg"),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
})
}
Hello Team,
I create a csv file (mac2) to save parameter values. the file looks like:
y,c,f
hwy,cyl,hwy_cyl2
cty,class,cty_class2
Then I load the file into R and apply the parameters y, c, f in for loop, see
my code below:
library(ggplot2)
library(tidyverse)
library(readr)
mac2 <- read_csv("C:/t
= c[i])) -> p[[i]]
ggsave(
paste0(tmpdir, f[i], ".jpg"),
plot = p[[i]],
width = 9,
height = 6,
dpi = 1200,
units = "in")
}
# See the first plot
p[[1]]
Hope this helps,
Rui Barradas
Às 18:18 de 22/12/21, Kai Yang via R-help escreveu:
> Hello Eric, Jim
ot;cty_class")
mac <- data.frame(y,c,f)
for (i in seq(nrow(mac))){
mpg %>%
filter(hwy <35) %>%
ggplot(aes(x = displ, y = y[i], color = c[i])) +
geom_point()
ggsave(paste0("c:/temp/",f[i],".jpg"),width = 9, height = 6, dpi = 1200,
units = "i
ot;),width = 9, height = 6, dpi = 1200,
units = "in")
}
On Wednesday, December 22, 2021, 09:42:45 AM PST, Ivan Krylov
wrote:
On Wed, 22 Dec 2021 16:58:18 + (UTC)
Kai Yang via R-help wrote:
> mpg %>% filter(hwy <35) %>% ggplot(aes(x = displ, y = y[i],
>
Hello R team,I want to use for loop to generate multiple plots with 3
parameter, (y is for y axis, c is for color and f is for file name in output).
I created a data frame to save the information and use the information in for
loop. I use y[i], c[i] and f[i] in the loop, but it seems doesn't wor
Hi team,I'm trying to pass macro variable into R script in Proc iml. I want to
do change variable in color= and export the result with different file name.If
I don't use macro, the code work well. But when I try to use macro below, I got
error message: "Submit block cannot be directly placed in
teps:
unwanted <- PD$Class == "1st" & PD$Survived == "No"test <- PD[!unwanted,]
On Mon, 13 Dec 2021 at 17:30, Kai Yang via R-help wrote:
Hi R team,I want to delete records from a data frame if Class = '1st' and
Survived = 'No'. I wrote the
Hi R team,I want to delete records from a data frame if Class = '1st' and
Survived = 'No'. I wrote the code below, test <- subset(PD, Class != '1st' &&
Survived != 'No')
but the code return a wrong result. Can someone help me for this?
Thanks,Kai
[[alternative HTML version deleted]]
___
Hi R team,When I use GTsummary to run summary table, I can add table title by
using modify_caption() function. But it is one row title only.Is it possible to
add title with multi rows for one summary table?Thanks,Kai
[[alternative HTML version deleted]]
__
Hello R team,we have a huge SOMAscan data set. This is an aptamer-based
protecomics assay capable of measuring 1305 human protein analytes. does anyone
know which package can load the data and do analysis? I apricate any
suggestion, your experience, web page, paper
Thank you,Kai
[[a
Hello List,
I submitted the code below, it will show two groups of avg_time bar chart for
each gc_label.
ggplot(s8_GCtime, aes(fill=GTresult, y=avg_time, x=gc_label, label = avg_time))
+
geom_bar(position=position_dodge(), stat="identity") +
geom_text(aes(label=avg_time), vjust=1.6, positi
Hello List,
I can order the general bar chart based on frequency, using ggplot2 with the
code : aes((reorder(Var1, Freq)), Freq))
I don't know how to order stacked bar plot by total frequency
Can you give me some of example?
Thank you
Kai
[[alternative HTML version deleted]]
___
; ggplot(s8_plot, aes(fill=GTresult, y=cases, x=gc_label)) +
>
> + geom_bar(position="stack", stat="identity"))
>
> Best,
>
> Grzegorz
>
> Od: Kai Yang via R-help
> Wysłano: środa, 15 września 2021 19:50
> Do: R-help Mailing List
> Temat: [R] ggplot
ill=GTresult, y=cases, x=gc_label)) +
+ geom_bar(position="stack", stat="identity"))
Best,
Grzegorz
Od: Kai Yang via R-help
Wysłano: środa, 15 września 2021 19:50
Do: R-help Mailing List
Temat: [R] ggplot question
Hello List,
I use ggplot to draw a stack bar chart. but
Hello List,
I use ggplot to draw a stack bar chart. but I error message. please look it
below:
> ggplot(s8_plot, aes(fill=GTresult, y=cases, x=gc_label) +
+ geom_bar(position="stack", stat="identity"))
Error: Mapping should be created with `aes()` or `aes_()`.
GTresult and gc_label are chara
Hi List,
I want to append some rows from R into sql server. So, I submitted the code
below. there is not any error message:
dbWriteTable(conn = con, name = "PMDB._Alias_A", value = try1, overwrite=FALSE,
append=TRUE, row.names = FALSE)
But when I try to query the data from the Sql server, I can n
Thanks Therneau, duplicated() function works well. --- Kai
On Friday, September 10, 2021, 05:13:47 AM PDT, Therneau, Terry M., Ph.D.
wrote:
I prefer the duplicated() function, since the final code will be clear to a
future reader.
(Particularly when I am that future reader).
last <
Hello List,
Please look at the sample data frame below:
ID date1 date2 date3
1 2015-10-08 2015-12-17 2015-07-23
2 2016-01-16 NA 2015-10-08
3 2016-08-01 NA 2017-01-10
3 2017-01-10 NA 2016-01
to:fra...@tcd.ie <mailto:fra...@tcd.ie>
mailto:fra...@gmail.com <mailto:fra...@gmail.com>
On Thu, 26 Aug 2021 at 20:04, Kai Yang via R-help mailto:r-help@r-project.org> > wrote:
Hi all,
I found something, but I don't know why it happen.
when I submitted the following code,
m it before passing that to ggplot.
Avi
-Original Message-
From: R-help On Behalf Of Kai Yang via R-help
Sent: Thursday, August 26, 2021 11:53 AM
To: R-help Mailing List
Subject: [R] ggplot error of "`data` must be a data frame, or other object
coercible by `fortify()`, not an S3
expects that argument to be a data frame or something
it can change into a data.frame. What you gave it probably is an object meant
to represent an EXCEL file or something. You may need to extract a data.frame
(or tibble or ...) from it before passing that to ggplot.
Avi
-Original Message-----
Fr
Hello List,
I got an error message when I submit the code below
ggplot(eth, aes(ymax=ymax, ymin=ymin, xmax=4, xmin=3, fill=ethnicity)) +
geom_rect() + coord_polar(theta="y") + xlim(c(2, 4) )
Error: `data` must be a data frame, or other object coercible by `fortify()`,
not an S3 object wit
Hello List,
I wrote the script below to assign value to a new field DisclosureStatus.
my goal is if gl_resultsdisclosed=1 then DisclosureStatus=DISCLOSED
else if gl_resultsdisclosed=0 then DisclosureStatus= ATTEMPTED
else if gl_resultsdisclosed is missing and gl_discloseattempt1 is not missing
the
t;
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Fri, Aug 13, 2021 at 2:48 PM Kai Yang via R-help
wrote:
>
> Hello John,
> I put my testing data below. I'm not sure how to use dupt() function. would
> you please give me an example?
> Th
ample
data is to use the dput() function. See ?dput. If you have a very
large data set then something like head(dput(myfile), 100) will likely
supply enough data for us to work with.
On Thu, 12 Aug 2021 at 11:45, Kai Yang via R-help wrote:
>
> Hello List,
> I use the following code to ge
Hello List,
I use the following code to generate a donut plot.
# Compute percentages
eth$fraction = eth$individuals / sum(eth$individuals)
# Compute the cumulative percentages (top of each rectangle)
eth$ymax = cumsum(eth$fraction)
# Compute the bottom of each rectangle
eth$ymin = c(0, head(eth$yma
quot;DB2", and "ora", I would try something like
setdiff(ls(), c("con", "DB2", "ora"))
and then add `rm` to that like
rm(list = setdiff(ls(), c("con", "DB2", "ora")))
On Wed, Jul 14, 2021 at 7:41 PM Kai Yang via R-help
wr
Hello List,
I have many data frames in environment. I need to keep 3 data frames only, con
DB2 and ora.
I write the script to do this.
rm(ls(pattern != c("(con|DB2|ora)")))
but it give me an error message:
Error in rm(ls(pattern != c("(con|DB2|ora)"))) :
... must contain names or charact
In the loop:
sdif[[j]] <- sqldf(etc)
Also, once again, why noquote? It's better to form file names with
file.path:
rdcsv <- file.path("w:/project/_Joe.B/Oracle/data", mycsv)
Hope this helps,
Rui Barradas
Às 16:55 de 14/07/2021, Kai Yang via R-help escreveu:
> Hello
Hello List,
I wrote a script below to compare the difference of data frames structure (and
will do something else). First of all I save the file list in a data frame ora,
then I use for loop to 1. load the data from two resource, 2. generate data
structure into two data frames, 3.do the compares
Thanks Bert,
I'm reading some books now. But it takes me a while to get familiar R.
Best,
KaiOn Friday, July 9, 2021, 03:06:11 PM PDT, Duncan Murdoch
wrote:
On 09/07/2021 5:51 p.m., Jeff Newmiller wrote:
> "Strictly speaking", Greg is correct, Bert.
>
> https://cran.r-project.org/doc/
te0(mycol,".csv")
rdcsv <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
rr[[j]] <- read.csv(rdcsv)
}
RegardsMigdonio G.
On Fri, Jul 9, 2021 at 1:10 PM Kai Yang via R-help wrote:
Hello List,
I use for loop to read csv difference file into data fr
Hello List,
I use for loop to read csv difference file into data frame rr. The data frame
rr will be deleted after a comparison and go to the next csv file. Below is my
code:
for (j in 1:nrow(ora))
{
mycol <- ora[j,"fname"]
mycsv <- paste0(mycol,".csv'")
rdcsv <- noquote(paste0("'w:/pr
Hello all,
I have to learning R from beginning, since my group will get rid of SAS. So, my
question may not be very clear for professional R user. I always dealing with
column in data frame, not data vector.
Many thanks to Greg's example. it is very helpful.
one more question, how can I know if
Hello List,
I have a one column data frame to store file name with extension. I want to
create new column to keep file name only without extension.
I tried to use strsplit("name1.csv", "\\.")[[1]] to do that, but it just retain
the first row only and it is a vector. how can do this for all of
ROUPS", "GEMD.GEMD_CODELIST_VALUES",
"GEMD.GEMD_LOT_DEFINITIONS", "GEMD.GEMD_SAMPLES", "GEMD.GEMD_STUDIES",
"GEMD.MECCUNIQUE", "GEMD.MECCUNIQUE2", "GEMD.MISSING_DI
One more question, in the code of "view(dfSummary(re
E2", "GEMD.MISSING_DI
One more question, in the code of "view(dfSummary(res), file =
"W:/project/_Joe.B/MSSQL/try/summarytools.Tabname.html")",
can Tabname part be replacted automatic also?
Thank you,
KaiOn Friday, July 2, 2021, 12:06:12 PM PDT, Eric Berger
wrote
Hello List,
The previous post look massy. I repost my question. Sorry,
I need to generate summary report for many tables (>200 tables). For each
table, I can use the script to generate report:
res <- dbGetQuery(con, "SELECT * FROM BIODBX.MECCUNIQUE2")
view(dfSummary(res), file =
"W:/project/_J
Hello List,I need to generate summary report for many tables (>200 tables). For
each table, I can use the script to generate repost:
res <- dbGetQuery(con, "SELECT * FROM BIODBX.MECCUNIQUE2")view(dfSummary(res),
file =
"W:/project/_Joe.B/MSSQL/try/summarytools.BIODBX.MECCUNIQUE2.html")rm(res)
BI
Hi List,I use odbc to connect a MSSQL server. When I run the script of "res <-
dbSendQuery(con, "SELECT * FROM BIODBX.MECCUNIQUE2")", the res is "Formal class
OdbcResult". Can someone help me to modify the code to get a data
frame?Thanks,Kai
[[alternative HTML version deleted]]
Hi Rui,
I use the code to fix my problem:
try$newcol <- gsub(" NA", "", try$newcol)
But, I'll try your solution later.
Thank you for your help.
Kai On Wednesday, June 2, 2021, 02:08:18 PM PDT, Kai Yang via R-help
wrote:
Hi List,
I use paste function to conc
Hi List,
I use paste function to concatenate 3 character columns together.
when I run table to see that, I found 3 categories. How can I write script to
trim NA in 2nd and 3rd group and set the first one as NA?
Thanks,
Kai
NA NA NA
NA NA Adenocarcinoma
NA Other NA
[[alternative HTML ver
Hello Jim,Your example works well.Thank you for your help,Kai
On Tuesday, June 1, 2021, 04:59:09 PM PDT, Kai Yang via R-help
wrote:
Hi List,
I have a column MMR in a data frame proband_crc2. The column contents missing
value and + (means positive).
I need to replace all missing value
Hi List,
I have a column MMR in a data frame proband_crc2. The column contents missing
value and + (means positive).
I need to replace all missing value into - (means negative)
I did try with difference ways. Below are my testing, but not any one works.
Can someone help me?
Thanks,
Kai
proband_
"")
testdf$c<-ifelse(testdf$a %in% match_strings,testdf$c,"")
testdf$d<-ifelse(testdf$a %in% match_strings,testdf$d,"")
testdf
I have assumed that you mean "zero length strings" rather than
"zeros". Also note that your initial code was producing
Hello List,I have a data frame which having the character columns:
| a1 | b1 | c1 | d1 |
| a2 | b2 | c2 | d2 |
| a3 | b3 | c3 | d3 |
| a4 | b4 | c4 | d4 |
| a5 | b5 | c5 | d5 |
I need to do: if a1 not = "Positive" and not = "VUS" then values of b1, c1 and
d1 will be zero out. And do the same
021, 01:37:58 AM PDT, Rui Barradas
wrote:
Hello,
ifelse needs a logical condition, not the value. Try grepl.
CRC$MMR.gene <- ifelse(grepl("MLH1"|"MSH2",CRC$gene.all), "Yes", "No")
Hope this helps,
Rui Barradas
Às 05:29 de 27/05/21, Kai Yang
Hi List,
I wrote the code to create a new variable:
CRC$MMR.gene<-ifelse(grep("MLH1"|"MSH2",CRC$gene.all,value=T),"Yes","No")
I need to create MMR.gene column in CRC data frame, ifgene.all column contenes
MLH1 or MSH2, then the MMR.gene=Yes, if not,MMR.gene=No
But, the code doesn't work for me
Hello list,I want to translate some of the R code into function, but I got
error message. I'm new for R. please point out where is my problem.thank you,Kai
the original working code:p1 <- select(raw ,Pedigree.name
,UPN ,Test.Result.tr_Test.Result1
how to fix the error
Thank you,Kai
On Friday, May 14, 2021, 05:38:18 PM PDT, Rolf Turner
wrote:
On Fri, 14 May 2021 17:42:12 + (UTC)
Kai Yang via R-help wrote:
> Hello List, I was trying to write a function. But I got a error
> message. Can someone help me how to fi
Hello List, I was trying to write a function. But I got a error message. Can
someone help me how to fix it?
Many thanks,Kai
> k_subset <- function(p, a, b, c){
+ p <- select(raw
+ ,Pedigree.name
+ ,UPN
+ ,a
+ ,b
+ ,c
+
73 matches
Mail list logo