0

enter image description here Hello, I have this type of table consisting of a single row and several columns. I have tried a code to extract my KD_PL parameters without success. Do you know a way in R to extract all the KD_PLs and store them in a vector or data frame array?

I tried this:

KDPL <- select("KD_PL.", which(substr(colnames(max_LnData), start=1, stop=6)))

kjetil b halvorsen
  • 1,206
  • 2
  • 18
  • 28
Yourda
  • 1
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Please [do not post code or data in images](https://meta.stackoverflow.com/q/285551/2372064) – MrFlick Jan 13 '23 at 15:56

1 Answers1

0

This should do the trick:

library(tidyverse)
KDPL <- max_LnData %>% select(starts_with("KD_PL."))

This function selects all columns from your old dataset starting with "KD_PL." and stores them in a new dataframe KDPL.

If you only want the names of the columns to be saved, you could use the following:

KDPL_names <- colnames(KDPL)

This saves the column names in the vector KDPL_names.