Re: [R] Fill NA values in columns with values of another column

2024-08-27 Thread Bert Gunter
Thanks, Calum. After rereading the post, I came to your interpret it as you did. So glad that we agree. "easier" of course is in the mind of the beholder. But I'm glad that you presented a "tidyverse" approach. There are other issues of dependencies and efficiency that also might be relevant. Any

Re: [R] Fill NA values in columns with values of another column

2024-08-27 Thread CALUM POLWART
Bert I thought she meant she wanted to replace the NAs with the 6. But I could be wrong. It looks like the data is combined from cbind. I'm going to give tidyverse examples because it's (/s) *"always"* (/s) easier. require(tidyverse) # impute the missing NAs myData <- cbind(VB1d[,1],s1id[,1])

Re: [R] Fill NA values in columns with values of another column

2024-08-27 Thread Bert Gunter
Sorry, not clear to me. For group 8 in your example, do you want extract the values in column 1 that are not NA, i.e. one value, 6; or do you want to extract the number of values -- that is, the count -- that are not NA, i.e. 1? ... and for group 5, would it be c(9,9) for the values; or 2 for th

[R] Fill NA values in columns with values of another column

2024-08-27 Thread Francesca PANCOTTO via R-help
Dear Contributors, I have a problem with a database composed of many individuals for many periods, for which I need to perform a manipulation of data as follows. Here I report the procedure I need to do for the first 32 observations of the first period. cbind(VB1d[,1],s1id[,1]) [,1] [,2] [

Re: [R] boxplot of raster and shapefile

2024-08-27 Thread Ivan Krylov via R-help
В Mon, 26 Aug 2024 14:33:02 +0200 SIBYLLE STÖCKLI via R-help пишет: > > # Extract raster values within the shapefile > > extracted_values <- extract(raster_file, shape_file) > > # Assuming the shapefile has multiple polygons and you want to > > # create a boxplot for each > > data_list <- lapply