A simple for loop iterating by one can be done by using the range To increment by two you can use the seq function This will print out every second number, since it is iterating by two here. Source: https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/seq
Category: R Language
How to get proportion of variance from prcomp in R
How to get proportion of variance from prcomp in R you might ask? You can see the value if you do a summary of prcomp You’ll get something that look like this: However, to actually get the value you can calculated it from the standard deviation variables. If you do a ? help on prcomp
Plot the PCA Principal Components Analysis in R
Calculating and plot the PCA Principal Components Analysis in R in RStudio example with comments: Now plotting it in RStudio you’ll get your view. So here I have three grouping with legends labels on the right. In this example the column one in the dataset is the group type (0, 1, 2). Autoplot() is just
RStudio run all
To run all the lines in your R file use the Source command or the shortcut Ctrl + Shift + S or if you want the echo feedback use Ctrl + Shift + Enter. The latter is close do the run a single line Ctrl + Enter. This will run the source command:
Github Actions building R install packages syntax error near unexpected token `c’
When trying to run the r-lib/actions/setup-r for R in Github Actions installing the dependencies. The pipeline yaml file I was missing adding shell: Rscript {0} at the end so the Install dependencies will be Source: https://github.com/r-lib/actions/tree/master/examples
Can’t load Rdata file in RStudio Error in readChar
When trying to load a Rdata file in RStudio and getting an error but it works fine if you load it directly from the file explorer. Output error: This might be due to a wrong working directory. First navigate to the correct folder. Then hit the menu “More” and select “Set as Working Directory” Now
Github Actions building R Error in read.dcf(path) cannot open the connection
When trying to run the r-lib/actions/setup-r for R in Github Actions installing the dependencies. When running this I get an error in read.dcf(path) cannot open the connection As the error message states isn’t trying to locate a DESCRIPTION file. Add a file called DESCRIPTION in the path it’s provided (most likely your root folder). Examples