sd function is giving NA

,

Hi community,
I'm facing problem in calculating standard deviation (at 10 intervals) using function--- sd

But I'm getting NA, please can you help me :slight_smile:

my data looks like this--

structure(list(Long = c(-88.75, -86.25, -83.75, -81.25, -78.75, 
-76.25, -73.75, -71.25, -68.75, -61.25, -58.75, -56.25, -53.75, 
-51.25, -48.75, -46.25, -43.75, -41.25, -38.75, -36.25, -33.75, 
-31.25, -28.75, -26.25, -23.75, -21.25, -18.75, -16.25, -13.75, 
-111.25, -103.75, -101.25, -93.75, -91.25, -88.75, -86.25, -83.75, 
-81.25, -78.75, -76.25, -68.75, -66.25, -63.75, -61.25, -58.75, 
-56.25, -53.75, -51.25, -48.75, -46.25), Lat = c(81.25, 81.25, 
81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 
81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 
81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 81.25, 
78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 
78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 78.75, 
78.75, 78.75, 78.75), Years_CE = c(800, 800, 800, 800, 800, 800, 
800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 
800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 
800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 
800, 800, 800, 800, 800), temp = c(-23.2279395461082, -22.5959677100182, 
-22.9541156888008, -23.4697868227959, -23.2690722942352, -23.2919907569885, 
-23.4045884013176, -22.6203962564468, -20.8181030750275, -20.8323660492897, 
-21.1287962198257, -21.1830872297287, -21.2242873311043, -21.2984372377396, 
-21.6488727927208, -22.3355931639671, -22.8920010924339, -23.5176593065262, 
-23.7143198847771, -23.4033827185631, -23.4045895934105, -23.4415615200996, 
-23.1572825312614, -22.8334090709686, -22.2590872049332, -21.0492706894875, 
-20.6457073688507, -18.4948316812515, -16.7946463823318, -18.3120978474617, 
-18.4638788104057, -18.6690977811813, -21.6257686018944, -22.1914752721786, 
-21.20003926754, -19.9879258871078, -20.4621767997742, -22.2486699819565, 
-20.9201712012291, -17.9803402423859, -17.2420032024384, -17.6654424071312, 
-18.9910494089127, -20.2454425692558, -21.4046941995621, -22.4127829670906, 
-23.4854105710983, -24.369870364666, -25.1887278556824, -26.0177202224731
)), row.names = c("469", "470", "471", "472", "473", "474", "475", 
"476", "477", "480", "481", "482", "483", "484", "485", "486", 
"487", "488", "489", "490", "491", "492", "493", "494", "495", 
"496", "497", "498", "499", "604", "607", "608", "611", "612", 
"613", "614", "615", "616", "617", "618", "621", "622", "623", 
"624", "625", "626", "627", "628", "629", "630"), class = "data.frame")

Code is here--

eu_avg_100 <- eu_amo_df_sub_NA_df  %>%
  group_by(Long, Lat, Years_CE) %>%
  dplyr::summarize(sd_10 = sd(temp))
#> Error in eu_amo_df_sub_NA_df %>% group_by(Long, Lat, floor(Years_CE/10) * : could not find function "%>%"

Created on 2022-11-15 with reprex v2.0.2

You probably need

library(magrittr)

You've only got one observation per group, so the sd cannot be calculated.

Hi @martin.R thank you for the response. Please, can you help me how can I add 10 observations per group?

It's your data. I don't know how you would expect me to guess what data you have.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.