Data from one table to select data columns from another table, using r

Screamh

My data table, tab, is 2000 x 500, y1 = col1, y2 = col2, y3 = col3 …. Y500 = col500. See image.

partial data table

I want to carry out some PCA work on a section of this, e.g y1 = col1, y22 = col22, y36 = col36, y41 = col41, and so on.

A separate data table, SM, contains the column ID,and refers to the columns in the main data table (tab) I want to consider. There are 200 such entries.

Image of SM follows.

Partial ID table

The following

fit.std <- prcomp(tab, scale.=T)

Pulls in all the column entries.

If I have 200 specific columns of data to consider, entering the column numbers manually would be very time consuming and error prone.

Can someone please tell me how to take the data from column ID (in data table SM), to select the corresponding columns in the data table tab, and then include in the fit.std line?

Is there a way to take in the data in SM to enable me to select the required columns in the larger data table tab? In order words, SM col1 would correspond to tab col1, SM col22 would correspond to tab col22, and so on.

fit.std <- promo(c(ID$*), scale = TRUE)

where ID$* contains the data table SN entries I want to match with columns in tab?

Thank you.

Akindele Davies

Ok based on your updated question, it looks like you want to subset the dataframe tab, selecting only the columns listed in SM$ID.

You can do that with:

tab[,SM$ID]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Append columns from one data table to another data table

Select all data from one table that does not exists in another table given 3 key columns

Select data from one table & then rename the columns based on another table in SQL server

SQLite: How to retrieve data from column in one table using SELECT to insert retrieved data in another table

Select data (join?) from only one table using an id from another table

R: Using IDs from another table, replace these IDs in 2 columns in another table with the relevant data

Select data from one table with the conditions from another

Update records of one table using data from another table

Append data from one table to another table

Copy Data from one table to another table

VBA Copying data from one table to another and rearranging columns

Procedure to insert data from one column into two columns in another table

Using data.table in R, can I select a vector of variable columns from a table?

best way to select data from one table or another

Select data from one table based on selected rows in another

Using data.table to select rows by distance from another row

How to use a data from one table as a reference to get another data in another table using Firebase?

How to select duplicate columns data from table

How to select rows from one data.table to apply in another data.table?

mysql copy data from one table to another using foreign key

Copying data from one table to another using php mysqli fails

update one table with data from another using derived key value

insert data from one table into another using a condition mysql

Transferring data from one table to another using a where clause mysql

getting data of 2 columns from one table

Select data from one table that depends on values from another table in mysql

Select data from one table base on selection from another table in SQL

How to select data from one table and select count to another table and combine it in MySQL?

IF NULL select data from another table