search for: sdf2

Displaying 20 results from an estimated 28 matches for "sdf2".

Did you mean: sda2
2008 May 14
2
Dividing Two Dataframes
Hi, I have two dataframes one with 144 rows and 160 columns (SDF1) and one with 12 rows and 160 columns (SDF2). Now I'm trying to divide rows 1:12 with SDF2, rows 13:24 with SDF2, rows 25:36 with SDF 2, . In S-Plus the following code works fine: DFS = SDF1[1:144,1:60] / as.vector(SDF2[1:12,1:160]) but in R when I try to implement the formula I get the following error: "/ only defined f...
2008 May 15
2
Adding columns to dataframe
Hi, I have a dataframe SDF1 that looks like this: Char1 Char2 Char 3 W.2007.02 W.2007.09 W.2007.16 W.2008.13 A C1 F1 F2 F3 A C2 F4 B C3 F5 F6 I have another dataframe SDF2 with 163 cols that has the following column names Char1 Char2 Char 3 W.2007.02 W.2007.03 W.2007.04 W.2007.05 W.2007.06 .W.2007.52 W.2008.01 . W.2008.13 Now I would like to add the missing period names to SDF1 as new columns and in the same order as in SDF2. Therefore I use the following formu...
2018 Jan 08
2
Replace NAs in split lists
Thank you Jeff. Your code works, as usual , perfectly. I am just wondering why if i put the whole code in one line, i get an error message. sdf2 <- lapply( sdf, function(z){z$Value <-ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z}) error. unexpected symbol in sdf2 Thanks again EK On Mon, Jan 8, 2018 at 3:12 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > Upon closer examination I see that you are no...
2018 Jan 08
1
Replace NAs in split lists
OPS! Sorry i did indeed posted the code in HTML; should have known better. ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z}) error. unexpected symbol in sdf2 On Mon, Jan 8, 2018 at 11:44 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > I don't know. You seem to be posting in HTML so your code is mangled. Can you post plain text and use the reprex package to make sure it produces the errorin a clean R session? > -- > Sent fro...
2018 Jan 08
0
Replace NAs in split lists
...R session? -- Sent from my phone. Please excuse my brevity. On January 8, 2018 8:03:45 AM PST, Ek Esawi <esawiek at gmail.com> wrote: >Thank you Jeff. Your code works, as usual , perfectly. I am just >wondering why if i put the whole code in one line, i get an error >message. >sdf2 <- lapply( sdf, function(z){z$Value ><-ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z}) >error. unexpected symbol in sdf2 > >Thanks again > >EK > > >On Mon, Jan 8, 2018 at 3:12 AM, Jeff Newmiller ><jdnewmil at dcn.davis.ca.us> wrote: >> U...
2018 Jan 08
0
Replace NAs in split lists
...: 08/01/2018 16:03 (GMT+00:00) Para: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>, r-help at r-project.org Assunto: Re: [R] Replace NAs in split lists Thank you Jeff. Your code works, as usual , perfectly. I am just wondering why if i put the whole code in one line, i get an error message. sdf2 <- lapply( sdf, function(z){z$Value <-ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z}) error. unexpected symbol in sdf2 Thanks again EK On Mon, Jan 8, 2018 at 3:12 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > Upon closer examination I see that you are no...
2018 Jan 08
0
Replace NAs in split lists
...d.table( text= "ID ID_2 Firist Value 1 a aa TRUE 2 2 a ab FALSE NA 3 a ac FALSE NA 4 b aa TRUE 5 5 b ab FALSE NA ", header=TRUE, as.is=TRUE ) sdf <- split( df1, df1$ID ) # note the extra [ 1 ] in case you have more than one non-NA value # per ID sdf2 <- lapply( sdf , function( z ) { z$Value <- ifelse( is.na( z$Value ) , z$Value[ !is.na( z$Value ) ][ 1 ] , z$Value ) z }...
2018 Jan 08
3
Replace NAs in split lists
Why do you want to modify df1? Why not just reassemble the parts as a new data frame and use that going forward in your calculations? That is generally the preferred approach in R so you can re-do your calculations easily if you find a mistake later. -- Sent from my phone. Please excuse my brevity. On January 7, 2018 7:35:59 PM PST, Ek Esawi <esawiek at gmail.com> wrote: >I just came
2012 Jan 26
2
Calculate a function repeatedly over sections of a ts object
...ily time series object by sliding a time window of constant length (e.g. 10 consecutive years or 1825 days) over the entire ts at increments of 1 time unit (e.g. 1 year or 365 days). So for example, the first SDF would be calculated for the daily values of my variable recorded between years 1 to 5, SDF2 to those for years 2 to 6 and so on until the total length of the series is covered. How can I implement this into a R script? Any help is much appreciated. Jorge
2012 Aug 01
1
How to trigger automount of USB drives in Centos6
...en the script runs if it wasn't unplugged and replugged to trigger the automount. Problem is, it is not certain that the same drive will be used so I cannot simply hard code a line that just do a mount -t ntfs-3g /dev/sde1 /media/backup. I cannot assume it would always be say /dev/sde1 or /dev/sdf2 as that depends on how many drives are connected before that and how was that particular drive partitioned. The inbuilt auto mount mechanism also appears to use different mountpoints for different USB drives (based on drive label?) and so the best way for me is to force all USB drives to be remoun...
2018 Jan 08
2
Replace NAs in split lists
...a aa TRUE 2 > 2 a ab FALSE NA > 3 a ac FALSE NA > 4 b aa TRUE 5 > 5 b ab FALSE NA > ", header=TRUE, as.is=TRUE ) > > sdf <- split( df1, df1$ID ) > # note the extra [ 1 ] in case you have more than one non-NA value # per ID > sdf2 <- lapply( sdf > , function( z ) { > z$Value <- ifelse( is.na( z$Value ) > , z$Value[ !is.na( z$Value ) ][ 1 ] > , z$Value > ) >...
2018 Jan 08
0
Replace NAs in split lists
...FALSE NA >> 3 a ac FALSE NA >> 4 b aa TRUE 5 >> 5 b ab FALSE NA >> ", header=TRUE, as.is=TRUE ) >> >> sdf <- split( df1, df1$ID ) >> # note the extra [ 1 ] in case you have more than one non-NA value # >per ID >> sdf2 <- lapply( sdf >> , function( z ) { >> z$Value <- ifelse( is.na( z$Value ) >> , z$Value[ !is.na( z$Value ) ][ 1 >] >> , z$Value >>...
2018 Jan 08
2
Replace NAs in split lists
...NA > >> 4 b aa TRUE 5 > >> 5 b ab FALSE NA > >> ", header=TRUE, as.is=TRUE ) > >> > >> sdf <- split( df1, df1$ID ) > >> # note the extra [ 1 ] in case you have more than one non-NA value # > >per ID > >> sdf2 <- lapply( sdf > >> , function( z ) { > >> z$Value <- ifelse( is.na( z$Value ) > >> , z$Value[ !is.na( z$Value ) ][ 1 > >] > >> , z$Value > >&...
2017 Dec 14
2
help with recursive function
...queid) sdf <- lapply(s, function(x) { data.frame(x, x$outlier <- ifelse(is.na(x$lp_norm), NA, ifelse(abs(x$lp_norm) == x$norm_max, "yes", "no")), x$lp <- with(x, ifelse(outlier == "yes", NA, lp))) x }) sdf2 <- bind_rows(sdf) all_dat <- bind_rows(df_clean, sdf2) all_dat } # funlp2 function funlp2<-function (dataset) { data1 <- dataset df_clean <- with(data1, data1[norm_sd < 1, ]) datD <- with(data1, data1[norm_sd >= 1, ]) s <- split(datD, da...
2017 Dec 14
0
help with recursive function
...; data.frame(x, x$outlier <- ifelse(is.na(x$lp_norm), NA, > > ifelse(abs(x$lp_norm) == x$norm_max, "yes", "no")), > > x$lp <- with(x, ifelse(outlier == "yes", NA, lp))) > > x > > }) > > sdf2 <- bind_rows(sdf) > > all_dat <- bind_rows(df_clean, sdf2) > > all_dat > > } > > > # funlp2 function > > funlp2<-function (dataset) > > { > > data1 <- dataset > > df_clean <- with(data1, data1[norm_sd < 1, ]) >...
2017 Dec 14
2
help with recursive function
...ifelse(is.na(x$lp_norm), NA, >> >> ifelse(abs(x$lp_norm) == x$norm_max, "yes", "no")), >> >> x$lp <- with(x, ifelse(outlier == "yes", NA, lp))) >> >> x >> >> }) >> >> sdf2 <- bind_rows(sdf) >> >> all_dat <- bind_rows(df_clean, sdf2) >> >> all_dat >> >> } >> >> >> # funlp2 function >> >> funlp2<-function (dataset) >> >> { >> >> data1 <- dataset >> &g...
2018 Jan 08
0
Replace NAs in split lists
...TRUE 5 >> >> 5 b ab FALSE NA >> >> ", header=TRUE, as.is=TRUE ) >> >> >> >> sdf <- split( df1, df1$ID ) >> >> # note the extra [ 1 ] in case you have more than one non-NA value ># >> >per ID >> >> sdf2 <- lapply( sdf >> >> , function( z ) { >> >> z$Value <- ifelse( is.na( z$Value ) >> >> , z$Value[ !is.na( z$Value ) ][ >1 >> >] >> >>...
2017 Dec 14
2
help with recursive function
...- lapply(s, function(x) { data.frame(x, x$outlier <- ifelse(is.na<http://is.na>(x$lp_norm), NA, ifelse(abs(x$lp_norm) == x$norm_max, "yes", "no")), x$lp <- with(x, ifelse(outlier == "yes", NA, lp))) x }) sdf2 <- bind_rows(sdf) all_dat <- bind_rows(df_clean, sdf2) all_dat } # funlp2 function funlp2<-function (dataset) { data1 <- dataset df_clean <- with(data1, data1[norm_sd < 1, ]) datD <- with(data1, data1[norm_sd >= 1, ]) s <- split(datD, da...
2017 Dec 14
0
help with recursive function
...- lapply(s, function(x) { data.frame(x, x$outlier <- ifelse(is.na<http://is.na>(x$lp_norm), NA, ifelse(abs(x$lp_norm) == x$norm_max, "yes", "no")), x$lp <- with(x, ifelse(outlier == "yes", NA, lp))) x }) sdf2 <- bind_rows(sdf) all_dat <- bind_rows(df_clean, sdf2) all_dat } # funlp2 function funlp2<-function (dataset) { data1 <- dataset df_clean <- with(data1, data1[norm_sd < 1, ]) datD <- with(data1, data1[norm_sd >= 1, ]) s <- split(datD, da...
2017 Dec 14
0
help with recursive function
...; data.frame(x, x$outlier <- ifelse(is.na(x$lp_norm), NA, > > ifelse(abs(x$lp_norm) == x$norm_max, "yes", "no")), > > x$lp <- with(x, ifelse(outlier == "yes", NA, lp))) > > x > > }) > > sdf2 <- bind_rows(sdf) > > all_dat <- bind_rows(df_clean, sdf2) > > all_dat > > } > > > # funlp2 function > > funlp2<-function (dataset) > > { > > data1 <- dataset > > df_clean <- with(data1, data1[norm_sd < 1, ]) >...