I have (used to have?) a function plot_ascii() which would display the
ascii character set in a graphical display. It simply used text() to
place the symbols on a 16 x 16 grid. The labels used by text() were
taken from a character vector that I called "all.ascii". According to
my notes, the
Hi Avi,
Thank you for your patient with me!!
Your code below generated what I want.
test %>%
group_by(group1,group2) %>%
mutate(count2 = ifelse(row_number()==1, TRUE, FALSE)) %>%
ungroup()
your code reminded me of the SAS first. And last. Function. I gave up SAS
several years ago.
Still can't makes sense of it. Shouldn't rows 5-7 have 3 for counts
and rows 8-9 have 2? If not, then I give up trying to figure out what
you mean. Maybe someone wlse can.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus
Ding,
Just to get you to stop asking, here is a solution I hope works.
In English, if you are asking that ONE instance of a duplicate be marked in
a new column with TRUE or 1 while all remaining ones are marked as FALSE or
2 or whatever, that is easy enough. The method is to use the assistive
I am very agnostic about tidyverse/base R. However, the complexity of
setting up NSE functions is often simply not needed, and I encounter so
many people who simply disregard base R as being too outdated so that they
never learn how simple solutions in R can be. The contrast between your
Hi Jeff,
Your code generated the count what I wanted.
As I emailed to Bert, yes, I made a mistake when generating the toy table, the
second count value should be 2.
Correct file is
test <- data.frame(group1=c("g1", "g1", "g1", "g2", "g2", "g2", "g2", "g2",
"g2"),
Hi Bert,
I am very sorry that I made a mistake for the second count value. The original
data are much more complicated, I just made a toy table.
test <- data.frame(group1=c("g1", "g1", "g1", "g2", "g2", "g2", "g2", "g2",
"g2"),
group2=c("k1", "a2",
I am not sure I understand... you are referring to files but we are not
discussing files here. There are "input" and "output" phases yet to be
dealt with that separate the analysis you do in R from the files
themselves. We are discussing data frames here.
Regardless, you either have
Your example makes no sense (to me, anyway). Please check it
carefully. Note that the count in rows 2 and 3 increment but the
counts in rows 5-7 or rows 8-9 do not. So your specification seems
inconsistent to me.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
Hi Jeff,
Thank you for your quick response!!
I made this following summary file, however, I want to add the count number
sequentially into the original file, because I have several more columns to
explain or annotate the first two columns.
count_test <- test %>% group_by(group1 )
It is poor analytical design to keep duplicates. If they are not duplicates
then there should be a distinguishing additional column. IMO you should
re-think your analysis rather than accomplish this short-term goal only to find
down the road that this duplication causes future problems.
On
Hi R users,
In this test file,
test <- data.frame(group1=c("g1", "g1", "g1", "g2", "g2", "g2", "g2", "g2",
"g2"),
group2=c("k1", "a2", "a2", "c5", "n6",
"n6", "n6", "m10","m10"),
count= c( 1, 1,2, 1, 2,
I know what you mean Jeff. Yes I am very familiar with base R techniques. What
I had hoped for was to do two things that some of the other methods mentioned
do that ended up bringing two data.frames together as part of the solution.
Much of what I used is now standard R. I was looking at the
Definitely doable and you are on the right path and maybe even close.
The error message you got showed your query as having the wrong info after
the 'FROM'
keyword
' SELECT * FROM c("BIODBX.MECCUNIQUE2", "BIODBX.QDATA_HTML_DUMMY",
"BIODBX.SET_ITEMS", "BIODBX.SET_NAMES", "dbo.sysdiagrams",
Hi Eric,
Thank you spent time to help me for this.
Here is the thing: I was requested to manage a sql server for my group. the
server has many schemas and the tables (>200). I use ODBC to connect the server
and get the schema name + table name into a data frame.
For each of schema + table on
Not all advice received on the Internet is safe.
https://xkcd.com/327
https://db.rstudio.com/best-practices/run-queries-safely
It is not that much more difficult to do it right.
On July 2, 2021 12:05:43 PM PDT, Eric Berger wrote:
>Modify the summ() function to start like this
>
>summ <-
Hard for me to tell without more details but it looks like the following
has several bugs
for (i in dbtable$Tot_table)
{
Tabname <- as.character(sqldf(sprintf("SELECT Tot_table FROM dbtable",
i)))
summ(Tabname)
}
Your sprintf() statement seems to use 'i' but actually does not.
You probably
Hello Eric,
Following your suggestion, I modified the code as:
summ <- function(Tabname){
query <- sprintf(" SELECT * FROM %s",Tabname)
res <- dbGetQuery(con, query)
view(dfSummary(res), file =
"W:/project/_Joe.B/MSSQL/try/summarytools.Tabname.html")
rm(res)
}
for (i in
Modify the summ() function to start like this
summ <- function(Tabname){
query <- sprintf(" SELECT * FROM %s",Tabname)
res <- dbGetQuery(con, query)
etc
HTH,
Eric
On Fri, Jul 2, 2021 at 9:39 PM Kai Yang via R-help
wrote:
> Hello List,
>
> The previous post look massy. I repost my
Works like a charm.
Thanks so much.
--John Sparks
From: Bill Dunlap
Sent: Thursday, July 1, 2021 8:01 PM
To: Sparks, John
Cc: r-help@r-project.org
Subject: Re: [R] List / Matrix to Data Frame
Does this do what you want?
> df <- data.frame(check.names=FALSE,
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 =
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)
¡Muchas gracias, Carlos!
Entonces, los tiempos que pusiste al principio, en los que había grandes
diferencias, ¿de dónde salieron?
¡Muchas gracias, como siempre, por tus grandes aportaciones!
Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Consejería de Economía, Empresas y
23 matches
Mail list logo