how to add specific only certain labels on PCA plot in R
I need your help on something which should be extremely easy to do, but already took me a while to figure out.
When making a PCA plot in R, I need to label only certain category of the data on the graph. Could you help me with an advice how I do that? With the current code (see below) I get all labels, but i need only labels to be shown for the originaldata which do not contain word "No" in a column X.
Thanks!
My code:
plt < autoplot(
pcadata,
data = originaldata,
colour = 'Woi',
frame.type = 'norm',
frame.colour = 'TasteScore',
size = 3,
) +
geom_text(aes(label = paste(keepRows$Woi)), parse = TRUE)
See also questions close to this topic

Read a power point template in R
I'm looking for a way to read a power point template I already have, in order to avoid all the work in creating that formatting in R. (I'm still even looking for which package can do it: R2PPT, Displayr, OfficeR, ReporteRs (outdated), Q.)
The final goal, is creating a scatter plot chart (R gives its table as output) with the format already in the power point template. Is there any way to do this?

(nan vs NA)  Missing value imputation in pandas dataframe using R  randomForest::rfImpute
I have a pandas dataFrame:
result
result
has 2 columns:doy
(Day of Year values from 1 to 365).bookings
(279 numeric values and 86nan
values)I want to do a
randomForest Imputation using R
to fill the gaps for further spectral analysis.This is what I have tried so far using rpy2 within the Python script:
import random import rpy2.robjects as robjects from rpy2.robjects.packages import importr base = importr('base') utils = importr('utils') randomForest = importr('randomForest') from rpy2.robjects import pandas2ri pandas2ri.activate() r_df = pandas2ri.py2ri(result) type(r_df) print(base.summary(r_df)) random.seed(222) result.imputed = randomForest.rfImpute('bookings', 'doy', data=r_df)
and here is the error I get
RRuntimeError: Error in rfImpute.default("bookings", "doy", data = list(doy = 1:365, : No NAs found in "bookings"
I guess it's because
nan in python
isn't getting converted toNA in R.
But that's precisely why I have imported andactivated pandas2ri
Is there something else I should do to fix this?
I would also like to point out the following output
print(base.summary(r_df))
This implies the R code recognizes the null values. I am not able to pinpoint what I did wrong.

Creating a new class with parameters from a function
AIM: I would like to add a "distribution" and "parameters" to the
summary
output of a function I created.The function I created takes a
n
and a choice of distribution and returns random numbers from that distribution. The output of the function is an object of the classMyClass
.Further below I created the
summary
function for objects ofMyClass
which currently returns the length, mean and standard deviation of the output.PROBLEM: I would like for the
summary
function to also print out the original parameters of therandom_number_generator
function, see DESIRED OUTPUT below.random_number_generator < function(n,distribution,mean=NULL,sd=NULL,lambda=NULL,size=NULL,prob=NULL){ if (distribution=="Normal"){ x < rnorm(n=n,mean=mean,sd=sd) } if (distribution=="Poisson"){ x < rpois(n=n, lambda=lambda) } if (distribution=="Binomial") { x < rbinom(n=n,size=size,prob=prob) } class(x) < "MyClass" return (x) } answer < random_number_generator(n=10, distribution = "Binomial",size=15,prob=0.4) summary.MyClass < function(x) { stopifnot(inherits(x, "MyClass")) cat("\t\n", sprintf("Sample size: %s\n", length(x)), sprintf("Mean: %s\n", mean(x)), sprintf("Standard Deviation: %s\n", sd(x)) ) }
CURRENT OUTPUT:
summary(answer) Sample size: 10 Mean: 4.9 Standard Deviation: 1.59513148186739
DESIRED OUTPUT:
class(answer) [1] "MyClass" summary(answer) Sample size: 10 Mean: 4.9 Standard Deviation: 1.59513148186739 Distribution: "Binomial" Size: 15 Prob: 0.4

How to make working label inside of label with two diferent radios?
I'm using css to change the style of selected li (by input:checked + label>li) When I press 4.1 or 4.2 I want to change the style of li 4 also.
I thought that general label (for='opt4') will do the job, but Its not working. Is there a possibility to check the opt4 input when I press li 4.1 o 4.2?
<input type='radio' id='opt4' name='oom'> <label for='opt4'> <li> 4 <ul> <input type='radio' id='opt41' name='oop'> <label for='opt41'> <li> 4.1 </li> </label> <input type='radio' id='opt42' name='oop'> <label for='opt42'> <li> 4.2 </li> </label> </ul> </li> </label>
I want to check two different input at once  oop and oom

Save the date of the day in a label
I'm getting problem saving the date and the time of the day in a label. I have a TodoList that when I add something show the date and the time of when you did it. What I want to do is save it. For save I tried with user default but I have always the date and the time of the day and not of when I did. I think I'm doing something wrong. Any suggest of how can I save the date?
@IBOutlet weak var Data: UILabel! override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) Data.text = String(describing: DateFormatter()) let dataFormatter = DateFormatter() dataFormatter.dateFormat = "dd/MM/yy H:mm a" Data.text = dataFormatter.string(from: .init()) UserDefaults.standard.setValue(Data.text!, forKey: "Data") Data!.text=UserDefaults.standard.string(forKey: "Data") }

how to get version variable in aws cloudformation?
I have dynamodb arn string and want to combine manually about the string of stream arn.
arn:aws:dynamodb:useast1:123456789012:table/books_table arn:aws:dynamodb:useast1:123456789012:table/books_table/stream/20150511T21:21:33.291
Any one who knows how to get label in aws cloudformation of '20150511T21:21:33.291' and give me example combine the dynamodb arn string to dynamodb stream arn string.
ps:
I can not use:
Fn::GetAtt: [ 'dynamodbTableLogicalId', 'StreamArn' ]
Because my dynamodb arn is the output string of my nested stack. I do not want export everything in nested stack.

Dimension reduction technique for categorical data and missing values
I have a task in Visual Analytics and I have to cluster similar items. I have a dataset that is from a questionnaire so there is a lot of missing values and the majority of the variables are categoricals. My dataset is really big, so I want to do first a dimension reduction before applying a cluster algorithm to reduce the number of dimensions for 2D plotting.
My problem is that I don't know which technique to choose since I am quite new in this domain. I first plan to use Probabilistic PCA to overcome the missing values problems, but I read on internet that PCA is mostly use for numerical data and not for categorical data. So I found out that there is MCA that is a PCAlike technique developed for categorical data, but with this technique I don't know how to handdle the missing values...
I think that dropping missing values is not a good choice considering the amount of missing values the dataset has, I also think that it is not good to replace the missing values with the mean since it's going to really change the accuracy of the data.
So maybe can someone tell me if my reflection on the problem is not good and/or anyone has any implementation pointer in python please?

Singular values of a dataframe using R
I am trying to get the Singular values of a dataframe using R. The prcomp method displays the Standard Deviation and svd$d displays a vector. The values displayed are correct. But, I am not sure which one of these is the singular value in this case? I went through a few documents but they are not pointing to the right direction.
iris<read.table(file.choose(),header=T) #(i)Plotting singular values X.pca<prcomp(iris[,1:4],scale=T) X.pca # Displays the Standard Deviations svd(iris[,1:4])$d # Displays the d values

How do I keep id variable in pca analysis in r after running factor loadings?
I am trying to run social capital data through a principal components analysis (pca) in r by using the following dataset: https://aese.psu.edu/nercrd/community/socialcapitalresources/socialcapitalvariablesfor2014/socialcapitalvariablesspreadsheetfor2014/view
I run the analysis just fine, but I need to merge the factor loadings onto the original dataset for further analysis and presentation. I simply need to know how I can retain the id variables when I run a pca analysis so I can merge those onto the original dataset.
I have standardized the data, and then run the code below (which I gleaned from another source). I receive what appears to be factor loadings in one column for each county in the United States, but my problem is that my original database contains the id variables for each county (FIPS codes) but the factor loadings do not.
calcpc < function(variables,loadings) { # find the number of samples in the data set as.data.frame(variables) numsamples < nrow(variables) # make a vector to store the component pc < numeric(numsamples) # find the number of variables numvariables < length(variables) # calculate the value of the component for each sample for (i in 1:numsamples) { valuei < 0 for (j in 1:numvariables) { valueij < variables[i,j] loadingj < loadings[j] valuei < valuei + (valueij * loadingj) } pc[i] < valuei } return(pc) } xxx<calcpc(standardisedconcentrations, socialcapital.pca$rotation[,1])