-- Forwarded message -
From: Kathan Desai
Date: Sat, 4 Jul 2020 at 14:31
Subject: Re: [R] Help with looping a function over a list of dataframes:
To: Jim Lemon
Hi Jim,
Thankyou for your reply, I tried the function you suggested and it
doesn't seem to work. There are again no
Hi Kathan,
How about trying to create a *minimal* reproducible example, e.g. with a
list of two data frames, where each data frame has 5 rows,?
My guess is that there is a good chance that when you try to create such an
example, you will discover the problem yourself.
In the event that you create
And post a minimal reproducible example (perhaps using dput(head(dta))).
On July 4, 2020 7:41:28 AM PDT, Bert Gunter wrote:
>You should post on r-sig-geo, not here. You are much more likely to
>find
>the interest and expertise you seek there.
>
>Bert Gunter
>
>"The trouble with having an open
Hi Kathan,
This is a very lazy answer as I haven't tested it. I think you will
need to wrap your loop in a function and return the modified list_df
to assign it like this:
add_IDs<-function(xdf) {
for(i in seq_along(xdf)) {
xdf$position_tab_[[i]]$ID <-
*I hope this is more succinct.*
*I have the following code: *
list_df$position_tab_5$ID <- unlist(lapply(list_df$position_tab_5$midpoint,
function(x) ifelse(any(abs(x - list_df$position_tab_4$midpoint) <= 1),1,0)))
It compares every observation from the midpoint column from dataframe 2 to
every
Dear List,
I have a postcode file containing geographical coordinates but this is not in
the
format of a standard shape file. I list the first 5 observations below;
Postcode Postcode_geometry
You should post on r-sig-geo, not here. You are much more likely to find
the interest and expertise you seek there.
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 )
I have been trying to run a forloop for a function that compares dataframe n
with dataframe n-1, across a list of dataframes. It does this by checking
each midpoint of dataframe n with each midpoint of dataframe n-1. This is
done to make up for an disparity in row length. The idea of this code is
Perhaps the following will be helpful (you can ignore the warning message
here):
> set.seed(1001)
> x <- sample(1:5,10, rep = TRUE)
> y <- sample(1:5,12, rep = TRUE)
> n <- seq_len(min(length(x), length(y)))
> flag <- as.numeric(abs(x-y)[n] <= 1)
Warning message:
In x - y : longer object length
Hello thanks everyone for your help i managed to get a working function as
followed:
for(i in 2:length(list_df)){
list_df[[paste0("position_tab_",i)]][['ID']] <-
unlist(lapply(list_df[[paste0("position_tab_",i)]][['midpoint']],
function(x)
ifelse(any(abs(x -
Hola,
Si pudieras compartir un subconjunto de datos con el que se pudiera
entender mejor tu código...
Gracias,
Carlos Ortega
www.qualityexcellence.es
El sáb., 4 jul. 2020 a las 18:00, Andrés Hirigoyen (<
andreshirigo...@gmail.com>) escribió:
> Buenas mi duda es cómo sumar los valores de una
Buenas mi duda es cómo sumar los valores de una variable dentro de una
clase ya creada.
Por ejemplo:
#Creo el dataset que voy a completar, primero la secuencia con la q hare
las clases:
cl<-round(seq(0,max(data$h),0.5),2)
# Mi data frame con las clases
Va ejemplo:
data <- Ejemplo_List
cl<-round(seq(0,max(data$h),10),2) # seq para clases
df<-data.frame(min.h=cl[-length(cl)],max.h=cl[-1]) # Data frame con las
clases
df$class<-paste(df$min.h,df$max.h,sep="-") # Armo las Clases
df$Largo <-NA # Variable nueva
# Completo la columna "Largo" con la
Hola,
¿Son tres columnas?...
Solo tienen nombre dos...¿?
hID
1: 18,2 20556
2: 18,5 20556
3: 20,9 20556
4: 19,2 20665
Y lo que quieres al final ¿es sumar el valor de ID de cada clase?
Gracias,
Carlos Ortega.
El sáb., 4 jul. 2020 a las 22:30, Andrés Hirigoyen (<
De los datos de partida creo un nuevo data set donde las filas son rangos
de h (Clase). Las variables de ese nuevo set son: Largo, que corresponde al
conteo de observaciones que caen en cada Clase, y Total que es la suma de
los valores de ID de las observaciones de casa clase. Por ejemplo para la
Estimado Andés Hirigoyen
¿Puedes escribir todo desde cero? En mi caso no pude duplicar ni una línea
de su código, será configuración, incomprensión de mi parte. No lo se.
Tampoco logro interpretar que desea, la clase como clase estadística (alto,
rugoso, liso, bajo), o clase como colocar algo
16 matches
Mail list logo