r - How do I work on a list using other list -


i have list containing 15 data frames.

> head(forecast_ucmseasonality) $us_month_businessconfidence  [1] 52.45713 53.49713 52.97712 53.15715 52.81716 52.75717 52.48875 53.00550 52.97213 52.77213 [11] 52.03886 52.33882  $us_month_chainstoresales  [1] 4099.952 4592.386 4195.608 4518.860 6230.274 9649.281 3373.654 3837.009 4417.476 4421.007 [11] 4857.800 4181.440  $us_month_cpi  [1] 235.905 236.223 236.575 237.335 237.890 238.772 239.448 239.241 239.313 239.363 239.250 [12] 239.159 

this list ucm result on list. have applied condition reduce large input values

train_dataucm <- lapply(train_data, transform, value = ifelse(value > 50000 , value/100000 , value )) #reducing large values in order ucm function work  ucm_trainseasonality <- lapply(train_dataucm, function(x) ucm(value~0,data = x , level=t, irregular=t,slope=t,season=t,season.length=12))  forecast_ucmseasonality <- lapply(ucm_trainseasonality, function(x) predict(x, n.ahead = 12)) 

the initial list looks :

 head(train_data[[5]])       datetime  value 721 2010-01-31 138438 722 2010-02-28 138581 723 2010-03-31 138751 724 2010-04-30 139297 725 2010-05-31 139241 726 2010-06-30 139141 

i showing 5th element in list because 1 got affected because of having large values.

also, identifying data frame list using following function :

has_too_high_values <- function (df)   any(df$value > 50000)  identify_val <- filter(has_too_high_values, train_data)  > identify_val $us_month_employedppl       datetime  value 721 2010-01-31 138438 722 2010-02-28 138581 723 2010-03-31 138751 724 2010-04-30 139297 725 2010-05-31 139241 726 2010-06-30 139141 727 2010-07-31 139179 

problem:

i want use list identify_val identify elements in forecast_ucmseasonality list multiplied 100000 correct forecasted values.

my sample code should this:

forecast_ucmseasonality <- lapply(forecast_ucmseasonality, function(x) ifelse(names(forecast_ucmseasonality) == names(identify_val) , x$value*100000, x$value)

i hope clear in question.

thank you.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -